0% found this document useful (0 votes)
25 views39 pages

C Objective

objective question for c

Uploaded by

bhavani.kanwar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views39 pages

C Objective

objective question for c

Uploaded by

bhavani.kanwar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

11.

If integer needs two bytes of storage, then maximum value


of an unsigned integer is

A. 216 – 1
B. 215 – 1
C. 216
D. 215

E. None of these

Answer: Option A
Solution:
An integer is a number with no fractional part; it can be positive, negative or zero. In ordinary usage,
one uses a minus sign to designate a negative integer. However, a computer can only store
information in bits, which can only have the values zero or one. We might expect, therefore, that the
storage of negative integers in a computer might require some special technique. As you might
imagine, an unsigned integer is either positive or zero. Consider a single digit decimal number: In a
single decimal digit, you can write a number between 0 and 9. In two decimal digits, you can write a
number between 0 and 99, and so on. Since nine is equivalent to 101 - 1, 99 is equivalent to 102 - 1,
etc. In n decimal digits, you can write a number between 0 and 10 n - 1. So, analogously, in the binary
number system, An unsigned integer containing n bits can have a value between 0 and 2 n - 1 (which
is 2n different values).
[Link] is the correct value to return to the operating system
upon the successful completion of a program?

A. 1

B. -1

C. 0

D. Program do no return a value.

E. 2
Answer: Option C

[Link] is the only function all C programs must contain?

A. start()

B. system()

C. main()

D. printf()

E. getch()

Answer: Option C

[Link] of the following is not a correct variable type?

A. float

B. real

C. int

D. double

E. char
Answer: Option B

[Link] number would be shown on the screen after the


following statements of C are executed?

char ch;
int i;
ch = 'G';
i = ch-'A';
printf("%d", i);

A. 5

B. 6

C. 7

D. 8

E. 9

Answer: Option B
Solution:Since the ASCII value of G is 71 and the garbage value if A is 65 and hence the
difference is 6.

[Link] of following is not a valid name for a C variable?

A. Examveda

B. Exam_veda

C. Exam veda
D. Both A and B

E. None of these

Answer: Option C
Solution:
No spaces are allowed in the variable names.

[Link] the output of the following program. void main()


{ int i=01289; printf("%d", i); }

A. 0289

B. 1289

C. 713

D. 0713

E. Syntax error

Answer: Option E
Solution:
The prefix 0 in an integer value indicates octal value. In octal value use of 8 and 9 is not
allowed and hence the error.

[Link] the output of the following program.

void main()
{
int i=065, j=65;
printf("%d %d", i, j);
}

A. 53 65

B. 65 65

C. 065 65

D. 053 65

E. Syntax error

Answer: Option A
Solution:
As octal 65 ( 065 ) is equivalent of decimal value 53.

[Link] ASCII value of 'x' is 120, then what is the value of the H,
if
H = ('x' – 'w' ) / 3;

A. 1

B. 2

C. 3

D. 4

E. 0
Answer: Option E
Solution:
Because 'x'-'w' = 120-119. And hence 1/3 results in 0(integer division)

[Link] is the difference between a declaration and a


definition of a variable?

A. Both can occur multiple times, but a declaration must occur first.

B. A definition occurs once, but a declaration may occur many times.

C. Both can occur multiple times, but a definition must occur first.

D. A declaration occurs once, but a definition may occur many times.

E. There is no difference between them

Answer: Option D

21."My salary was increased by 15%" Select the statement,


which will EXACTLY reproduce the line of text above.

A. printf("My salary was increased by 15/%!");

B. printf("My salary was increased by 15%!");

C. printf("My salary was increased by 15'%'!");

D. printf("My salary was increased by 15%%!");


Answer: Option D

22.

short testarray[4][3] = { {1}, {2,3}, {4,5,6}};


printf("%d", sizeof(testarray));

Assuming a short is two bytes long, what will be printed by


the above code?

A. 6

B. 7

C. 12

D. 24

E. It will not compile because not enough initializers are given

