Question
#include<stdio.h>
int check(int);
int main()
{
int i=45, c;
c = check(i);
printf("%d\n", c);
return 0;
}
int check(int ch)
{
if(ch >= 45)
return 100;
else
return 10;
}
What will be the output of the program?
#include<stdio.h>
int check(int);
int main()
{
int i=45, c;
c = check(i);
printf("%d\n", c);
return 0;
}
int check(int ch)
{
if(ch >= 45)
return 100;
else
return 10;
}
Answer: Option A
Was this answer helpful ?
Step 1: int check(int); This prototype tells the compiler that the function check()accepts one
integer parameter and returns an integer value.
Step 2: int l=45, c; The variable i and c are declared as an integer type and i is initialized to 45.
The function check(i) return 100 if the given value of variable i is >=(greater than or equal to) 45,
else it will return 10.
Step 3: c = check(i); becomes c = check(45); The function check() return 100 and it get stored in
the variable c.(c = 100)
Step 4: printf("%d`setminus`n", c); It prints the value of variable c.
Hence the output of the program is '100'.
Was this answer helpful ?
Submit Solution