0

programming languages Online Quiz - 142

Description: programming languages Online Quiz - 142
Number of Questions: 20
Created by:
Tags: programming languages
Attempted 0/20 Correct 0 Score 0

Comments (Not remarks) should be in

  1. Upper case

  2. running text

  3. Any of above

  4. Not a part of standard.


Correct Option: B

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


Correct Option: D

All subscripts should be defined as PIC ____?

  1. NUMERIC

  2. BINARY

  3. ALPHANUMERIC

  4. ANY OF THE ABOVE


Correct Option: B

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


Correct Option: B

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


Correct Option: D

#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


Correct Option: D

2) void main() { unsigned char a; a = 0XFF + 1; printf(“%d”,a); }

  1. 255

  2. 256

  3. 0

  4. 1


Correct Option: C

3) 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


Correct Option: C

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


Correct Option: B

5) 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


Correct Option: A

AI Explanation

To answer this question, we need to understand how the function swap works and what happens when it is called.

The function swap takes two integer references as parameters. It adds 2 to the first parameter and 3 to the second parameter.

In the given code, the main function initializes two variables a and b with values 10 and 20 respectively. Then, the swap function is called with the expressions a++ and b++ as arguments.

When the expression a++ is passed as an argument, the value of a is first used in the swap function and then incremented by 1. Similarly, the value of b is used and then incremented by 1.

Therefore, inside the swap function, x is 10 and y is 20. After adding 2 and 3 to x and y respectively, x becomes 12 and y becomes 23.

Finally, in the printf statement, the values of a and b are printed. Since a++ was passed as an argument to swap, a was incremented by 1 before being used in the printf statement. Therefore, the value of a is 11. The value of b is 21 because it was incremented by 1 in the same way.

Hence, the correct answer is:

Option A) 11 21

6) 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


Correct Option: D

7) 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


Correct Option: A

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

  1. asiha

  2. hai

  3. aha

  4. siha


Correct Option: B

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

  1. 50

  2. 10

  3. error

  4. none of these


Correct Option: A

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

  1. 400 300

  2. 300 400

  3. junk value

  4. error


Correct Option: A

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


Correct Option: C

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


Correct Option: B

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


Correct Option: C

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

  1. 0

  2. 1

  3. infinite loop

  4. 0 1


Correct Option: B

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

  1. ffff

  2. fff0

  3. 0ff0

  4. 0fff


Correct Option: B
- Hide questions