Ticker

6/recent/ticker-posts

Header Ads Widget

Responsive Advertisement

Program output questions

Q1.What will be the output of following code

// Assume all header files are included

int main()

{

 int a=89;

 printf("%c",a);

 return 0;

}

A. 89

B. y

C. Y

D. Runtime Error : %c not suitable for integer type.

Ans : C

Explanation : %c is used for printing the character values, also ASCII code of ‘Y’ is 89.

Q2.What will be the output of following code

// Assume all header files are included

int main(void)

{

int cog;

cog=printf("Hey,Welcome")+printf(" to world");

printf("\n%d characters were printed",cog);

return 0;

}

A. 20 characters were printed

B. Hey,Welcometo world
    20 characters were printed

C. Hey,Welcome to world
    20 characters were printed

D. RunTime Error : Cannot assign string values to integer type.

Ans : C

Explanation : Option C is correct as at first, message written inside printf() will be printed and then cog variable holds the length of “Hey,Welcome to world”, will be printed along with ” characters were printed”.

Q3.What will be the output of following code

// Assume all header files are included

int main(void)

{

int cog=15,bog=23,c;

c=subtract(cog,bog);

return 0;

}

int subtract(int a,int b)

{

return a-b;

}

A. -8

B. 8

C. 0

D. ERROR – Function subtract needs to be declared before main() or function prototype must be provided .

Ans : D

Q4.What will be the output of following code

int main(void)

{

 int k=7;

 float l=7;

 if(k==l)

 {

  printf("EQUAL\n");

 }

 else

 {

  printf("NOT EQUAL\n");

 }

return 0;

}

A. EQUAL

B. NOT EQUAL

C. Error

D. None of these

Ans : C

Q5.What will be the output of following code

// Assume all header files are included

#include

int main(void)

{

int a=435;

int b=432;

int res;

res=findrem(a,b);

int findrem(int x,int y)

{

return x%y;

}

printf("%d",res);

return 0;

}

A. -8

B. 8

C. 0

D. ERROR – Function subtract needs to be declared before main() or function prototype must be provided .

Ans : D

Q6.What will be the output of following code

// Assume all header files are included

int main(void)

{

 int k=7;

 float l=7;

 if(k==l)

 {

  printf("EQUAL\n");

 }

 else

 {

  printf("NOT EQUAL\n");

 }

return 0;

}

A. EQUAL

B. NOT EQUAL

C. Error

D. None of these

Ans : A

Q7.What will be the output of following code

// Assume all header files are included

#include.....

int a=30;

main(void)

{

a=43;

printf("%d", a);

}

A. 30

B. 43

C. 0

D. ERROR – Cannot Override Global variable.

Ans : B

Q8.What will be the output of following code

// Assume all header files are included

#include.....

int find(int x)

{

 return x+2;

}

int main(void)

{

 int a=44;

 int res;

 res=find(a);

 printf("%d",res);

 return 0;

}

A. 46

B. 44

C. 0

D. ERROR – res variable can not hold integer value.

Ans : A

Explanation :

res = find(44)
find(44) : return (44 + 2)
res = 46

Q9.What will be the output of following code

// Assume all header files are included

int find(int x,int y)

{

return (x*5+y*86);

}

int main(void)

{

int a=44,b=32;

int res;

res=find(a);

printf("%d",res);

return 0;

}

A. 44

B. 32

C. 76

D. ERROR -Too few Arguments passed

Ans : D

Q10.What will be the output of following code

A. 30

B. 43

C. 0

D. ERROR – Cannot Override Global variable.

Ans : B

Post a Comment

0 Comments