Sei sulla pagina 1di 28

1.

How many times "IndiaBIX" is get printed?

#include<stdio.h>
int main() { int x; for(x=-1; x<=10; x++) { if(x < 5) continue; else break; printf("IndiaBIX"); } return 0; } A. C. 2. Infinite times 0 times B. D. 11 times 10 times

How many times the while loop will get executed if a short int is 2 byte wide?

#include<stdio.h>
int main() { int j=1; while(j <= 255) { printf("%c %d\n", j, j); j++; } return 0; } A. C. 3. Infinite times 256 times B. D. 255 times 254 times

Which of the following is not logical operator? A. C. & || B. D. && !

4.

In mathematics and computer programming, which is the correct order of mathematical operators ? A. B. C. D. Addition, Subtraction, Multiplication, Division Division, Multiplication, Addition, Subtraction Multiplication, Addition, Division, Subtraction Addition, Division, Modulus, Subtraction

5.

Which of the following cannot be checked in a switch-case statement? A. C. Character Float B. D. Integer enum

1.

. What will be the output of the program?

#include<stdio.h>
int main() { int i=0; for(; i<=5; i++); printf("%d,", i); return 0; } A. 0, 1, 2, 3, 4, 5 B. 5

C. 2.

1, 2, 3, 4

D.

What will be the output of the program?

#include<stdio.h>
int main() { char str[]="C-program"; int a = 5; printf(a >10?"Ps\n":"%s\n", str); return 0; } A. C. 3. C-program Error B. D. Ps None of above

What will be the output of the program?

#include<stdio.h>
int main() { int a = 500, b = 100, c; if(!a >= 400) b = 300; c = 200; printf("b = %d c = %d\n", b, c); return 0; } A. C. 4. b = 300 c = 200 b = 300 c = garbage B. D. b = 100 c = garbage b = 100 c = 200

What will be the output of the program?

#include<stdio.h>
int main() { unsigned int i = 65535; /* Assume 2 byte integer*/ while(i++ != 0) printf("%d",++i); printf("\n"); return 0; } A. B. C. D. 5. Infinite loop 0 1 2 ... 65535 0 1 2 ... 32767 - 32766 -32765 -1 0 No output

. What will be the output of the program?

#include<stdio.h>
int main() { int x = 3; float y = 3.0; if(x == y) printf("x and y are equal"); else printf("x and y are not equal"); return 0; } A. x and y are equal B. x and y are not equal

C. 6.

Unpredictable

D.

No output

What will be the output of the program, if a short int is 2 bytes wide?

#include<stdio.h>
int main() { short int i = 0; for(i<=5 && i>=-1; ++i; i>0) printf("%u,", i); return 0; } A. C. 7. 1 ... 65535 No output B. D. Expression syntax error 0, 1, 2, 3, 4, 5

What will be the output of the program?

#include<stdio.h>
int main() { char ch; if(ch = printf("")) printf("It matters\n"); else printf("It doesn't matters\n"); return 0; } A. C. 8. It matters matters B. D. It doesn't matters No output

What will be the output of the program?

#include<stdio.h>
int main() { unsigned int i = 65536; /* Assume 2 byte integer*/ while(i != 0) printf("%d",++i); printf("\n"); return 0; } A. B. C. D. 9. Infinite loop 0 1 2 ... 65535 0 1 2 ... 32767 - 32766 -32765 -1 0 No output

What will be the output of the program?

#include<stdio.h>
int main() { float a = 0.7; if(0.7 > a) printf("Hi\n"); else printf("Hello\n"); return 0; } A. C. Hi Hi Hello B. D. Hello None of above

10. What will be the output of the program?

#include<stdio.h>
int main() { int a=0, b=1, c=3; *((a) ? &b : &a) = a ? b : c; printf("%d, %d, %d\n", a, b, c); return 0; } A. C. 0, 1, 3 3, 1, 3 B. D. 1, 2, 3 1, 3, 1

11. What will be the output of the program?

#include<stdio.h>
int main() { int k, num = 30; k = (num < 10) ? 100 : 200; printf("%d\n", num); return 0; } A. C. 200 100 B. D. 30 500

12. What will be the output of the program?

#include<stdio.h>
int main() { int a = 300, b, c; if(a >= 400) b = 300; c = 200; printf("%d, %d, %d\n", a, b, c); return 0; } A. C. 300, 300, 200 300, Garbage, 200 B. D. Garbage, 300, 200 300, 300, Garbage

13. What will be the output of the program?

#include<stdio.h>
int main() { int x=1, y=1; for(; y; printf("%d %d\n", x, y)) { y = x++ <= 5; } printf("\n"); return 0; } 2 3 4 5 6 7 2 3 4 5 1 1 1 1 1 0 1 1 1 1

A.

B.

2 3 4 5 6

1 1 1 1 1

C.

D.

2 3 4 5

2 3 4 5

14. What will be the output of the program?

