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.
Questions
Comments (Not remarks) should be in
- Upper case
- running text
- Any of above
- Not a part of standard.
While reading a SDF file, if AT END clause is skipped,
- program will abort
- command will fail but last line will remain populated in the file- variables
- command will fail and file-variables will be blank
- the program will give a compile time error
All subscripts should be defined as PIC ____?
- NUMERIC
- BINARY
- ALPHANUMERIC
- ANY OF THE ABOVE
Which of the following set of statements is correct as per standards?
- MOVE 1 TO A.
- MOVE 1 TO A
- Both of the above.
- None of the above
In the ENVIRONMENT DIVISION which paragrahs should a program (not a subroutine) have?
- ERROR RECOVERY
- ROLLBACK
- Any one of the above
- Both of the above
#define T t void main() { char T=’T’; printf(“\n%c\t%c\n”,T,t); }
- t t
- t T
- T t
- T T
- void main() { unsigned char a; a = 0XFF + 1; printf(“%d”,a); }
- 255
- 256
- 0
- 1
- void main() { int x=10; (x<0) ? (int a = 100) : (int a=1000); printf(“%d”,a); }
- 10
- 1000
- error
- none of this
main() { int *p1, i=25; void *p2; p1=&i; p2=&i; p1=p2; p2=p1; printf(“%d”,i); }
- error
- 25
- will not complie
- some memory address
- 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; }
- 11 21
- 13 24
- 10 20
- 12 23
- void abc(int a[]) { a++; a[1] = 612; } main() { char a[5]; abc(a); printf(“%d”,a[4]); }
- error
- arbitary value
- 612
- 100
- main() { float me=1.1; double you=1.1; if(me = = you) printf(“I love u”); else printf(“I hate you”); }
- I hate you
- I love your
- error
- will not compile
main() { printf(“\nab”); printf(“\bsi”); printf(“\rha”); }
- asiha
- hai
- aha
- siha
#define a 10 main() { #define a 50 printf(“%d”,a); }
- 50
- 10
- error
- none of these
main() { int i = 400, j = 300; printf(“%d %d”); } [in Turbo C complier]
- 400 300
- 300 400
- junk value
- error
1)main() { int i = 1, j = 2; switch(i) { case i: printf(“GOOD”); break; case j: printf(“BAD”); break; }; }
- GOOD
- BAD
- ERROR
- NONE OF THESE
1)#define f(g,g2) g# #g2 main() { int var12 = 100; printf(“%d”,f(var,12)); }
- junk value
- 100
- 12
- none of these
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 0 2 0
- -1 -1 0 2 1
- 0 0 1 3 1
- 0 0 1 3 0
1)main() { int i = 0; for( ; i++ ; printf(“%d”,i)); printf(“%d”,i); }
- 0
- 1
- infinite loop
- 0 1
1)main() { printf(“%x”,-1<<4); }
- ffff
- fff0
- 0ff0
- 0fff