Question: Write a C program, final_q1.c, which reads two integers andprints all the integers between the twointegers which have their bottom 2 bits set. Only print

Write a C program, final_q1.c, which reads two integers andprints all the integers between the twointegers which have their bottom 2 bits set.

Only print integers between the two integers, the two integersthemselves should not be printed.

Reminder: a bit is said to be set if it isa 1, and unset if it is a 0.
So:

  • 19, whichis 10011 inbinary, has its bottom 2 bits set.

  • 21, whichis 10101 in binary, does nothave its bottom 2 bits set.

For example:

./final_q1315711./final_q146./final_q150705155596367./final_q1244227313539

You can use make to build your code:

make final_q1
  • Your program can assume its inputonly contains only 2 integers, one per line.

  • Your program can assume the firstinteger is not greater than the second integer.

  • Your program can assume that bothintegers will fit in a C int variable.

  • Your solution must bein C only.
    Your solution must not bein MIPS, C++, Python, orany other language.

  • Your program cannot call externalprogram.
    Your program cannot use anyof: fork(), exec(), posix_spawn(), system(), orany other similar functions.

  • No error checking is necessary orrequired.

// read two integers and print all the integers which have theirbottom 2 bits set.

int main(void) {
int x, y;

scanf("%d", &x);
scanf("%d", &y);

// PUT YOUR CODE HERE

return 0;
}

Step by Step Solution

3.40 Rating (163 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Answer include int mainvoid int x y scanfd x scanfd y ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Electrical Engineering Questions!