#include<stdio.h>
int main() { int i = 5; while(i-- >= 0) printf("%d,", i); i = 5; printf("\n"); while(i-- >= 0) printf("%i,", i); while(i-- >= 0) printf("%d,", i); return 0; } 4, 3, 2, 1, 0, -1 4, 3, 2, 1, 0, -1 5, 4, 3, 2, 1, 0 5, 4, 3, 2, 1, 0 5, 4, 3, 2, 1, 0 5, 4, 3, 2, 1, 0 5, 4, 3, 2, 1, 0

A.

B.

C.

Error

D.

15. What will be the output of the program?

#include<stdio.h>
int main() { int i=3; switch(i) { case 1: printf("Hello\n"); case 2: printf("Hi\n"); case 3: continue; default: printf("Bye\n"); } return 0; } A. C. Error: Misplaced continue No output B. D. Bye Hello Hi

16. What will be the output of the program?

#include<stdio.h>
int main() { int x = 10, y = 20; if(!(!x) && x) printf("x = %d\n", x); else printf("y = %d\n", y); return 0; }

A. C.

y =20 x = 10

B. D.

x=0 x=1

17. What will be the output of the program?

#include<stdio.h>
int main() { int i=4; switch(i) { default: printf("This case 1: printf("This break; case 2: printf("This break; case 3: printf("This } return 0; } This is default This is case 1 This is case 1 This is case 3

is default\n"); is case 1\n");

is case 2\n");

is case 3\n");

A.

B.

This is case 3 This is default

C.

D.

This is default

18. What will be the output of the program?

#include<stdio.h>
int main() { int i = 1; switch(i) { printf("Hello\n"); case 1: printf("Hi\n"); break; case 2: printf("\nBye\n"); break; } return 0; } Hello Hi Hi Hello Bye Bye

A.

B.

C.

D.

19. What will be the output of the program?

#include<stdio.h>
int main() { char j=1; while(j < 5) { printf("%d, ", j); j = j+1; } printf("\n"); return 0; } A. B. C. D. 1 2 3 ... 127 1 2 3 ... 255 1 2 3 ... 127 128 0 1 2 3 ... infinite times 1, 2, 3, 4

20. What will be the output of the program?

#include<stdio.h>
int main() { int x, y, z; x=y=z=1; z = ++x || ++y && ++z; printf("x=%d, y=%d, z=%d\n", x, y, z); return 0; } A. C. x=2, y=1, z=1 x=2, y=2, z=2 B. D. x=2, y=2, z=1 x=1, y=2, z=1

1.

Point out the error, if any in the for loop.

#include<stdio.h>
int main() { int i=1; for(;;) { printf("%d\n", i++); if(i>10) break; } return 0; } A. B. C. D. 2. There should be a condition in the for loop The two semicolons should be dropped The for loop should be replaced with while loop. No error

View Answer Online Compiler Report Discuss in Forum Point out the error, if any in the program.

#include<stdio.h>
int main() { int a = 10; switch(a) { } printf("This is c program."); return 0; } A. B. C. D. 3. Error: No case statement specified Error: No default specified No Error Error: infinite loop occurs

View Answer Online Compiler Report Discuss in Forum Point out the error, if any in the program.

#include<stdio.h>
int main() { int i = 1; switch(i) { printf("This is c program."); case 1: printf("Case1"); break; case 2: printf("Case2"); break; } return 0; } A. B. C. D. 4. Error: No default specified Error: Invalid printf statement after switch statement No Error and prints "Case1" None of above

View Answer Online Compiler Report Discuss in Forum Point out the error, if any in the while loop.

#include<stdio.h>
int main() { int i=1; while() { printf("%d\n", i++); if(i>10) break; } return 0; } A. B. C. D. 5. There should be a condition in the while loop There should be at least a semicolon in the while The while loop should be replaced with for loop. No error

View Answer Online Compiler Report Discuss in Forum Which of the following errors would be reported by the compiler on compiling the program given below?

#include<stdio.h>
int main() { int a = 5; switch(a) { case 1: printf("First"); case 2: printf("Second"); case 3 + 2: printf("Third"); case 5: printf("Final"); break; } return 0; }

A. B. C. D. 6.

There is no break statement in each case. Expression as in case 3 + 2 is not allowed. Duplicate case case 5: No error will be reported.

View Answer Online Compiler Report Discuss in Forum Point out the error, if any in the program.

#include<stdio.h>
int main() { int P = 10; switch(P) { case 10: printf("Case 1"); case 20: printf("Case 2"); break; case P: printf("Case 2"); break; } return 0; } A. B. C. D. Error: No default value is specified Error: Constant expression required at line case P: Error: There is no break statement in each case. No error will be reported.

View Answer Online Compiler Report Discuss in Forum

7.

Point out the error, if any in the program.

#include<stdio.h>
int main() { int i = 1; switch(i) { case 1: printf("Case1"); break; case 1*2+4: printf("Case2"); break; } return 0; } A. B. C. D. 8. Error: in case 1*2+4 statement Error: No default specified Error: in switch statement No Error

Point out the error, if any in the while loop.

#include<stdio.h>
int main() {

void fun(); int i = 1; while(i <= 5) { printf("%d\n", i); if(i>2) goto here; } return 0; } void fun() { here: printf("It works"); } A. B. C. D. 9. No Error: prints "It works" Error: fun() cannot be accessed Error: goto cannot takeover control to other function No error

Point out the error, if any in the program.

#include<stdio.h>
int main() { int a = 10, b; a >=5 ? b=100: b=200; printf("%d\n", b); return 0; } A. C. 1. 100 Error: L value required for b B. D. 200 Garbage value

Which of the following statements are correct about the below program?

#include<stdio.h>
int main() { int i = 10, j = 20; if(i = 5) && if(j = 10) printf("Have a nice day"); return 0; } A. B. C. D. 2. Output: Have a nice day No output Error: Expression syntax Error: Undeclared identifier if

Which of the following statements are correct about the below program?

#include<stdio.h>
int main() { int i = 10, j = 15; if(i % 2 = j % 3) printf("IndiaBIX\n"); return 0; } A. C. 3. Error: Expression syntax Error: Rvalue required B. D. Error: Lvalue required The Code runs successfully

Which of the following statements are correct about the program?

10

#include<stdio.h>
int main() { int x = 30, y = 40; if(x == y) printf("x is equal to y\n"); else if(x > y) printf("x is greater than y\n"); else if(x < y) printf("x is less than y\n") return 0; } A. C. 4. Error: Statement missing Error: Lvalue required B. D. Error: Expression syntax Error: Rvalue required

Which of the following statements are correct about an if-else statements in a Cprogram? 1: Every if-else statement can be replaced by an equivalent statements using ? ; operators 2: Nested if-else statements are allowed. 3: Multiple statements in an if block are allowed. 4: Multiple statements in an else block are allowed. A. C. 1 and 2 1, 2 and 4 B. D. 2 and 3 2, 3, 4

5.

Which of the following statements are correct about the below program?

#include<stdio.h>
int main() { int i = 0; i++; if(i <= 5) { printf("IndiaBIX\n"); exit(0); main(); } return 0; } A. B. C. D. 6. The program prints 'IndiaBIX' 5 times The program prints 'IndiaBIX' one time The call to main() after exit() doesn't materialize. The compiler reports an error since main() cannot call itself.

Which of the following statements are correct about the below C-program?

#include<stdio.h>
int main() { int x = 10, y = 100%90, i; for(i=1; i<10; i++) if(x != y); printf("x = %d y = %d\n", x, y); return 0; } 1 : The printf() function is called 10 times. 2 : The program will produce the output x = 10 y = 10 3 : The ; after the if(x!=y) will NOT produce an error.

11

4 : The program will not produce output. A. C. 7. 1 3, 4 B. D. 2, 3 4

Which of the following sentences are correct about a for loop in a C program? 1: for loop works faster than a while loop. 2: All things that can be done using a for loop can also be done using a whileloop. 3: for(;;); implements an infinite loop. 4: for loop can be used if we want statements in a loop get executed at least once. A. C. 1 2, 3 B. D. 1, 2 2, 3, 4

8.

Which of the following statements are correct about the below program?

#include<stdio.h>
int main() { int n = 0, y = 1; y == 1 ? n=0 : n=1; if(n) printf("Yes\n"); else printf("No\n"); return 0; } A. B. C. D. 9. Error: Declaration terminated incorrectly Error: Syntax error Error: Lvalue required None of above

Which of the following sentences are correct about a switch loop in a C program? 1: switch is useful when we wish to check the value of variable against a particular set of values. 2: switch is useful when we wish to check whether a value falls in different ranges. 3: Compiler implements a jump table for cases used in switch. 4: It is not necessary to use a break in every switch statement. A. C. 1,2 2,4 B. D. 1,3,4 2

1.

A short integer is at least 16 bits wide and a long integer is at least 32 bits wide. A. True B. False

2.

If scanf() is used to store a value in a char variable then along with the value a carriage return(\r) also gets stored it. A. True B. False

3.

The modulus operator cannot be used with a long double. A. True B. False

4.

A char variable can store either an ASCII character or a Unicode character. A. True B. False

1.

View Answer Online Compiler Report Discuss in Forum The way the break is used to take control out of switch and continue to take control of the beginning of the switch? A. Yes B. No

12

2.

View Answer Online Compiler Report Discuss in Forum Can we use a switch statement to switch on strings? A. Yes B. No

3.

View Answer Online Compiler Report Discuss in Forum We want to test whether a value lies in the range 2 to 4 or 5 to 7. Can we do this using a switch? A. Yes B. No

4.

View Answer Online Compiler Report Discuss in Forum By default, the data type of a constant without a decimal point is int, whereas the one with a decimal point is a double. A. Yes B. No

1.

View Answer Online Compiler Report Discuss in Forum Which of the following statements should be used to obtain a remainder after dividing 3.14 by 2.1 ? A. B. C. D. rem = 3.14 % 2.1; rem = modf(3.14, 2.1); rem = fmod(3.14, 2.1); Remainder cannot be obtain in floating point division.

View Answer Online Compiler Report Discuss in Forum 2. What are the types of linkages? A. C. 3. Internal and External External and None B. D. External, Internal and None Internal

View Answer Online Compiler Report Discuss in Forum Which of the following special symbol allowed in a variable name? A. C. 4. * (asterisk) - (hyphen) B. D. | (pipeline) _ (underscore)

View Answer Online Compiler Report Discuss in Forum Is there any difference between following declarations? 1 : extern int fun(); 2 : int fun(); A. B. C. D. 5. Both are identical No difference, except extern int fun(); is probably in another file

int fun(); is overrided with extern int fun();


None of these

View Answer Online Compiler Report Discuss in Forum How would you round off a value from 1.66 to 2.0? A. C. 6. ceil(1.66) roundup(1.66) B. D. floor(1.66) roundto(1.66)

View Answer Online Compiler Report Discuss in Forum By default a real number is treated as a A. C. float long double B. D. double far double

View Answer Online Compiler Report Discuss in Forum 7. Which of the following is not user defined data type?

13

1:

struct book { char name[10]; float price; int pages; }; long int l = 2.35; enum day {Sun, Mon, Tue, Wed}; 1 3 B. D. 2 Both 1 and 2

2: 3:

A. C. 8.

View Answer Online Compiler Report Discuss in Forum Is the following statement a declaration or definition?

extern int i;
A. C. 9. Declaration Function B. D. Definition Error

View Answer Online Compiler Report Discuss in Forum Identify which of the following are declarations 1 : extern int x; 2 : float square ( float x ) { ... } 3 : double pow(double, double); A. C. 1 1 and 3 B. D. 2 3

View Answer Online Compiler Report Discuss in Forum 10. In the following program where is the variable a getting defined and where it is getting declared?

#include<stdio.h>
int main() { extern int a; printf("%d\n", a); return 0; } int a=20; A. B. C. D.

extern int a is declaration, int a = 20 is the definition int a = 20 is declaration, extern int a is the definition int a = 20 is definition, a is not defined a is declared, a is not defined

View Answer Online Compiler Report Discuss in Forum When we mention the prototype of a function? A. C. 1. Defining Prototyping B. D. Declaring Calling

View Answer Online Compiler Report Discuss in Forum What are the different types of real data type in C ? A. C. float, double float, double, long double B. D. short int, double, long int double, long int, float

2.

View Answer Online Compiler Report Discuss in Forum What will you do to treat the constant 3.14 as a long double?

14

A. C. 3.

use 3.14LD use 3.14DL

B. D.

use 3.14L use 3.14LF

View Answer Online Compiler Report Discuss in Forum If the binary eauivalent of 5.375 in normalised form is 0100 0000 1010 1100 0000 0000 0000 0000, what will be the output of the program (on intel machine)?

#include<stdio.h> #include<math.h>
int main() { float a=5.375; char *p; int i; p = (char*)&a; for(i=0; i<=3; i++) printf("%02x\n", (unsigned char)p[i]); return 0; } A. C. 4. 40 AC 00 00 00 00 AC 40 B. D. 04 CA 00 00 00 00 CA 04

View Answer Online Compiler Report Discuss in Forum Which of the following range is a valid long double ? A. C. 3.4E-4932 to 1.1E+4932 1.1E-4932 to 1.1E+4932 B. D. 3.4E-4932 to 3.4E+4932 1.7E-4932 to 1.7E+4932

5.

View Answer Online Compiler Report Discuss in Forum Which statement will you add in the following program to work it correctly?

#include<stdio.h>
int main() { printf("%f\n", log(36.0)); return 0; } A. C. 6. #include<conio.h> #include<stdlib.h> B. D. #include<math.h> #include<dos.h>

View Answer Online Compiler Report Discuss in Forum We want to round off x, a float, to an int value, The correct way to do is A. C. y = (int)(x + 0.5) y = (int)x + 0.5 B. D. y = int(x + 0.5) y = (int)((int)x + 0.5)

7.

View Answer Online Compiler Report Discuss in Forum The binary equivalent of 5.375 is A. C. 101.101110111 101011 B. D. 101.011 None of above

8.

View Answer Online Compiler Report Discuss in Forum A float occupies 4 bytes. If the hexadecimal equivalent of these 4 bytes are A, B, C and D, then when this float is stored in memory in which of the following order do these bytes gets stored? A. B. C. D. ABCD DCBA 0xABCD Depends on big endian or little endian architecture

View Answer Online Compiler Report Discuss in Forum

15

9.

What will you do to treat the constant 3.14 as a float? A. C. use float(3.14f) use f(3.14) B. D. use 3.14f use (f)(3.14)

View Answer Online Compiler Report Discuss in Forum 10. Which of the following statement obtains the remainder on dividing 5.5 by 1.3 ? A. C. 1. rem = (5.5 % 1.3) rem = fmod(5.5, 1.3) B. D. rem = modf(5.5, 1.3) Error: we can't divide

View Answer Online Compiler Report Discuss in Forum What will be the output of the program?

#include<stdio.h>
int main() { float a=0.7; if(a < 0.7) printf("C\n"); else printf("C++\n"); return 0; } A. C. 2. C Compiler error B. D. C++ Non of above

View Answer Online Compiler Report Discuss in Forum What will be the output of the program?

#include<stdio.h>
int main() { float *p; printf("%d\n", sizeof(p)); return 0; } A. B. C. D. 3. 2 in 16bit compiler, 4 in 32bit compiler 4 in 16bit compiler, 2 in 32bit compiler 4 in 16bit compiler, 4 in 32bit compiler 2 in 16bit compiler, 2 in 32bit compiler

View Answer Online Compiler Report Discuss in Forum What will be the output of the program?

#include<stdio.h>
int main() { float fval=7.29; printf("%d\n", (int)fval); return 0; } A. C. 4. 0 7.0 B. D. 0.0 7

View Answer Online Compiler Report Discuss in Forum What will be the output of the program?

#include<stdio.h> #include<math.h>
int main() { printf("%f\n", sqrt(36.0));

16

return 0; } A. C. 5. 6.0 6.000000 B. D. 6 Error: Prototype sqrt() not found.

View Answer Online Compiler Report Discuss in Forum What will be the output of the program?

#include<stdio.h> #include<math.h>
int main() { printf("%d, %d, %d\n", sizeof(3.14f), sizeof(3.14), sizeof(3.14l)); return 0; } A. C. 6. 4, 4, 4 4, 8, 10 B. D. 4, 8, 8 4, 8, 12

View Answer Online Compiler Report Discuss in Forum What will be the output of the program?

#include<stdio.h>
int main() { float f=43.20; printf("%e, ", f); printf("%f, ", f); printf("%g", f); return 0; } A. C. 7. 4.320000e+01, 43.200001, 43.2 4.3e, 43.20f, 43.00 B. D. 4.3, 43.22, 43.21 Error

View Answer Online Compiler Report Discuss in Forum What will be the output of the program?

#include<stdio.h>
int main() { float a=0.7; if(a < 0.7f) printf("C\n"); else printf("C++\n"); return 0; } A. C. 8. C Compiler error B. D. C++ Non of above

View Answer Online Compiler Report Discuss in Forum What will be the output of the program?

#include<stdio.h> #include<math.h>
int main() { float n=1.54; printf("%f, %f\n", ceil(n), floor(n)); return 0; } A. C. 2.000000, 1.000000 1.550000, 2.000000 B. D. 1.500000, 1.500000 1.000000, 2.000000

View Answer Online Compiler Report Discuss in Forum

17

9.

What will be the output of the program?

#include<stdio.h>
int main() { float d=2.25; printf("%e,", printf("%f,", printf("%g,", printf("%lf", return 0; } A. B. C. D. 1.

d); d); d); d);

2.2, 2.50, 2.50, 2.5 2.2e, 2.25f, 2.00, 2.25 2.250000e+000, 2.250000, 2.25, 2.250000 Error

View Answer Online Compiler Report Discuss in Forum In which numbering system can the binary number 1011011111000101 be easily converted to? A. C. Decimal system Octal system B. D. Hexadecimal system No need to convert

View Answer Online Compiler Report Discuss in Forum 2. Which bitwise operator is suitable for turning off a particular bit in a number? A. C. 3. && operator || operator B. D. & operator ! operator

View Answer Online Compiler Report Discuss in Forum Which bitwise operator is suitable for turning on a particular bit in a number? A. C. 4. && operator || operator B. D. & operator | operator

View Answer Online Compiler Report Discuss in Forum Which bitwise operator is suitable for checking whether a particular bit is on or off? A. C. 1. && operator || operator B. D. & operator ! operator

View Answer Online Compiler Report Discuss in Forum Assunming, integer is 2 byte, What will be the output of the program?

#include<stdio.h>
int main() { printf("%x\n", -1>>1); return 0; } A. C. 2. ffff 0000 B. D. 0fff fff0

View Answer Online Compiler Report Discuss in Forum If an unsigned int is 2 bytes wide then, What will be the output of the program ?

#include<stdio.h>
int main() { unsigned int m = 32; printf("%x\n", ~m);

18

return 0; } A. C. 3. ffff ffdf B. D. 0000 ddfd

View Answer Online Compiler Report Discuss in Forum Assuming a integer 2-bytes, What will be the output of the program?

#include<stdio.h>
int main() { printf("%x\n", -1<<3); return 0; } A. C. 4. ffff 0 B. D. fff8 -1

View Answer Online Compiler Report Discuss in Forum If an unsigned int is 2 bytes wide then, What will be the output of the program ?

#include<stdio.h>
int main() { unsigned int a=0xffff; ~a; printf("%x\n", a); return 0; } A. C. 5. ffff 00ff B. D. 0000 ddfd

View Answer Online Compiler Report Discuss in Forum What will be the output of the program?

#include<stdio.h>
int main() { unsigned char i = 0x80; printf("%d\n", i<<1); return 0; } A. C. 6. 0 100 B. D. 256 80

View Answer Online Compiler Report Discuss in Forum What will be the output of the program?

#include<stdio.h>
int main() { printf("%d >> %d %d >> %d\n", 4 >> 1, 8 >> 1); return 0; } A. B. C. 4181 4 >> 1 8 >> 1 2 >> 4 Garbage value >> Garbage value

19

D. 7.

24

View Answer Online Compiler Report Discuss in Forum What will be the output of the program?

#include<stdio.h>
int main() { char c=48; int i, mask=01; for(i=1; i<=5; i++) { printf("%c", c|mask); mask = mask<<1; } return 0; } A. C. 8. 12400 12500 B. D. 12480 12556

View Answer Online Compiler Report Discuss in Forum What will be the output of the program?

#define P printf("%d\n", -1^~0); #define M(P) int main()\


{\ P\ return 0;\ } M(P) A. C. 9. 1 -1 B. D. 0 2

View Answer Online Compiler Report Discuss in Forum What will be the output of the program ?

#include<stdio.h>
int main() { int i=32, j=0x20, k, l, m; k=i|j; l=i&j; m=k^l; printf("%d, %d, %d, %d, %d\n", i, j, k, l, m); return 0; } A. C. 0, 0, 0, 0, 0 32, 32, 32, 32, 0 B. D. 0, 32, 32, 32, 32 32, 32, 32, 32, 32

View Answer Online Compiler Report Discuss in Forum 10. What will be the output of the program?

#include<stdio.h>
int main() { printf("%d printf("%d printf("%d printf("%d return 0; } A.

%d\n", %d\n", %d\n", %d\n",

32<<1, 32<<0); 32<<-1, 32<<-0); 32>>1, 32>>0); 32>>-1, 32>>-0);

