Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 21

MCQs of C

Solved MCQ of C set-1


1. C language has been developed by
A) Martin Richards
B) Bijarne Stroustrup
C) Dennis Ritche
D) Ken Thompson
2. int[ ] ={5,6,7,8,9} What is the value of a[3]?
A) 9
B) 8
C) 7
D) 6
3. C can be used on
A) Only MS-Dos operating System
B) Only Linux operating system
C) Only Windows operating system
D) All of the above
4. Float a[15], what is the size of array?
A) 17
B) 14
C) 15
D) 16
5. C programs are converted into machine language with the help of
A) An Editor
B) A complier
C) An operating system
D) None of the above
6. Array is
A) Primary data type
B) Pointer data type
C) Heterogeneous data type
D) Homogenous data type
7. Which of the following is allowed in a C Arithmetic Instruction?

A) [ ]
B) { }
C) ( )
D) None of the above
8. To accept 100 different values into the array we require
A) Loop
B) If condition
C) Function
D) Structure
9. If a is an integer variable, a=7/3; will return a value
A) 2.5
B) 3
C) 0
D) 2
10. Pointer holds
A) Value of variable
B) Address of variable
C) Value and address of variable
D) Always null
Answers:
1. C) Dennis Ritche
2. B) 8
3. D) All of the above
4. C) 15
5. B) A complier
6. D) Homogenous data type
7. C) ( )
8. A) Loop
9. D) 2
10. B) Address of variable

Objective Questions of C with answer set-2


1. Hierarchy decides which operator
A) is most important
B) is used first
C) is fastest
D) Operates on largest numbers
2. A pointer can hold

A) Single address at a time


B) Two addresses at a time
C) Number of addresses at a time
D) No address
3. An integer constant in C must have
A) At least one digit
B) At least one decimal point
C) A comma along with digits
D) Digits separated by commas
4. main() {
Int a=3, b=2, c*d*e;
d=&a; e=&b;
c=*d+*e;
}
Which one of the given answers is correct?
A) a=4, c-6
B) a=3, c=5
C) a=3, c=6
D) a=3, c=8
5. In C a variable cannot contain
A) Blank Spaces
B) Decimal Point
C) Hyphen
D) All of the above
6. Assume that variable x resides at memory location 1234, y at 1111 and p at 2222.
Int x=1, y=2, *p;
p=&x;
y=*p;
What will be the value of y after execution of above code?
A) 2
B) 1
C) 1234
D) 1111
7. Which of the following is FALSE in C?
A) Keywords can be used as variable names
B) Variable names can contain a digit
C) Variable names do not contain a blank space
D) Capital letters can be used in variables
8. If an integer occupies 4 bytes and a character occupies 1 byte of memory, each element of the
following structure would occupy how many bytes ?
struct name {

int age;
char name[30];
};
A) 30
B) 32
C) 34
D) 36
9. The expression x=4+2 % -8 evaluates to
A) -6
B) 6
C) 4
D) None of the above
10. A structure brings together a group of
A) items of the same data type
B) related data items and variables
C) integers with user defined names
D) floating points with user defined names
Answers:
1. B) is used first
2. A) Single address at a time
3. A) At least one digit
4. B) a=3, c=5
5. A) Blank Spaces
6. B) 1
7. A) Keywords variable names
8. C) 34
9. B) 6
10. B) related data items and variables

Solved MCQ of Programming in C set-3

Dependency graph for tgmath.h header file in


C Programming Language (Photo credit:
Wikipedia)
1. C language is available for which of the following operating systems?
A) DOS
B) Windows
C) Unix
D) All of the above
2. Which of the following are tokens in C?
A) Keywords
B) Variables
C) Constraints
D) All of the above
3. C was developed in the year .....................
A) 1970
B) 1972
C) 1976
D) 1980

4. Which escape character can be used to beep from speaker in C?


A) \a
B) \b
C) \m
D) \n
5. Which of the following is a keyword is used for storage class?
A) printf
B) external
C) auto
D) scanf
6. Continue statement is used .............
A) to go to the next iteration in a loop
B) come out of a loop
C) exit and return to the main function
D) restarts iteration from beginning of loop
7. File manipulation functions in C are available in which header file?
A) streams.h
B) stdio.h
C) stdlib.h
D) files.h

8. A compiler ................
A) is a computer program
B) translates a high level language into machine language
C) is a part of software
D) editor
9. Explicit type conversion is known as ....................
A) casting
B) conversion
C) disjunction
D) separation
10. A function popularly used C input function
A) scanf
B) printf
C) getch
D) Char

Answers:

1. C language is available for which of the following operating systems?


D) All of the above
2. Which of the following are tokens in C?
D) All of the above
3. C was developed in the year .....................

