Programming in C Question Bank
Programming in C Question Bank
SUBJECT: PROGRAMMING IN C
3. 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
a. 1 character
b. 8 characters
c. 254 characters
d. None of the above
a. The character Z
b. ASCII value of Z
c. Z along with the single inverted commas
d. Both (1) and (2)
a. Thank You’
b. ‘Enter values of P, N, R’
c. ‘23.56E-03’
d. All the above
a. -32767
b. 32767
c. 1.7014e+38
d. –1.7014e+38
a. An alphabet
b. A number
c. A special symbol other than underscore
d. Both (2) &(3) above
a. mes = 123.56
b. con = T* A;
c. this = T* 20
d. 3+a=b
a. []
b. {}
c. ()
d. None of the above
a. is most important
b. is used first
c. is fastest
d. operates on largest numbers
a. 32 characters
b. 8 characters
c. 254 characters
d. 1 character
a. Blank spaces
b. Hyphen
c. Decimal point
d. All the above
a. character
b. integer
c. float
d. double
a. 1A
b. !A
c. A_1
d. None of these
a. 1 byte
b. 2 byte
c. 4 byte
d. 8 byte
a. integer
b. pointer
c. Array
d. None of these
a. character
b. integer
c. float
d. double
a. character
b. integer
c. float
d. double
a. 1 byte
b. 2 byte
c. 4 byte
d. 8 byte
26. What is the 16-bit compiler allowable range for integer constants?
28. How many characters can a string hold when declared as follows?
a. char name[20]:
b. 18
c. 19
d. 20
a. Pre-processor
b. Compiler
c. Linker
d. Editor
a. Executable code
b. Object code
c. Assembly code
d. None of the above.
a. 30
b. 32
c. 34
d. 24
a. printf()
b. scanf()
c. main()
d. None of the above
a. Low Level
b. High Level
c. Low + High
d. None
a. Object Oriented
b. Procedural
c. Bit level language
d. Functional
a. Uniliver Labs
b. IBM Labs
c. AT&T Bell Labs
d. Verizon Labs
a. Android
b. Linux
c. Ubuntu
d. Unix
a. Statements
b. Functions
c. Variables
d. All of the above
a. 3.145
b. 34
c. 125"
d. None of the above
a. A to Z = 65 to 91
b. a to z = 97 to 122
c. 0 to 9 = 48 to 57
d. All the above
a. Variables
b. Constants
c. variable names on right side of =
d. constants on left side of =
a. /+*-
b. *- / +
c. +-/*
d. /*+-
a. &
b. %
c. !
d. =
main( )
int a = 300, b, c ;
if ( a >= 400 )
b = 300;
c = 200;
a. 300 200
b. 400 200
c. Garbage value 200
d. None of these
main( )
int x = 3, y = 5 ;
if ( x == 3 )
printf ( "\n%d", x ) ;
else ;
printf ( "\n%d", y ) ;
a. 5
b. 3 5
c. 3
d. None of these
main( )
int x = 3, y, z ;
y = x = 10 ;
z = x < 10 ;
a. 3 10 0
b. 3 10 1
c. 10 10 0
d. None of these
a. ?:
b. :?
c. :<
9. What is the other name for the following in C Language ? : Question Mark Colon Operator.?
a. Comparison Operator
b. If-Else Operator
c. Binary Operator
d. Ternary Operator
a. +
b. *
c. /
d. %
a. I and II
b. I and III
c. II and III
d. II and IV
13. Output of an arithmetic expression with integers and real numbers is ___ by default?
a. Integer
b. Real number
c. Depends on the numbers used in the expression
d. None of the above
a. a = 10
b. a = 14.867
c. a = 14
d. compiler error
a. a=0
b. a=7
c. a=8
d. a = 8.0
a. x = 8.0
b. x=8
c. x=7
d. x = 0.0
18. Can you use C Modulo Division operator % with float and int?
a. Operators *, / and % have Left to Right Associativity. Operators + and - have Left to Right
Associativity. Operator = has Right to Left Associativity.
b. Operators *, / and % have Right to Left Associativity. Operators + and - have Left to Right
Associativity. Operator = has Right to Left Associativity.
a. Truncation
b. Rounding
c. Underflow
d. None of these
a. Comparison Operator
b. If-Else Operator
c. Binary Operator
d. Ternary Operator
23. In C programming language, which of the following type of operators have the highest
precedence
a. Relational Operators
b. Equality Operators
c. Logical Operators
d. Arithmetic Operators
24. Which of the following comments about the ++ operator are correct?
a. It is a unary operator
b. The operand can come before or after the operator
c. It cannot be applied to an expression
d. All of the above
int z, x = 5, y = -10, a = 4, b = 2;
z = x++ - --y*b/a;
26. Which operator from the following has the lowest priority?
a. Assignment Operator
b. Division Operator
c. Comma Operator
d. Conditional Operator
27. Given b = 110 and c = 20, what is the value of 'a' after execution of the expression a = b = c*=5?
a. 450
b. 10
c. 110
d. -10
28. In C programming language, which of the following type of operators have the highest precedence
a. Relational operators
b. Equality operators
c. Logical operators
d. Arithmetic operators
29. In C programming language, which of the following operator has the highest precedence?
a. Unary +
b. *
c. >=
d. ==
30. If i j,k are integer variable with values 1,2,3 respectively, then what is the value of the expression
a. 6
b. 5
c. 1
d. 0
31. The expression a << 6 shifts all bits of a six places to the left. If a Ox6db7, then what is the value
of a << 6
a. 0xa72b
b. 0xa2b
c. 0x6dc0
int **a;
a. is illegal
b. is legal but meaningless
c. is syntactically and semantically correct
d. none of these
34.Determine Output:
void main() {
int i = 0, j = 1, k = 2, m;
a. 1 1 2 3
b. 1 1 2 2
c. 0 1 2 2
d. 0 1 2 3
35. Determine Output :
void main() {
int c = - -2;
a. 1
b. -2
c. 2
d. Error
a. Selection
b. Decision
c. Repetition
d. None of these
a. Two
b. Five
c. Seven
d. Three
3. Which of the following statement is used to take the control to the beginning of the loop?
a. Exit
b. Break
c. continue
d. None of the above
a. 5
b. 3
c. 9
d. 7
a. 0
b. Infinitely
c. 1
d. Variable
6. What is the use of WHILE loop?
a. an if statement
b. a for loop
8. A do-while loop is useful when we want that the statements within the loop must be executed:
a. Only once
b. At least once
c. More than once
d. None of the above
a. One
b. Zero
c. Non – zero
d. None of the above
10. In what sequence the initialization, testing and execution of body is done in a do-while loop
a. Character
b. Integer
c. Float
d. Enum
a. Pass by value
b. Pass by reference
c. Non-pointer variable are pass by value and pointers are passed by reference
d. Passed by value result
a. Forever
b. Never
c. 0
d. 1
a. While Block
b. For Block
c. Do While Block
d. All the above
a. for
b. while
c. do while
d. All work at same speed
a. &&
b. ||
c. both i & ii
d. !
a. Relational operator
b. Binary operator
c. Ternary operator
d. Arithematic operator
y = (x > 6 ? 4 : 6);
a. Compilation Error
b. 0
c. 4
d. 6
a. !
b. ||
c. &&
d. All of the above
a. for
b. while
c. do while
d. switch
a. True
b. False
a. if (if (a == 1)){}
b. if (a){}
c. if ((char) a){}
d. if (func1 (a)){}
a. int
b. char
c. long
d. All of the above
a. for
b. while
c. do while
d. None of the above
a. ;
b. :
c. ,
d. =
a. One
b. Zero
c. Non - zero
d. None of the above
a. Continue
b. Break
c. Return
d. None of the above
a. Call by value
b. Call by reference
c. Address relocation
d. Address restructure
a. int anarray[10];
b. int anarray;
c. anarray{10};
d. array anarray[10];
7. Which of the following operator can be used to access value at address stored in a pointer variable?
a. *
b. #
c. &&
d. @
a. Macros
b. Conditional Compilation
c. File Inclusion
d. All the above
a. $ symbol (DOLLAR)
b. @ symbol (At The Rate)
c. & symbol (Ampersand)
d. # symbol (HASH)
#include <stdio.h>
void main() {
#ifdef max
printf("Hello");
a. 100
b. hello
c. "hello"
d. Error
13. __________ is the Preprocessor directive which is used to end the scope of #ifdef.
a. #elif
b. #ifndef
c. #endif
d. #if
#include <stdio.h>
void main() {
#if (max%10)
printf("Alg");
#endif
printf("bly");
a. error
a. auto
b. register
c. extern
d. volatile
16. What is the inital value of register storage class specifier?
a. 0
b. Null
c. Garbage
d. Infinite
a. Within block
b. Within Program
c. Global Multiple files
d. None of the above
a. Within block
b. Within Program
c. Global Multiple files
d. None of the above
a. 0
b. Null
c. Garbage
d. Infinite
a. 21
b. 00
c. 32
d. Compilation error
(I) The maximum value a variable can hold depends upon its storage class.
a. Only I is correct
b. Only II is correct
c. Both I & II are correct
d. Both I & II are incorrect
a. 2
b. 3
c. 4
d. 5
a. Randomly
b. Sequentially
c. Exponentially
d. Logarithmically
a. 15
b. 19
c. 11
d. 60
a. Binary trees
b. Scheduling of processes
c. Caching
d. Spatial locality
a. Compile-time
b. Run-time
c. Not an error
d. Not an exception at all
a. Compile-time
b. Run-time
c. Not an error
d. Not an exception at all
System.out.println(arr[5]);
a. 4
b. 5
c. ArrayIndexOutOfBoundsException
d. InavlidInputException
System.out.println(arr[2]);
System.out.println(arr[4]);
a. 3 and 5
b. 5 and 3
c. 2 and 4
d. 4 and 2
1. What is the base data type of a pointer variable by which the memory would be allocated to it?
a. int
b. No datatype
c. Depends upon the type of the variable to which it is pointing
d. unsigned int
a. int p*;
b. int *p;
c. int +p;
d. int $p;
a. Passed to a function
b. Changed within a function
c. Returned by a function
d. Can be assigned an integer value
void main() {
p = a;
++*p;
p += 2;
a. 24
b. 34
c. 22
d. 23
char *ptr;
ptr = myString;
a. fg
b. efg
c. defg
d. cdefg
int main() {
return 0;
a. True
b. False
a. True
b. False
9. Which of the following statements correct about k used in the below statement?
char ****k;
char *p = 0;
char *t = NULL;
a. Yes
b. No
11. What is the base data type of a pointer variable by which the memory would be allocated to it?
a. int
b. No datatype
c. Depends upon the type of the variable to which it is pointing
a. Declared
b. Initialized
c. Both declared and initalized
d. None of these
a. int p*;
b. int *p;
c. int +p;
d. int $p;
a. Passed to a function
b. Changed within a function
c. Returned by a function
d. Can be assigned an integer value
void main() {
p = a;
++*p;
p += 2;
a. 24
b. 34
c. 22
d. 23
int main() {
return 0;
a. True
b. False
a. True
b. False
#include <stdio.h>
struct temp {
int a[10];
char p;
};
a. 5
b. 11
c. 41
d. 44
int main() {
struct ship {
};
return 0;
a. structure is used to implement Linked Lists, Stack and Queue data structures
b. Structures are used in Operating System functionality like Display and Input taking
c. Structure are used to exchange information with peripherals of PC
d. All the above
a. s1 = &s2;
b. s1 = s2;
c. (*s1).number = 10;
d. None of the mentioned
28. Which one of the following is correct syntax for opening a file.
30. If the mode includes b after the initial letter, what does it indicates?
a. text file
b. big text file
c. binary file
d. blueprint text
a. input streams
b. output streams
c. previous contents
d. appended text
32. _____removes the named file, so that a subsequent attempt to open it will fail.
a. remove(const *filename)
b. remove(filename)
c. remove()
d. fclose(filename)
34.What does tmpfile() returns when it could not create the file?
a. fscanf() can read from standard input whereas scanf() specifies a stream from which to read
b. fscanf() can specifies a stream from which to read whereas scanf() can read only from
standard input
c. fscanf() and scanf() has no difference in their functions
1. fscanf() and scanf() can re
1. Explain about Pseudo code Statement and Flowchart symbol with the help of
example.
2. Explain the Evolution of programming Languages.
3. Write a program to take input of name, rollno and marks obtained by a student in 4
subjects of 100 marks each and display the name, rollno with percentage score
secured.
4. Write a program to calculate simple and compound interest.
5. Write a program to swap values of two variables with and without using third variable
6. What do you understand by Decision Making Statement? Write down the syntax of if,
if else, if-else-if ladder using program.
7. What do you mean by Looping Statement? How many types of looping statement
present in c language. Also write down their syntax.
8. Write a Program to Check Whether a Number is Prime or not. 2
9. Write a program to find the largest and smallest among three entered numbers and
also display whether the identified largest/smallest number is even or odd.
10. Write a program to check whether the entered year is leap year or not (a year is leap if
it is divisible by 4 and divisible by 100 or 400.)
11. Write a program to find the factorial of a number.
12. Write a program to check number is Armstrong or not.
13. Write a program to print day name using switch case statement.
14. Write a program to check whether date is valid or not.
15. How to pass arguments to a function? Explain the concept of call by value and call by
reference with the help of program.
16. Write a Program to Search an element in array.
17. Write a Program to perform addition of all elements in Array.
18. Write a Program to find the largest and smallest element in Array.
19. Write a Program to reverse the array elements in C Programming.
2. Two integer operands and one operator form user, performs the operation and then
prints the result. (Consider the operators +,-,*, /, % and use Switch Statement)
3. Write a C program to find the factorial of a given integer by using recursive and
non-recursive functions.
6. Write a program to compute grade of students using if else adder. The grades are
assigned as followed:
a. Marks Grade
b. marks<50 F
c. 50≤marks< 60 C
d. 60≤marks<70 B
e. 70≤marks<80 B+
f. 80≤marks<90 A
g. 90≤mars≤ 100 A+
8. Write a program to create a structure named company which has name, address,
phone and noOfEmployee as member variables. Read name of company, its
address, phone and noOfEmployee. Finally display these members‟ value.
11. Write a program to add two distances in feet and inches using structure.
15. Write a program to create a file called emp.rec and store information abouta person,
in terms of his name, age and salary.
17. Write a C program to merge two files into a third file (i.e., the contents of the first file
followed by those of the second are put in the third.
(ix (x)
)1 (xi)
******* (xii)
123 ******
*** *** *****
12345 *
123 ** ** * *
*
1 * * * *
*
* *
* *****
******