Garbage values

B.

64 32 0 32 16 32

20

0 32 80 00 32 0 0 16

C.

All zeros

D.

View Answer Online Compiler Report Discuss in Forum 11. What will be the output of the program?

#include<stdio.h>
int main() { unsigned int res; res = (64 >>(2+1-2)) & (~(1<<2)); printf("%d\n", res); return 0; } A. C. 32 0 B. D. 64 128

View Answer Online Compiler Report Discuss in Forum 12. What will be the output of the program ?

#include<stdio.h>
int main() { int i=4, j=8; printf("%d, %d, %d\n", i|j&j|i, i|j&&j|i, i^j); return 0; } A. C. 1. 4, 8, 0 12, 1, 12 B. D. 1, 2, 1 0, 0, 0

View Answer Online Compiler Report Discuss in Forum Which of the following statements are correct about the program?

#include<stdio.h>
int main() { unsigned int num; int i; scanf("%u", &num); for(i=0; i<16; i++) { printf("%d", (num<<i & 1<<15)?1:0); } return 0; } A. B. C. D. 2. It prints all even bits from num It prints all odd bits from num It prints binary equivalent num Error

View Answer Online Compiler Report Discuss in Forum Which of the following statements are correct about the program?

#include<stdio.h>
int main() { unsigned int num;

21

int c=0; scanf("%u", &num); for(;num;num>>=1) { if(num & 1) c++; } printf("%d", c); return 0; } A. B. C. D. 3. It counts the number of bits that are ON (1) in the number num. It counts the number of bits that are OFF (0) in the number num. It sets all bits in the number num to 1 Error