A) 1970
4. Which escape character can be used to beep from speaker in C?
B) \b
5. Which of the following is a keyword is used for storage class?
C) auto
6. Continue statement is used .............
A) to go to the next iteration in a loop
7. File manipulation functions in C are available in which header file?
B) stdio.h
8. A compiler ................
B) translates a high level language into machine language
9. Explicit type conversion is known as ....................
A) casting
10. A function popularly used C input function
A) scanf

MCQ on C Programming With Answers set-4


1. 'C' is often called a ....
A) Object oriented language
B) High level language
C) Assembly language
D) Machine level language

2. Each C preprocessor directive begins with ....


A) #
B) include
C) main()
D) {
3. C allows arrays of greater than two dimensions, who will determine this?
A) programmer
B) compiler
C) parameter
D) None of the above
4. The << operator is used for
A) Right shifting
B) Left shifting
C) Bitwise shifting
D) Bitwise complement
5. Set of values of the same type, which have a single name followed by an index is called
A) function
B) structure
C) array
D) union
6. Which of the following header file is required for strcpy() function?

A) String.h
B) Strings.h
C) file.h
D) strcpy()
7. scanf() can be used for reading ...
A) double character
B) single character
C) multiple characters
D) no character
8. A variable which is visible only in the function in which it is defined is called
A) Static variable
B) auto variable
C) external variable
D) local variable
9. In the loop structure logical expression is checked at the ....................of the loop.
A) first
B) end
C) middle
D) second
10. If an array is used as function argument, the array is passed
A) by value

B) by reference
C) by name
D) the array cannot be used as function argument
11. If is necessary to declare the type of function in the calling program if
A) Function returns an integer
B) Function returns a non-integer value
C) Function is not defined in the same file
D) Function is called number of times
12. Which escape character can be used to begin a new line in C ........
A) \a
B) \m
C) \b
D) \n
13. Input/output function prototypes and macros are defined in which header file?
A) conio.h
B) stdlib.h
C) stdio.h
D) dos.h
14. What is the purpose of fflush() function?
A) flushes all streams and specified streams
B) flushes only specified stream

C) flushes input/output buffer


D) flushes file buffer
15. What does the following declaration mean?int(*ptr)[10].
A) ptr is array of pointers to 10 integers.
B) ptr is a pointer to an array of 10 integers
C) ptr is an array of 10 integers
D) ptr is an pointer to array

Answers:

1. 'C' is often called a ....


B) High level language
2. Each C preprocessor directive begins with ....
A) #
3. C allows arrays of greater than two dimensions, who will determine this?
B) compiler
4. The << operator is used for
B) Left shifting
5. Set of values of the same type, which have a single name followed by an index is called
C) array
6. Which of the following header file is required for strcpy() function?
A) String.h

7. scanf() can be used for reading ...


C) multiple characters
8. A variable which is visible only in the function in which it is defined is called
D) local variable
9. In the loop structure logical expression is checked at the ....................of the loop.
A) first
10. If an array is used as function argument, the array is passed
B) by reference
11. If is necessary to declare the type of function in the calling program if
B) Function returns a non-integer value
12. Which escape character can be used to begin a new line in C ........
D) \n
13. Input/output function prototypes and macros are defined in which header file?
C) stdio.h
14. What is the purpose of fflush() function?
A) flushes all streams and specified streams
15. What does the following declaration mean?int(*ptr)[10].
B) ptr is a pointer to an array of 10 integers

Solved MCQ on C Programming Language set-5


1. What will be output of the following C program? #include int main() {int goto=5;
printf("%d",goto); return 0;}
A) 5

B) 10
C) **
D) compilation error
2. Output of the following C program fragment is. x=5; y=x++; printf("%d %d", x,y);
A) 5, 6
B) 5, 5
C) 6, 5
D) 6, 6
3. What will be output of the following C program? #include int xyz=10; int main() { int xyz=20;
printf("%d", xyz); return 0;}
A) 10
B) 20
C) 30
D) compilation error
4. Following program fragment. main(){ printf("%p\n", main( ) ); }
A) Prints the address of main function
B) Prints 0
C) Is an error
D) In an infinite loop
5. What will be output of the following program? #include int main() {int a=2, b=7, c=10;
c=a==b; printf("%d",c); return 0;}
A) 0

