LOOP 1.Which of the following statement about for loop is true ? ans:- All 2.The GOTO statement is used: ans:- an unconditional transfer of control to a named label (C) 3.How many times i value is checked in the following C code? #include <stdio.h> int main() { int i = 0; do { i++; printf("in while loop\n"); } while (i < 3); } ans:- 3 times 4.Give Output #include <stdio.h> void main() { int i = 2; do { printf("Hi"); } while (i < 2); } ans:- Hi 5. What will be the output of the following C code? #include <stdio.h> int main() { while () printf("In while loop "); printf("After loop\n"); } ans:- Compile time error 6. #include <stdio.h> void main() { int i = 0; do { printf("Hello"); } while (i != 0); } ans:- Hello 7.#include <stdio.h> void main() { int i = 0; while (++i) { printf("H"); } ans:- H print infinite times 8.#include <stdio.h> void main() { double k = 0; for (k = 0.0; k < 3.0; k++); printf("%lf", k); } ans:- 3.0000 9.#include <stdio.h> void main() { int k; for (k = -3; k < -5; k++) printf("Hello"); } ans:- nothing or null 10. #include <stdio.h> int main() { int i = 0; for (;;;) printf("In for loop\n"); printf("After loop\n"); } ans:- compile time error 11.What will be the output of the following C code? #include <stdio.h> int main() { int i = 0; for (i++; i == 1; i = 2) printf("In for loop "); printf("After loop\n"); } a)In for loop after loop b) After loop c) Compile time error d) Undefined behaviour 12.#include <stdio.h> int main() { for (int i = 0;i < 1; i++) printf("In for loop\n"); } ans:- in for loop 13. #include<stdio.h> int main() { int a=32; do { printf("%d ", a); a++; }while(a <= 30); return 0; } ans:- 32 14.int main() { int a=32; do { printf("%d ", a); a++; if(a > 35) break; }while(1); return 0; } ans:- 32 33 34 35 15. int main() { int k; for(k=1; k <=5; k++); { printf("%d ", k); } return 0; } ans:- 6 16. #include < stdio.h > void main() { unsigned char var=0; for(var=0;var<=255;var++) { printf("%d ",var); } } ans::- 0 1 2...255 17. int main() { int n; for (n = 9; n!=0; n--) printf("n = %d", n--); return 0; } ans:- infinite loop 18. #include <stdio.h> int main() { int i=1; while(i<=10 && i++) printf("\nHello"); } ans:- hello 10 times ARRAY 1. Consider the statement int val[2] [4] = { 1, 2, 3, 4, 5, 6, 7, 8} ; 4 will be the value of a.val[0 ][ 3] b.val[0 ][ 4] c.val[1 ][ 1] d.none ans:- a 2.4_5 Position number contained within a square brackets e.g. my_array [5], is referred as 1.post scripts 2.subscript 3.element 4.none ans:- 2 3. int main() { int arr[1]={10}; printf("%d\n", 0[arr]); return 0; } ans:- 10 4. #include<stdio.h> Int main() { char *str =”hello, world\n”; printf(“%d”, strlen(str)); } ans:- 13 5.#include <stdio.h> int main() { printf("variable! %d \n", x); return 0; } ans:- error 6. #include <stdio.h> int main() { int main = 3; printf("%d", main); return 0; } ans:- 3 7. If the two strings are identical, then strcmp() function returns ans:- 0 8. #include <stdio.h> int main() { int a, b; printf("%d", scanf("%d%d",&a,&b)); return 0; } ans:- 2 9. What will be the output of the program? #include<stdio.h> #include<string.h> int main() { char str1[20]="hello",str2[20]="world"; printf(“%s\n”, strcpy(str2, strcat(str1,str2))); return 0; } ans:- helloworld 10.#include<stdio.h> Int main() { printf(5+”Good Morning\n”); return 0; } a. Good Morning b. Good c. d. M Morning ans:- d 11. Which of the following is not a library function that operates on string? 1.strlen() 2.strcpy 3.strcmp 4.StrCon() ans:- 4 12. In below program, what would you put in place of “?” to print “Quiz”? #include <stdio.h> int main() { char arr[] = "GeeksQuiz"; printf("%s", ?); return 0; } ans:- arr+5 13. void main() { int x = 10; float x = 10; printf("%d", x) } ans:- compile time error 14. What is the worst case complexity of bubble sort? 1.(nlogn) 2.O(logn) 3.(n) 4.(n2) ans:- 4 15. #include<stdio.h> Int main() { char str[11]=”hello”; char *str1= “world”; strcat(str,str1); printf(“%s %d “,str, str[10]); } a. helloworld 0 b. helloworld anyvalue c. worldhello 0 d. Segmentation fault/code crash ans:- a