View Answer Online Compiler Report Discuss in Forum Which of the following statements are correct about the program?

#include<stdio.h>
char *fun(unsigned int num, int base); int main() { char *s; s=fun(128, 2); s=fun(128, 16); printf("%s\n",s); return 0; } char *fun(unsigned int num, int base) { static char buff[33]; char *ptr = &buff[sizeof(buff)-1]; *ptr = '\0'; do { *--ptr = "0123456789abcdef"[num %base]; num /=base; }while(num!=0); return ptr; } A. B. C. D. 4. It converts a number to a given base. It converts a number to its equivalent binary. It converts a number to its equivalent hexadecimal. It converts a number to its equivalent octal.

View Answer Online Compiler Report Discuss in Forum Which of the following statements are correct about the program?

#include<stdio.h>
int main() { unsigned int m[] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80}; unsigned char n, i; scanf("%d", &n); for(i=0; i<=7; i++) { if(n & m[i]) printf("yes"); } return 0; } A. B. It will put OFF all bits that are ON in the number n It will test whether the individual bits of n are ON or OFF

22

C. D. 1.

It will put ON all bits that are OFF in the number n It will report compilation errors in the if statement.

View Answer Online Compiler Report Discuss in Forum Left shifting a number by 1 is always equivalent to multiplying it by 2. A. True B. False