B) 7
C) 10
D) 2
6. What is the output of the following program segment? main( ) { long i=65536; printf("%d\n",
i); }
A) 0
B) 65536
C) -1
D) 65
7. What will be the output of the program? # include int main() {int a[5]={5,1,15,20,25}; int i, j,
m; i=++a[1]; j=a[1]++; m=a[i++]; printf("%d, %d, %d", i,j,m); return0;}
A) 2, 1, 15
B) 1, 2, 5
C) 3, 2, 15
D) 2, 3, 20
8. What is the output of the following program segment? main( ) { int=1; do { printf("%d . . ", i);
} while (i--); }
A) 0 . . 1 . .
B) 1 . . 0 . .
C) 0
D) -1
9. Output of the program below is. int i; main( ) { printf("%d", i); }

A) 1
B) 0
C) -1
D) Null
10. What will be the output of the following program? main( ) { int i=5; printf("%d", i=+
+i==6); }
A) 0
B) 7
C) 6
D) 1

Answers:

1. What will be output of the following C program? #include int main() {int goto=5;
printf("%d",goto); return 0;}
A) 5
2. Output of the following C program fragment is. x=5; y=x++; printf("%d %d", x,y);
C) 6, 5
3. What will be output of the following C program? #include int xyz=10; int main() { int xyz=20;
printf("%d", xyz); return 0;}
B) 20
4. Following program fragment. main(){ printf("%p\n", main( ) ); }
A) Prints the address of main function
5. What will be output of the following program? #include int main() {int a=2, b=7, c=10;
c=a==b; printf("%d",c); return 0;}

A) 0
6. What is the output of the following program segment? main( ) { long i=65536; printf("%d\n",
i); }
A) 0
7. What will be the output of the program? # include int main() {int a[5]={5,1,15,20,25}; int i, j,
m; i=++a[1]; j=a[1]++; m=a[i++]; printf("%d, %d, %d", i,j,m); return0;}
C) 3, 2, 15
8. What is the output of the following program segment? main( ) { int=1; do { printf("%d . . ", i);
} while (i--); }
B) 1 . . 0 . .
9. Output of the program below is. int i; main( ) { printf("%d", i); }
B) 0
10. What will be the output of the following program? main( ) { int i=5; printf("%d", i=+
+i==6); }
D) 1

objective type questions in c programming language set-6

1. Which symbol is used as a statement terminator in C?


A) !
B) ~
C) #
D) ;
2. If the size of the array is less than the number of initializes then, ..........

A) extra values are being ignored


B) generates an error message
C) size of array is increased
D) size is neglected when values are given
3. In C, if you pass an array as an argument to a function, what actually gets passed?
A) Value of elements in array
B) First element of the array
C) Base address of the array
D) Address of the last element of array
4. How many times the following loop be executed? { .. ch='b'; while (ch>='a' && ch<=='z') ch+
+; }
A) 0
B) 25
C) 26
D) 1
5. If a=8 and b=15 then the statement x=(a>b) ? a:b;
A) assigns a value 8 to x
B) gives an error message
C) assigns a value 15 to x
D) assigns a value 7 to x
6. What is the output of the following code. int n=0, m=1; do { printf("%d", m); m++; } while
(m<=n);

A) 0
B) 2
C) 1
D) 4
7. A C program contains the following declaration int i=8, j=5 what would be the value of
following expression? abs(i-2*j)
A) 2
B) 4
C) 6
D) 8
8. The output of the following is . int a=75; printf("%d%%", a);
A) 75
B) 75%%
C) 75%
D) None of the above
9. How many times the following program would print ("abc")? main( ) { printf("\nabc");
main( ); }
A) Infinite number of times
B) 32767 times
C) 65535 times
D) Till the stack does not overflow
10. Which of the following is the correct usage of conditional operators used in C?

A) a>b?c=30:c=40;
B) a>b?c=30;
C) max=a>b?a>c?a:c:b>c?b:c
D) return (a>b)?(a:b)

Answers:

1. Which symbol is used as a statement terminator in C?


D) ;
2. If the size of the array is less than the number of initializes then, ..........
B) generates an error message
3. In C, if you pass an array as an argument to a function, what actually gets passed?
C) Base address of the array
4. How many times the following loop be executed? { .. ch='b'; while (ch>='a' && ch<=='z') ch+
+; }
B) 25
5. If a=8 and b=15 then the statement x=(a>b) ? a:b;
C) assigns a value 15 to x
6. What is the output of the following code. int n=0, m=1; do { printf("%d", m); m++; } while
(m<=n);
C) 1
7. A C program contains the following declaration int i=8, j=5 what would be the value of
following expression? abs(i-2*j)
A) 2
8. The output of the following is . int a=75; printf("%d%%", a);

D) None of the above


9. How many times the following program would print ("abc")? main( ) { printf("\nabc");
main( ); }
A) Infinite number of times
10. Which of the following is the correct usage of conditional operators used in C?
C) max=a>b?a>c?a:c:b>c?b:c

You might also like