Answer: Option D
Solution:
The following table provides the details of standard integer types with their storage sizes
and value ranges −
Type Storage size Value range
char 1 byte -128 to 127 or 0 to 255
unsigned char 1 byte 0 to 255
signed char 1 byte -128 to 127
int 2 or 4 bytes -32,768 to 32,767 or -2,147,483,648 to 2,147,483,647
unsigned int 2 or 4 bytes 0 to 65,535 or 0 to 4,294,967,295
short 2 bytes -32,768 to 32,767
unsigned short2 bytes 0 to 65,535
long 4 bytes -2,147,483,648 to 2,147,483,647
unsigned long 4 bytes 0 to 4,294,967,295
23. Property which allows to produce different executable for different platforms in C is
called?

 A. File inclusion

 B. Selective inclusion

 C. Conditional compilation

 D. Recursive macros

 Answer: Option C
 Explanation:
 Conditional compilation is the preprocessor facility to produce different executable.

24. #include is called

 A. Preprocessor directive

 B. Inclusion directive

 C. File inclusion directive

 D. None of the mentioned

 Answer: Option A
 Explanation:
 None.
25. C preprocessors can have compiler specific features.

 A. true

 B. false

 C. Depends on the standard

 D. Depends on the platform

 Answer: Option A
 Explanation:
 #pragma is compiler specific feature.
26. C preprocessor is conceptually the first step during compilation.

 A. true

 B. false

 C. Depends on the compiler


 D. Depends on the standard

 Answer: Option A
27. Preprocessor feature that supply line numbers and file names to compiler is called?

 A. Selective inclusion

 B. macro substitution

 C. Concatenation

 D. Line control
Answer: Option D

28 What is the output of this C code?

int main()
{
enum {ORANGE = 12, MANGO, BANANA = 11, APPLE};
printf("APPLE = %d\n", APPLE);
}

 A. APPLE= 11

 B. APPLE= 12

 C. APPLE= 23

 D. APPLE= 0

 Answer: Option B
 Explanation:
 In enum, the value of constant is defined to the recent assignment from left.
[Link] is the output of this C code?

int main()
{
printf("C programming %s", "Class by\n%s AllIndiaExams", "SUPER");
}

 A. C programming Class by SUPER AllIndiaExams

 B. C programming Class by\n%s AllIndiaExams

 C. C programming Class by %s AllIndiaExams

 D. Compilation error
 Answer: Option C
 Explanation:
 This program has only one %s within first double quotes, so it does not read the string
“SUPER”.
The %s along with the AllIndiaExams is not read as a format modifier while new line
character prints the new line.

[Link] is the output of this C code?

#define a 20
int main()
{
const int a = 50;
printf("a = %d\n", a);
}

 A. a = 50

 B. a = 20

 C. Run time error

 D. Compilation Error