2.

View Answer Online Compiler Report Discuss in Forum In the statement expression1 >> expression2. if expression1 is a signed integer with its leftmost bit set to 1 then on right shifting it the result of the statement will vary from computer to computer A. True B. False

View Answer Online Compiler Report Discuss in Forum 3. Bitwise & and | are unary operators A. 4. True B. False

View Answer Online Compiler Report Discuss in Forum Bitwise & can be used to check if more than one bit in a number is on. A. True B. False

View Answer Online Compiler Report Discuss in Forum 5. Bitwise & can be used to check if a bit in number is set or not. A. 6. True B. False

View Answer Online Compiler Report Discuss in Forum Bitwise & can be used to divide a number by powers of 2 A. True B. False

7.

View Answer Online Compiler Report Discuss in Forum Left shifting an unsigned int or char by 1 is always equivalent to multiplying it by 2. A. True B. False

View Answer Online Compiler Report Discuss in Forum 8. On left shifting, the bits from the left are rotated and brought to the right and accommodated where there is empty space on the right? A. 1. True B. False

View Answer Online Compiler Report Discuss in Forum Bitwise & can be used in conjunction with ~ operator to turn off 1 or more bits in a number. A. Yes B. No

2.

View Answer Online Compiler Report Discuss in Forum Bitwise can be used to reverse a sign of a number. A. Yes B. No

