Knowee
Questions
Features
Study Tools

Select the missing code lines from the dropdown provided.The C code given below should print the reverse of a number entered by the user.But, line numbers 9 and 10 are missing.1. #include <stdio.h>2. int main()3. {4.   int num, reverse=0, rem;5.   printf("Enter an integer:");6.   scanf("%d", &num);7.   while(num>0)8.   {9.        ---------------Missing code -------------------10.      ---------------Missing code -------------------11.      num/=10;12.   }13.   printf("Reverse is = %d",reverse);14.   return 0;15. }

Question

Select the missing code lines from the dropdown provided.The C code given below should print the reverse of a number entered by the user.But, line numbers 9 and 10 are missing.1. #include <stdio.h>2. int main()3. {4.   int num, reverse=0, rem;5.   printf("Enter an integer:");6.   scanf("%d", &num);7.   while(num>0)8.   {9.        ---------------Missing code -------------------10.      ---------------Missing code -------------------11.      num/=10;12.   }13.   printf("Reverse is = %d",reverse);14.   return 0;15. }

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

The missing lines of code are used to calculate the reverse of the number. Here are the missing lines:

  1. rem = num % 10;
  2. reverse = reverse * 10 + rem;

So, the complete code would look like this:

  1. #include <stdio.h>
  2. int main()
  3. {
  4. int num, reverse=0, rem;
  5. printf("Enter an integer:");
  6. scanf("%d", &num);
  7. while(num>0)
  8. {
  9. rem = num % 10;
  10. reverse = reverse * 10 + rem;
  11. num/=10;
  12. }
  13. printf("Reverse is = %d",reverse);
  14. return 0;
  15. }

This problem has been solved

Similar Questions

Select the missing code lines from the dropdown provided.The C code given below should print the sum of digits of a number entered by the user.But, line numbers 6 and 10 are missing.1. #include<stdio.h>2. int main()3. {4.     int num, sum=0, rem;5.     printf("Enter a number\n");6.     ---------------Missing code -------------------7.     while(num>0)8.     {9.         rem = num%10;10.   ---------------Missing code -------------------       11.         num = num/10;12.     }13.     printf("Sum is %d\n", sum);14.     return 0;15. }

Select the missing code lines from the dropdown provided.The C code given below should count digits of a number entered by the user.But, line numbers 7 and 9 are missing.1. #include <stdio.h>2. int main()3. {4.   int num,count=0;5.   printf("Enter an integer: ");6.   scanf("%d", &num);7.   ---------------Missing code -------------------8.   {9.   ---------------Missing code -------------------10.       ++count;11.   }12.   printf("Number of digits: %d",count);13. }

Select the missing code lines from the dropdown provided.The C code given below should print the factorial of a number entered by the user.But, line numbers 4 and 10 are missing.1. #include<stdio.h>2. int main()3. {4.     ---------------Missing code -------------------5.     printf("Enter a number\n");6.     scanf("%d",&num);7.     while(num>0)8.     {9.         fact = fact * num;10.       ---------------Missing code -------------------11.     }12.     printf("Factorial is %d\n", fact);13.     return 0;14. }

Fill in the missing code in the below sample code to reverse the given string.

Select the missing code lines from the dropdown provided.The  C code given below should find the product of two numbers entered by the user.But, line numbers 4 and 7 are missing.#include<stdio.h>int main(){  ---------------Missing code -------------------    printf("Enter two numbers\n");    scanf("%d%d",&a,&b);  ---------------Missing code -------------------    return 0;}

1/4

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.