Answer: Option D
Explanation:
The #define substitutes a with 20 leaving no identifier and hence compilation error.
Complilation Error: expected identifier or ‘(’ before numeric constant

[Link] is the output of this C code?

int main()
{
int var = 010;
printf("%d", var);
}

 A. 2

 B. 8

 C. 9
 D. 10

 Answer: Option B
 Explanation:
 010 is octal representation of 8.

32. enum types are processed by?

 A. Compiler

 B. Preprocessor

 C. Linker

 D. Assembler
 Answer: Option A

33. What is the output of this C code?

int main()
{
const int a;
a = 32;
printf("a is %d", a);
return 0;
}

 A. a is 32

 B. Compile time error

 C. Run time error

 D. none

 Answer: Option B
 Explanation:
 Since the constant variable has to be declared and defined at the same time, not doing it
results in an error.

34. Which is false?


 A. Constant variables need not be defined as they are declared and can be defined later

 B. Global constant variables are initialised to zero

 C. const keyword is used to define constant values

 D. You cannot reassign a value to a constant variable

 Answer: Option A
 Explanation:
 Since the constant variable has to be declared and defined at the same time, not doing it
results in an error.
Hence the statement a is false.

[Link] is the output of this C code?

void main()
{
int const k = 11;
k++;
printf("k is %d", k);
}

 A. k is 12

 B. Error because const and int are used together

 C. garbage value

 D. Error, because a constant variable cannot be changed

 Answer: Option D
 Explanation:
 Constant variable has to be declared and defined at the same time. Trying to change it later
results in error.
36. Comment on the output of this C code?

int const print()


{
printf("[Link]");
return 0;
}
void main()
{
print();
}

 A. [Link] is printed infinite number of times

 B. [Link]

 C. Runtime Error

 D. complilation error
Answer: Option B

37. The format identifier ‘%i’ is also used for _____ data type?

 A. char

 B. int

 C. float

 D. double

 Answer: Option B
 Explanation:
 Both %d and %i can be used as a format identifier for int data type.
38. Which data type is most suitable for storing a number 65000 in a 32-bit system?

 A. short

 B. int

 C. long

 D. double

 Answer: Option A
 Explanation:
 65000 comes in the range of short (16-bit) which occupies the least memory.

39. Which of the following is a User-defined data type?

 A. typedef int Boolean;

 B. typedef enum {Mon, Tue, Wed, Thu, Fri} Workdays;

 C. struct {char name[10], int age};

 D. All of the mentioned


 Answer: Option D
 Explanation:
 typedef and struct are used to define user-defined data types.

[Link] is the size of an int data type?

 A. 4 Bytes

 B. 8 Bytes

 C. Depends on the system/compiler

 D. Cannot be determined

 Answer: Option C
 Explanation:
 The size of the data types depend on the system.

41. What is the output of this C code?

int main()
{
char chr;
chr = 128;
printf("%d\n", chr);
return 0;
}

 A. 128

 B. -128

 C. Depends on the compiler

 D. None of the mentioned

 Answer: Option B
 Explanation:
 signed char will be a negative number.
Output:
$ cc pgm2.c
$ [Link]
-128

42. What is short int in C programming?

 A. Basic datatype of C

 B. Qualifier

 C. short is the qualifier and int is the basic datatype

 D. All of the mentioned


 Answer: Option C

43. What is the output of this C code (on a 32-bit machine)?

int main()
{
int x = 10000;
double y = 56;
int *p = &x;
double *q = &y;
printf("p and q are %d and %d", sizeof(p), sizeof(q));
return 0;
}

 A. p and q are 4 and 4

 B. p and q are 4 and 8

 C. Compiler error

 D. p and q are 2 and 8

 Answer: Option A
 Explanation:
 Size of any type of pointer is 4 on a 32-bit machine.
Output:
$ cc pgm6.c
$ [Link]
p and q are 4 and 4

44. Which is correct with respect to size of the datatypes?

 A. char > int > float


 B. int > char > float

 C. char < int < double

 D. double > char > int

 Answer: Option C
 Explanation:
 char has lesser bytes than int and int has lesser bytes than double in any system

45. Which of the datatypes have size that is variable?

 A. int

 B. struct

 C. float

 D. double

 Answer: Option B
 Explanation:
 Since the size of the structure depends on its fields, it has a variable size.

46. What is the output of this C code?

int main()
{
float x = 'a';
printf("%f", x);
return 0;
}

 A. a

 B. run time error

 C. a.0000000

 D. 97.000000

 Answer: Option D
 Explanation:
 Since the ASCII value of a is 97, the same is assigned to the float variable and printed.
Output:
$ cc pgm8.c
$ [Link]
97.000000
47. What is the output of this C code?

int main()
{
int i = -5;
int k = i %4;
printf("%d\n", k);
}

 A. Compile time error

 B. -1

 C. 1

 D. None
Answer: Option B

48. What is the output of this C code?

int main()
{
int i = 5;
int l = i / -4;
int k = i % -4;
printf("%d %d\n", l, k);
return 0;
}

 A. Compile time error

 B. -1 1

 C. 1 -1

 D. Run time error


Answer: Option B

49. What is the output of this C code?

int main()
{
int i = 7;
i = i / 4;
printf("%d\n", i);
return 0;
}

 A. Run time error

 B. 1

 C. 3

 D. Compile time error


Answer: Option B

50. What is the value of x in this C code?

void main()
{
int x = 4 *5 / 2 + 9;
}

 A. 6.75

 B. 1.85

 C. 19

 D. 3
Answer: Option C

51. What is the output of this C code?

void main()
{
int x = 4.3 % 2;
printf("Value of x is %d", x);
}

 A. Value of x is 1.3

 B. Value of x is 2

 C. Value of x is 0.3

 D. Compile time error


Answer: Option D
52. What is the output of this C code?

void main()
{
int a = 5;
int b = ++a + a++ + --a;
printf("Value of b is %d", b);
}

 A. Value of x is 16

 B. Value of x is 21

 C. Value of x is 15

 D. Undefined behaviour
Answer: Option D

53. The precedence of arithmetic operators is (from highest to lowest)?

 A. %, *, /, +, -

 B. %, +, /, *, -

 C. +, -, %, *, /

 D. %, +, -, *, /
Answer: Option A

54. Which of the following is not an arithmetic operation?

 A. a *= 20;

 B. a /= 30;

 C. a %= 40;

 D. a != 50;
Answer: Option D

55. Which of the following data type will throw an error on modulus operation(%)?

 A. char

 B. short

 C. float
 D. int
Answer: Option C

56What is the output of this C code?

void main()
{
int x = 0;
if (x = 0)
printf("Its zero\n");
else
printf("Its not zero\n");
}

 A. Its not zero

 B. Its zero

 C. Run time error

 D. None
Answer: Option A

1. Who is father of C Language?


A. Bjarne Stroustrup
B. Dennis Ritchie
C. James A. Gosling
D. Dr. E.F. Codd
Answer: B

2. C Language developed at _____?


A. AT & T's Bell Laboratories of USA in 1972
B. AT & T's Bell Laboratories of USA in 1970
C. Sun Microsystems in 1973
D. Cambridge University in 1972
Answer: A

3. For 16-bit compiler allowable range for integer constants is ______ ?


A. -3.4e38 to 3.4e38
B. -32767 to 32768
C. -32768 to 32767
D. -32668 to 32667
Answer: C

4. C programs are converted into machine language with the help of


A. An Editor
B. A compiler
C. An operating system
D. None of the above
Answer: B

5. A C variable cannot start with


A. An alphabet
B. A number
C. A special symbol other than underscore
D. both (b) and (c)
6. Which of the following is allowed in a C Arithmetic Instruction?
A. []
B. {}
C. ()
D. None of the above
Answer: C

7. Which of the following shows the correct hierarchy of arithmetic operations in C


A. / + * -
B. * - / +
C. + - / *
D. * / + -
Answer : D

8. What is an array?
A. An array is a collection of variables that are of the dissimilar data type.
B. An array is a collection of variables that are of the same data type.
C. An array is not a collection of variables that are of the same data type.
D. None of the above.
Answer : B

9. What is right way to Initialization array?


A. int num[6] = { 2, 4, 12, 5, 45, 5 } ;
B. int n{} = { 2, 4, 12, 5, 45, 5 } ;
C. int n{6} = { 2, 4, 12 } ;
D. int n(6) = { 2, 4, 12, 5, 45, 5 } ;
Answer : A

10. An array elements are always stored in _________ memory locations.


A. Sequential
B. Random
C. Sequential and Random
D. None of the above
Answer : A

11. What is the right way to access value of structure variable book{ price, page }?
A. printf("%d%d", [Link], [Link]);
B. printf("%d%d", [Link], [Link]);
C. printf("%d%d", price::book, page::book);
D. printf("%d%d", price->book, page->book);
Answer : A

12. perror( ) function used to ?


A. Work same as printf()
B. prints the error message specified by the compiler
C. prints the garbage value assigned by the compiler
D. None of the above
Answer : B

13. Bitwise operators can operate upon?


A. double and chars
B. floats and doubles
C. ints and floats
D. ints and chars
Answer : D

14. What is C Tokens?


A. The smallest individual units of c program
B. The basic element recognized by the compiler
C. The largest individual units of program
D. A & B Both
Answer : D

15. What is Keywords?


A. Keywords have some predefine meanings and these meanings can be changed.
B. Keywords have some unknown meanings and these meanings cannot be changed.
C. Keywords have some predefine meanings and these meanings cannot be changed.
D. None of the above
Answer : C
16. What is constant?
A. Constants have fixed values that do not change during the execution of a program
B. Constants have fixed values that change during the execution of a program
C. Constants have unknown values that may be change during the execution of a program
D. None of the above
Answer : A
17. Which is the right way to declare constant in C?
A. int constant var =10;
B. int const var = 10;
C. const int var = 10;
D. B & C Both
Answer : D

18. Which operators are known as Ternary Operator?


A. ::, ?
B. ?, :
C. ?, ;;
D. None of the above
Answer : B

19. In switch statement, each case instance value must be _______?


A. Constant
B. Variable
C. Special Symbol
D. None of the above
Answer : A

20. What is the work of break keyword?


A. Halt execution of program
B. Restart execution of program
C. Exit from loop or switch statement
D. None of the above
Answer : C

21. What is function?


A. Function is a block of statements that perform some specific task.
B. Function is the fundamental modular unit. A function is usually designed to perform a
specific task.
C. Function is a block of code that performs a specific task. It has a name and it is reusable
D. All the above
Answer : D

22. Which one of the following sentences is true ?


A. The body of a while loop is executed at least once.
B. The body of a do ... while loop is executed at least once.
C. The body of a do ... while loop is executed zero or more times.
D. A for loop can never be used in place of a while loop.
Answer : B

23. Recursive functions are executed in a?


A. First In First Out Order
B. Load Balancing
C. Parallel Fashion
D. Last In First Out Order
Answer : D

24. The statement print f ("%d", 10 ? 0 ? 5 : 1 : 12); will print?


A. 10
B. 0
C. 12
D. 1
Answer : D

25. The statement printf("%c", 100); will print?


A. prints 100
B. print garbage
C. prints ASCII equivalent of 100
D. None of the above
Answer : C

26. The _______ memory allocation function modifies the previous allocated space.
A. calloc
B. free
C. malloc
D. realloc
Answer : D
27. The "C" language is
A. Context free language
B. Context sensitive language
C. Regular language
D. None of the above
Answer : A

28. C is ______ Language?


A. Low Level
B. High Level
C. Assembly Level
D. Machine Level

29. The Default Parameter Passing Mechanism is called as


A. Call by Value
B. Call by Reference
C. Call by Address
D. Call by Name
Answer : A
30. Which is the correct syntax to declare constant pointer?
A. int *const constPtr;
B. *int constant constPtr;
C. const int *constPtr;
D. A and C both
Answer : D

31. What will be the output of the following arithmetic expression ?


5+3*2%10-8*6
a) -37
b) -42
c) -32
d) -28
Ans: a

