C and COBOL Programming Quiz

Test your knowledge of C and COBOL programming languages with questions on preprocessor directives, operators, pointers, data types, control structures, ENVIRONMENT DIVISION, MOVE statements, subscripts, file handling, and comments.

20 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

Comments (Not remarks) should be in

  1. Upper case
  2. running text
  3. Any of above
  4. Not a part of standard.
Question 2 Multiple Choice (Single Answer)

While reading a SDF file, if AT END clause is skipped,

  1. program will abort
  2. command will fail but last line will remain populated in the file- variables
  3. command will fail and file-variables will be blank
  4. the program will give a compile time error
Question 3 Multiple Choice (Single Answer)

All subscripts should be defined as PIC ____?

  1. NUMERIC
  2. BINARY
  3. ALPHANUMERIC
  4. ANY OF THE ABOVE
Question 4 Multiple Choice (Single Answer)

Which of the following set of statements is correct as per standards?

  1. MOVE 1 TO A.
  2. MOVE 1 TO A
  3. Both of the above.
  4. None of the above
Question 5 Multiple Choice (Single Answer)

In the ENVIRONMENT DIVISION which paragrahs should a program (not a subroutine) have?

  1. ERROR RECOVERY
  2. ROLLBACK
  3. Any one of the above
  4. Both of the above
Question 6 Multiple Choice (Single Answer)

#define T t void main() { char T=’T’; printf(“\n%c\t%c\n”,T,t); }

  1. t t
  2. t T
  3. T t
  4. T T
Question 7 Multiple Choice (Single Answer)
  1. void main() { unsigned char a; a = 0XFF + 1; printf(“%d”,a); }
  1. 255
  2. 256
  3. 0
  4. 1
Question 8 Multiple Choice (Single Answer)
  1. void main() { int x=10; (x<0) ? (int a = 100) : (int a=1000); printf(“%d”,a); }
  1. 10
  2. 1000
  3. error
  4. none of this
Question 9 Multiple Choice (Single Answer)

main() { int *p1, i=25; void *p2; p1=&i; p2=&i; p1=p2; p2=p1; printf(“%d”,i); }

  1. error
  2. 25
  3. will not complie
  4. some memory address
Question 10 Multiple Choice (Single Answer)
  1. void swap(int &, int &); void main() { int a=10, b=20; swap(a++,b++); printf(“\n%d\t%d\t”,a,b); } void swap(int &x, int &y) { x+=2; y+=3; }
  1. 11 21
  2. 13 24
  3. 10 20
  4. 12 23
Question 11 Multiple Choice (Single Answer)
  1. void abc(int a[]) { a++; a[1] = 612; } main() { char a[5]; abc(a); printf(“%d”,a[4]); }
  1. error
  2. arbitary value
  3. 612
  4. 100
Question 12 Multiple Choice (Single Answer)
  1. main() { float me=1.1; double you=1.1; if(me = = you) printf(“I love u”); else printf(“I hate you”); }
  1. I hate you
  2. I love your
  3. error
  4. will not compile
Question 13 Multiple Choice (Single Answer)

main() { printf(“\nab”); printf(“\bsi”); printf(“\rha”); }

  1. asiha
  2. hai
  3. aha
  4. siha
Question 14 Multiple Choice (Single Answer)

#define a 10 main() { #define a 50 printf(“%d”,a); }

  1. 50
  2. 10
  3. error
  4. none of these
Question 15 Multiple Choice (Single Answer)

main() { int i = 400, j = 300; printf(“%d %d”); } [in Turbo C complier]

  1. 400 300
  2. 300 400
  3. junk value
  4. error
Question 16 Multiple Choice (Single Answer)

1)main() { int i = 1, j = 2; switch(i) { case i: printf(“GOOD”); break; case j: printf(“BAD”); break; }; }

  1. GOOD
  2. BAD
  3. ERROR
  4. NONE OF THESE
Question 17 Multiple Choice (Single Answer)

1)#define f(g,g2) g# #g2 main() { int var12 = 100; printf(“%d”,f(var,12)); }

  1. junk value
  2. 100
  3. 12
  4. none of these
Question 18 Multiple Choice (Single Answer)

1)main() { int i = -1, j= -1, k=0, l=2, m; m=i++&&j++&&k++||l++; printf(“%d %d %d %d %d”,i,j,k,l,m); }

  1. -1 -1 0 2 0
  2. -1 -1 0 2 1
  3. 0 0 1 3 1
  4. 0 0 1 3 0
Question 19 Multiple Choice (Single Answer)

1)main() { int i = 0; for( ; i++ ; printf(“%d”,i)); printf(“%d”,i); }

  1. 0
  2. 1
  3. infinite loop
  4. 0 1
Question 20 Multiple Choice (Single Answer)

1)main() { printf(“%x”,-1<<4); }

  1. ffff
  2. fff0
  3. 0ff0
  4. 0fff