Knowee
Questions
Features
Study Tools

What will be the output of the program?  Write the answer in digits not alphabets.#include<stdio.h>int main(){ int a=2,b=6,c; c = a%b; printf("%d",c); return 0;}

Question

What will be the output of the program?  Write the answer in digits not alphabets.#include<stdio.h>int main(){ int a=2,b=6,c; c = a%b; printf("%d",c); return 0;}

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

Solution

The output of the program will be 2.

Here's the step by step explanation:

  1. The program starts with the inclusion of the stdio.h header file which is used for input/output operations in C.

  2. The main function is declared which is the entry point of any C program.

  3. Inside the main function, three integer variables a, b, and c are declared. The variables a and b are initialized with the values 2 and 6 respectively.

  4. The modulus operation is performed on a and b (a%b) and the result is stored in the variable c. The modulus operation gives the remainder of the division of a by b. Since 2 divided by 6 gives a remainder of 2, the value of c becomes 2.

  5. The printf function is used to print the value of c, which is 2.

  6. The return 0 statement signifies the successful termination of the program.

So, the output of the program is 2.

This problem has been solved

Similar Questions

What will be the output of the program?  Write the answer in digits not alphabets.#include<stdio.h>int main(){    int a=5;    int b=++a*a++;    printf("%d",b);    return 0;}

What will be the output of the following program? Write the answer in digits not alphabets.#include<stdio.h> int main() {     float i=10, *j;     void *k;     k=&i;     j=k;     printf("%.2f", *j);     return 0; }

What will be the output of the following program?

What will be the output of following program?main( ){int k, num = 30 ;k = ( num > 5 ? ( num <= 10 ? 100 : 200 ) : 500 ) ;printf ( "\n%d", num ) ;}

What will be the output of the following program?12345678910#include <stdio.h> int main() { int a[10]; *a = 7; *(a+1) = 12; int p = *(a+1) / *a; printf("%d", p); 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.