32. What will be the output of the following statement ?


int a=10;
printf("%d &i",a,10);
a) error
b) 10
c) 10 10
d) none of these
Ans: d

33. What will be the output of the following statement ?


printf("%X%x%ci%x",11,10,'s',12);
a) error
b) basc
c) Bas94c
d) none of these
Ans: b

34. What will be the output of the following statements ?


int a = 4, b = 7,c; c = a = = b;
printf("%i",c);
a) 0
b) error
c) 1
d) garbage value
Ans: a

35. What will be the output of the following statements ?


int a = 5, b = 2, c = 10, i = a>b
void main()
{ printf("hello"); main(); }
a) 1
b) 2
c) infinite number of times
d) none of these
Ans: c

36. What will be output if you will compile and execute the following c code?
struct marks{
int p:3;
int c:3;
int m:2;
};
void main(){
struct marks s={2,-6,5};
printf("%d %d %d",s.p,s.c,s.m);
}
(a) 2 -6 5
(b) 2 -6 1
(c) 2 2 1
(d) Compiler error
(e) None of these
Ans: c

37. What will be the output of the following statements ?


int x[4] = {1,2,3}; printf("%d %d %D",x[3],x[2],x[1]);
a) 03%D
b) 000
c) 032
d) 321
Ans: c

