Questions 11: Predict the output of the following code :
#include < stdio.h > int main(){ int a=10,b=0; while(a>=b) { a=a-1; printf("%d",a); } return 0; }
Answer: c) 9 8 7 6 5 4 3 2 1 0 -1
Questions 12: What will be the output of the following code?
#include < stdio.h > int main(){ int y=1,x; for(x=0;x<=2;x++){ while(y < 3) { printf(" %d",x+y); y++; } } return 0; }
Answer: d) 1 2
Questions 13: What will be the output of the following code?
#include < stdio.h > int main(){ int n=1,r=3,c; for(c=1;c < =r;c++) n=n*c; printf("%d",n); return 0; }
Answer: b) 6
Questions 14: What will be the output of the following code?
#include < stdio.h > int main(){ int y=2,z=4; printf("%d ",(y || z) && (z || y)); return 0; }
Answer: b) 1
Questions 15: What will be the output of the following code?
#include < stdio.h > int main(){ int x=7; float y=7.0; if ( x==y ) printf("Equal"); else printf("Unequal"); return 0; }
Answer: a) Equal
Questions 16: What will be the output of the following code?
#include < stdio.h > int main(){ int arr[]={3,7,18,9,5}; int result = ++arr[3]; printf("%d",result); return 0; }
Answer: b) 10
Questions 17: What will be the output of the following code ?
#include < stdio.h > int main(){ int no = 2357; float amount = 125.00; while(no>0) { if((amount >100.00) && (amount <=125.00)) printf("Discount is 50%"); else printf("Discount is 30%"); } return 0; }
Answer: a) Discount is 50% will be displayed infinitly
Questions 18: What will be the output of the following question?
#include < stdio.h > int main(){ int n = 10; for (int index = 0;index<=5;index++) n = n * index; printf("%d",n); return 0; }
Answer: a) 0
Questions 19: How many will following loop take to find key = 37 in array?
#include < stdio.h > int main() { int key=37; int c=0; int array[]={27,17,47,37,67}; for (int ele = 0; ele<=4;ele++){ if ( array[ele]== key){ printf("found"); break; } } return 0; }
Answer: b) 4
Questions 20: What will be the output of the following code?
#include < stdio.h > int main(){ int Mark=90; int Flag; while(Mark>=0){ if(Mark>100){ printf("Invalid Mark"); Flag = 0; } else { printf("Valid Mark"); Flag = 1; } } return 0; }
Answer: b) Valid Mark will be displayed infinitly