View Answer Online Compiler Report Discuss in Forum 3. Bitwise can be used to generate a random number. A. 4. Yes B. No

View Answer Online Compiler Report Discuss in Forum Bitwise | can be used to multiply a number by powers of 2. A. Yes B. No

View Answer Online Compiler Report Discuss in Forum 5. Bitwise | can be used to set multiple bits in number. A. 6. Yes B. No

View Answer Online Compiler Report Discuss in Forum Bitwise can be used to perform addition and subtraction. A. Yes B. No

View Answer Online Compiler Report Discuss in Forum 7. Bitwise | can be used to set a bit in number. A. Yes B. No

23

1.

View Answer Online Compiler Report Discuss in Forum Which of the following is the correct order of evaluation for the below expression?

z = x + y * z / 4 % 2 - 1
A. C. 2. */%+-= /*%-+= B. D. =*/%+*%/-+=

View Answer Online Compiler Report Discuss in Forum Which of the following correctly shows the hierarchy of arithmetic operations in C? A. C. /+*+-/* B. D. *-/+ /*+-

3.

View Answer Online Compiler Report Discuss in Forum Which of the following is the correct usage of conditional operators used in C? A. C. a>b ? c=30 : c=40; max = a>b ? a>c?a:c:b>c?b:c B. D. a>b ? c=30; return (a>b)?(a:b)

4.

View Answer Online Compiler Report Discuss in Forum Which of the following is the correct order if calling functions in the below code?

a = f1(23, 14) * f2(12/4) + f3();


A. B. C. D. 5. f1, f2, f3 f3, f2, f1 Order may vary from compiler to compiler None of above

View Answer Online Compiler Report Discuss in Forum Which of the following are unary operators in C? 1. ! 2. sizeof 3. ~ 4. && A. C. 1, 2 2, 4 B. D. 1, 3 1, 2, 3

View Answer Online Compiler Report Discuss in Forum In which order do the following gets evaluated 1. Relational 2. Arithmetic 3. Logical 4. Assignment A. C. 2134 4321 B. D. 1234 3214

View Answer Online Compiler Report Discuss in Forum 1. What will be the output of the program?

#include<stdio.h>
int main() { int i=-3, j=2, k=0, m; m = ++i && ++j && ++k; printf("%d, %d, %d, %d\n", i, j, k, m); return 0; } A. -2, 3, 1, 1 B. 2, 3, 1, 2

24

C. 2.

1, 2, 3, 1

D.

3, 3, 1, 2

View Answer Online Compiler Report Discuss in Forum Assunming, integer is 2 byte, What will be the output of the program?

#include<stdio.h>
int main() { printf("%x\n", -2<<2); return 0; } A. C. 3. ffff fff8 B. D. 0 Error

View Answer Online Compiler Report Discuss in Forum What will be the output of the program?

#include<stdio.h>
int main() { int i=-3, j=2, k=0, m; m = ++i || ++j && ++k; printf("%d, %d, %d, %d\n", i, j, k, m); return 0; } A. C. 4. 2, 2, 0, 1 -2, 2, 0, 0 B. D. 1, 2, 1, 0 -2, 2, 0, 1

View Answer Online Compiler Report Discuss in Forum What will be the output of the program?

#include<stdio.h>
int main() { int x=12, y=7, z; z = x!=4 || y == 2; printf("z=%d\n", z); return 0; } A. C. 5. z=0 z=4 B. D. z=1 z=2

View Answer Online Compiler Report Discuss in Forum What will be the output of the program?

#include<stdio.h>
int main() { static int a[20]; int i = 0; a[i] = i ; printf("%d, %d, %d\n", a[0], a[1], i); return 0; } A. C. 6. 1, 0, 1 0, 0, 0 B. D. 1, 1, 1 0, 1, 0

View Answer Online Compiler Report Discuss in Forum What will be the output of the program?

#include<stdio.h>
int main() { int i=4, j=-1, k=0, w, x, y, z;

25

w = i || j || k; x = i && j && k; y = i || j &&k; z = i && j || k; printf("%d, %d, %d, %d\n", w, x, y, z); return 0; } A. C. 7. 1, 1, 1, 1 1, 0, 0, 1 B. D. 1, 1, 0, 1 1, 0, 1, 1

View Answer Online Compiler Report Discuss in Forum What will be the output of the program?

#include<stdio.h>
int main() { int i=-3, j=2, k=0, m; m = ++i && ++j || ++k; printf("%d, %d, %d, %d\n", i, j, k, m); return 0; } A. C. 8. 1, 2, 0, 1 -2, 3, 0, 1 B. D. -3, 2, 0, 1 2, 3, 1, 1

View Answer Online Compiler Report Discuss in Forum What will be the output of the program?

#include<stdio.h>
int main() { int x=4, y, z; y = --x; z = x--; printf("%d, %d, %d\n", x, y, z); return 0; } A. C. 9. 4, 3, 3 3, 3, 2 B. D. 4, 3, 2 2, 3, 3

View Answer Online Compiler Report Discuss in Forum What will be the output of the program?

#include<stdio.h>
int main() { int i=3; i = i++; printf("%d\n", i); return 0; } A. C. 3 5 B. D. 4 6

View Answer Online Compiler Report Discuss in Forum 10. What will be the output of the program?

#include<stdio.h>
int main() { int a=100, b=200, c; c = (a == 100 || b > 200); printf("c=%d\n", c); return 0; } A. c=100 B. c=200

26

C.

c=1

D.

c=300

View Answer Online Compiler Report Discuss in Forum 11. What will be the output of the program?

#include<stdio.h>
int main() { int x=55; printf("%d, %d, %d\n", x<=55, x=40, x>=10); return 0; } A. C. 1, 40, 1 1, 55, 0 B. D. 1, 55, 1 1, 1, 1

View Answer Online Compiler Report Discuss in Forum 12. What will be the output of the program?

#include<stdio.h>
int main() { int i=2; printf("%d, %d\n", ++i, ++i); return 0; } A. B. C. D. 3, 4 4, 3 4, 4 Output may vary from compiler to compiler

View Answer Online Compiler Report Discuss in Forum 13. What will be the output of the program?

#include<stdio.h>
int main() { int k, num=30; k = (num>5 ? (num <=10 ? 100 : 200): 500); printf("%d\n", num); return 0; } A. C. 200 100 B. D. 30 500

View Answer Online Compiler Report Discuss in Forum 14. What will be the output of the program?

#include<stdio.h>
int main() { char ch; ch = 'A'; printf("The letter is"); printf("%c", ch >= 'A' && ch <= 'Z' ? ch + 'a' - 'A':ch); printf("Now the letter is"); printf("%c\n", ch >= 'A' && ch <= 'Z' ? ch : ch + 'a' - 'A'); return 0; } The letter is a Now the letter is A Error The letter is A Now the letter is a None of above

A.

B.

C.

D.

View Answer Online Compiler Report Discuss in Forum

27

15. What will be the output of the program?

#include<stdio.h>
int main() { int i=2; int j = i + (1, 2, 3, 4, 5); printf("%d\n", j); return 0; } A. C. 1. 4 6 B. D. 7 5

View Answer Online Compiler Report Discuss in Forum Associativity has no role to play unless the precedence of operator is same. A. True B. False

2.

View Answer Online Compiler Report Discuss in Forum The expression of the right hand side of || operators doesn't get evaluated if the left hand side determines the outcome. A. True B. False

3.

View Answer Online Compiler Report Discuss in Forum In the expression a=b=5 the order of Assignment is NOT decided by Associativity of operators A. True B. False

View Answer Online Compiler Report Discuss in Forum 4. Associativity of an operator is either Left to Right or Right to Left. A. 1. True B. False

View Answer Online Compiler Report Discuss in Forum Are the following two statement same? 1. a <= 20 ? b = 30: c = 30; 2. (a <=20) ? b : c = 30; A. Yes B. No

View Answer Online Compiler Report Discuss in Forum 2. Two different operators would always have different Associativity. A. 3. Yes B. No

View Answer Online Compiler Report Discuss in Forum Will the expression *p = p be disallowed by the compiler? A. Yes B. No

View Answer Online Compiler Report Discuss in Forum 4. Every operator has an Associativity A. Yes B. No

View Answer Online Compiler Report Discuss in Forum

28

Potrebbero piacerti anche