38. What will be the output of the following statement ?


printf( 3 + "goodbye");
a) goodbye
b) odbye
c) bye
d) dbye
Ans: d

39. What will be the output of the following statements ?


long int a = scanf("%ld%ld",&a,&a); printf("%ld",a);
a) error
b) garbage value
c) 0
d) 2
Ans: b
40. What will be the output of the following program ?
#include
void main()
{ int a = 2;
switch(a)
{ case 1:
printf("goodbye"); break;
case 2:
continue;
case 3:
printf("bye");
}
}
a) error
b) goodbye
c) bye
d) byegoodbye
Ans: a

41. What will be the output of the following statements ?


int i = 1,j; j=i--- -2; printf("%d",j);
a) error
b) 2
c) 3
d) -3
Ans: c
42. What will be the output of following program ?
#include
main()
{
int x,y = 10;
x = y * NULL;
printf("%d",x);
}
a) error
b) 0
c) 10
d) garbage value
Ans: b

43. What will be the output of following statements ?


char x[ ] = "hello hi"; printf("%d%d",sizeof(*x),sizeof(x));
a) 88
b) 18
c) 29
d) 19
Ans: d

44. What will be the output of the following statements ?


int a=5,b=6,c=9,d; d=(ac?1:2):(c>b?6:8)); printf("%d",d);
a) 1
b) 2
c) 6
d) Error
Ans: d

45. What will be the output of the following statements ?


int i = 3;
printf("%d%d",i,i++);
a) 34
b) 43
c) 44
d) 33
Ans: b

46. What will be the output of the following program ?


#include
void main()
{
int a = 36, b = 9;
printf("%d",a>>a/b-2);
}
a) 9
b) 7
c) 5
d) none of these
Ans: a

47. int testarray[3][2][2] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};


What value does testarray[2][1][0] in the sample code above contain?
a) 11
b) 7
c) 5
d) 9
Ans: a

48. void main()


{
int a=10,b=20;
char x=1,y=0;
if(a,b,x,y)
{
printf("EXAM");
}
}
What is the output?
a) XAM is printed
b) exam is printed
c) Compiler Error
d) Nothing is printed
Ans: d

49. What is the output of the following code?


#include
void main()
{
int s=0;
while(s++<10)>
# define a 10
main()
{
printf("%d..",a);
foo();
printf("%d",a);
}
void foo()
{
#undef a
#define a 50
}
a) 10..10
b) 10..50
c) Error
d) 0
Ans: c

50. main()
{
struct
{
int i;
}xyz;
(*xyz)->i=10;
printf("%d",xyz.i);
}
What is the output of this program?
a) program will not compile
b) 10
c) god only knows
d) address of I
Ans: b

[Link] will happen if in a C program you assign a value to an array element whose
subscript exceeds the size of array?
A. The element will be set to 0.
B. The compiler would report an error.
C. The program may crash if some important data gets overwritten.
D. The array size would appropriately grow.
Ans: C

52. What would be the output of the following program?


#include
main()
{
char str[]="S\065AB";
printf("\n%d", sizeof(str));
}
a) 7
b) 6
c) 5
d) error
Ans: b

53. What will be the value of `a` after the following code is executed
#define square(x) x*x
a = square(2+3)
a) 25
b) 13
c) 11
d) 10
Ans: c

54. #include
void func()
{
int x = 0;
static int y = 0;
x++; y++;
printf( "%d -- %d\n", x, y );
}
int main()
{
func();
func();
return 0;
}
What will the code above print when it is executed?
a)
1 -- 1
1 -- 1
b)
1 -- 1
2 -- 1
c)
1 -- 1
2 -- 2
d)
1 -- 1
1 -- 2
Ans: d

55. long factorial (long x)


{
????
return x * factorial(x - 1);
}
With what do you replace the ???? to make the function shown above return the
correct answer?
a)
if (x == 0) return 0;
b)
return 1;
c)
if (x >= 2) return 2;
d)
if (x <= 1) return 1;
Ans: d

56. int y[4] = {6, 7, 8, 9};


int *ptr = y + 2; printf("%d\n", ptr[ 1 ] );
What is printed when the sample code above is executed?
a) 6
b) 7
c) 8
d) 9
Ans: d

57. int i = 4;
switch (i)
{
default: ;
case 3:
i += 5;
if ( i == 8)
{
i++;
if (i == 9) break;
i *= 2;
}
i -= 4;
break;
case 8:
i += 5;
break;
}
printf("i = %d\n", i);
What will the output of the sample code above be?
a) i = 5
b) i = 8
c) i = 9
d) i = 10
Ans: a

58. What will be output if you will compile and execute the following c code?
void main()
{
if(printf("cquestionbank"))
printf("I know c");
else
printf("I know c++");
}
(a) I know c
(b) I know c++
(c) cquestionbankI know c
(d) cquestionbankI know c++
(e) Compiler error
Answer: (c)

[Link] will be output if you will compile and execute the following c code?
#define call(x) #x
void main(){
printf("%s",call(c/c++));
}
(a)c
(b)c++
(c)#c/c++
(d)c/c++
(e)Compiler error
Answer: (d)

60. What will be output if you will compile and execute the following c code?
#define message "union is\
power of c"
void main()
{
clrscr();
printf("%s",message);
getch();
}
(a) union is power of c
(b) union is power of c
(c) union is Power of c
(d) Compiler error
(e) None of these
Answer: (b)

61. What will be output if you will compile and execute the following c code?
void main(){
int a=25;
clrscr();
printf("%o %x",a,a);
getch();
}
(a) 25 25
(b) 025 0x25
(c) 12 42
(d) 31 19
(e) None of these
Answer: (d)

62. What will be output if you will compile and execute the following c code?
void main()
{
int i=0;
if(i==0){
i=((5,(i=3)),i=1);
printf("%d",i);
}
else
printf("equal");
}
(a) 5
(b) 3
(c) 1
(d) equal
(e) None of above
Answer: (c)

[Link] will be output if you will compile and execute the following c code?
int extern x;
void main()
printf("%d",x);
x=2;
getch();
}
int x=23;
(a) 0
(b) 2
(c) 23
(d) Compiler error
(e) None of these
Answer: (c)

[Link] will be output if you will compile and execute the following c code?
void main(){
int a,b;
a=1,3,15;
b=(2,4,6);
clrscr();
printf("%d ",a+b);
getch();
}
(a) 3
(b) 21
(c) 17
(d) 7
(e) Compiler error
Answer: (d)

65. What will be output if you will compile and execute the following c code?
void main(){
static main;
int x;
x=call(main);
clrscr();
printf("%d ",x);
getch();
}
int call(int address){
address++;
return address;
}
(a) 0
(b) 1
(c) Garbage value
(d) Compiler error
(e) None of these
Answer: (b)

66. What will be output if you will compile and execute the following c code?
#include "string.h"
void main(){
clrscr();
printf("%d %d",sizeof("string"),strlen("string"));
getch();
}
(a) 6 6
(b) 7 7
(c) 6 7
(d) 7 6
(e) None of these
Answer: (d)

67. Which of the following below is/are valid C keywords


a) integer
b) int
c) null
d) none of above
Answer: B

68. Total number of keywords in C are


a) 30
b) 32
c) 48
d) 132
Answer: B

69. Which operator has the highest priority


a) ()
b) []
c) *
d) /
Answer: A

70. What is the purpose of getch()


a) read a character from STDIN
b) read a character from a file
c) read all file
d) read file random
Answer:B

71. Difference between structure and union is


a) We can define functions within structures but not within a union
b) We can define functions within union but not within a structure
c) The way memory is allocated
d) There is no difference
Answer: C

72. To access the members of structure which symbol is used


a) *
b) -
c) ,
d) .
Answer: D
73. A member is a
a) Variable in a structure
b) Data type of structure
c) Structure pointer
d) None of above
Answer: A

74. Structures can be used


a) to hold different data types
b) have pointers to structures
c) to assign to one another
d) all of above
Answer: D

75. printf() belongs to which library of c


a) stdlib.h
b) stdio.h
c) stdout.h
d) stdoutput.h
Answer: B

76. A variable in c
a) must have a valid data type
b) can't have a name same as keyword
c) must have a name starting with a character
d) All of above
Answer: D

77. Wild pointer in C


a) if pointer is pointing to a memory location from where variable has been deleted
b) if pointer has not been initialized
c) if pointer has not defined properly
d) if pointer pointing to more than one variable
Answer: B

78. What is prototype of a function in C


a) It is the return type of a function
b) It is the return data of the function
c) It is declaration of a function
d) It is a data type
Answer: C

79. Size of void pointer is


a) 1 byte
b) 2 byte
c) 4 byte
d) 8 byte
Answer: B

80. We can insert pre written code in a C program by using


a) #read
b) #get
c) #include
d) #put
Answer: C

You might also like