0% found this document useful (0 votes)
102 views20 pages

C Question Bank

The document outlines a comprehensive curriculum on computers and C programming, divided into five units covering topics such as algorithms, data types, control statements, arrays, functions, pointers, strings, structures, and file management. It includes short answer questions and essay prompts designed to assess understanding and application of C programming concepts. Additionally, it features multiple-choice questions to test foundational knowledge about computers and programming languages.

Uploaded by

dgpguru
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)
102 views20 pages

C Question Bank

The document outlines a comprehensive curriculum on computers and C programming, divided into five units covering topics such as algorithms, data types, control statements, arrays, functions, pointers, strings, structures, and file management. It includes short answer questions and essay prompts designed to assess understanding and application of C programming concepts. Additionally, it features multiple-choice questions to test foundational knowledge about computers and programming languages.

Uploaded by

dgpguru
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
You are on page 1/ 20

UNIT –I : OVERVIEW OF COMPUTERS AND C-PROGRAMMING

Short Answer (2 mark) Questions


1. Write difference between algorithm and flowchart.
2. Explain the importance of C language.
3. What is format specifier?
4. Define keyword, constant and variable.
5. Write a short note on type casting.
6. Explain sizeof() with example?
7. Why do we use header files?
8. Define relational operator?
9. What is the purpose of adding comments in a program?
10. Differentiate between computer software and hardware?

Essay Answer (10 mark) Questions


1. Describe in detail about computer hardware and software. [10]
2. Write detailed notes on C data types. [10]
3. Write an algorithm, flowchart and C program to find the sum of numbers from 1 to ‗n‘
4. Discuss about the following operators in C language with example. [4+3+3]
a. Bitwise operators
b. Increment and decrement operators
c. Logical operators
5. Perform the following operations [2+2+2+2+2]
a. 23>>3 b. 27<<2 c. 15&9 d. 15^9 e. 15 | 9
6. (a) Write the structure of C program and explain. [5+5]
(b) Write a program to perform swapping of two numbers without using temporary variable.
7. (a) Define algorithm. Write algorithm for finding factorial of a number. [4+6]

(b) What is flowchart? Explain different symbols used for flowchart.


8. (a) What is constant? Explain different constants in C. [6+4]
(b) What is variable? Give the rules for variable declaration.
9. (a) Write an algorithm and flowchart to generate Fibonacci series of numbers up to 'n'.
(b) Draw the flowchart to find the greatest of three numbers. [5+5]
10. (a) Write an algorithm and flowchart to find whether the given number is prime or not. (b)
Explain about type conversion in C. [5+5]

Page 1
UNIT –II : DECISION & LOOP CONTROL STATEMENTS
Short Answer (2 mark) Questions

1. Classify the different types of decision making statements.


2. How switch case works without break statement.
3. Write the syntax for nested if and else-if ladder?
4. Write a program to check whether the person is eligible to vote.
5. Write and explain syntax of ―for‖ loop.
6. Distinguish between while and do-while statements.
7. Write a program to print the multiplication table from 1 to n?
8. Differentiate between break and continue.
9. Define goto with an example.
10. Define exit and return statements.
Essay Answer (10 mark) Questions

1. Explain various branching statements in C with examples. [10]


2. (a) Write and explain about switch statement. [4+6]
(b) Write a Program to perform arithmetic operations using switch.
3. List and explain loop control (or) iteration statements in C. [10]
4. (a) Write and explain syntax of ―for‖ loop. [3+7]
(b) Write a program to generate prime numbers between 1 and ‗n‘.
5. (a) Write a program to check whether the given number is palindrome or not. [5+5]
(b) Write a program to check whether the given number is ―Even‖ or ―Odd
6. List and explain unconditional statements in C with examples. [10]
7. (a) Write a program to find sum of the individual digits of a given number. [5+5]

(b) Write a program to find the sum of even and odd numbers from 1 to n.
8. (a) Write a program to find the factorial of a given number. [5+5]
(b) Write a program to generate ‗n‘ Fibonacci numbers.
9. (a) What is a nested loop? Write a program to display multiplications tables from 1 to n.
(b) Write a program to display the following pattern. [5+5]
*****
****
***
**
*
10. (a) Explain else-if ladder with the help of flowchart and program. [5+5]
(b) How does nested if-else works explain with an example?

Page 2
UNIT –III : Arrays and Functions
Short Answer (2 mark) Questions

1. What is an array? Write the types of an array.


2. How to declare and initialize 1-D, 2-D array with an example.
3. What is multi-dimensional array?
4. Write a program to read and display the elements using 1-D array.
5. Write a program to print the array elements in reverse order.
6. What is a function? Write the types of functions.
7. What is meant by call-by value and call-by reference?
8. What is recursion?
9. Write and explain the syntax of function?
10. What is #include, #define directives.
Essay Answer (10 mark) Questions
1. (a) Define an array. How to initialize one-dimensional array? Explain with suitable examples.
[5+5]
(b) Write a C program to sort the given array elements in Ascending order.
2. (a) How to declare and initialize a Two-dimensional array? Discuss with examples. [5+5]
(b) Write a C program to print the sum of diagonal elements of 2-D matrix.
3. Write a C program to multiply two matrices of different order. [10]
4. (a) Write a C program to read and display a 3 by 3 matrix. [5+5]
(b) Write a C program to add 2 matrices of size n by n.

5. (a) Illustrate multidimensional arrays with example program. [5+5]


(b) Write a C program to find the largest element given in an array of elements.
6. (a) What are the advantages of functions? [3+7]
(b) Write a C program using function to exchange two numbers using pointers.
7. (a) Discuss about the different categories of functions. [5+5]
(b) Write a C program to illustrate call-by-value parameter passing technique.
8. (a) Write short notes on nested functions. [4+6]
(b) Write a C program to explain call-by-reference parameter passing technique.
9. (a) What is recursion? What are the advantages and Disadvantages of recursion? [4+6]
(b) Write a C program to find the factorial of a given number using recursion.
10. Distinguish between the following: [4+3+3]
a. Actual and formal arguments
b. Global and local variables
c. Automatic and static variables

Page 3
UNIT –IV : POINTERS AND STRINGS
Short Answer (2 mark) Questions
1. Define pointer. How can you declare it?
2. What is pointer to pointer?
3. What is pointer arithmetic?
4. Define pointer array.
5. How can you read a string through keyboard?
6. What is array of strings?
7. Display string ―pepper‖ in reverse order
8. Discriminate puts() and gets()
9. Discriminate putchar() and getchar()
10. How can you compare two strings?
Essay Answer (10 mark) Questions

1. (a) Define pointer. How to declare and initialize it. [5+5]


(b) Write a C program to illustrate the use of indirection operator to access the value
pointed by a pointer.

2. (a) What are the features of pointers? Write a C program to print address of a variable
(b) Explain the declaration of pointers and pointer to pointer with examples. [6+4]
3. (a) With proper examples explain different arithmetic operations on pointers. [6+4]
(b) Write a C program to show that pointer of any data type occupies same space.
4. (a) Explain the concept of functions returning pointers with example. [5+5]
(b) Write a C program to read and print an array of elements using pointers.
5. (a) Explain the concept of array of pointers with examples. [4+6]
(b) Write a C program to read and display multiple strings using pointers.
6. (a) Write a C program to count the number of vowels, consonants, digits, spaces and
special characters in a given string. [5+5]
(b) Write a C program to read the elements in an array and print the same in reverse order.
7. (a) Write a C program to implement strcmp() , strcat() , strcpy() and strlen(). [5+5]
(b) Write a program to find the average marks obtained by a class of 50 students in a test.
8. (a) Explain declaration and initialization of array of strings. [4+6]
(b) Write a C program to find whether a given string is palindrome or not.
9. (a) Discus about arithmetic operations on characters. [5+5]
(b) Write a C program to read a set of strings and sort them in alphabetical order.
10. Explain the following string handling functions with example: [10]
a. strcpy() b. strcmp() c. strcat() d.strlen() e. strncat()
Page 4
UNIT –V : STRUCTURES AND FILE MANAGEMENT IN C
Short Answer (2 mark) Questions

1. Define Structure? How to Initialize a Structure?


2. How to represent self-referential structures?
3. Define Union? How to represent an union?
4. Write some of the differences between Structure and Union?
5. What are the Different ways of representing Structures and Functions?
6. What are the Different file operations?
7. Write about Sequential file handling functions?
8. Write about Random file handling functions?
9. Write about different file modes?
10. Write about different error handling functions on files?

Essay Answer (10 mark) Questions

1. (a) Define Structure and write the general syntax for declaring and accessing members.
(b) How to copy and compare structure variables? Illustrate with example. [5+5]
2. Write a C program that defines a structure employee containing the details such as empno,
empname, department name and salary. The structure has to store 20 employees in an
organization. Use the appropriate method to define the above details and define a function that
will display the contents? [10]
3. (a) Explain the following: [6+4]
i. Nested structures ii. Array of structures
(b) Write a C program to read and display student details using structure.
4. (a) Define union. Give the general template for union. [4+6]
(b) List out the differences between unions, structures and arrays
5. (a) How data elements are stored under unions, explain with example? [5+5]
(b) Write a C program to illustrate the concept of structure within structure.
6. (a) Write the syntax for opening a file with various modes and closing a file. [4+6]
(b) Explain the following file handling functions:
a. fseek() b. ftell() c. rewind() d. feof()
7. (a) Write a C program to display the contents of the file in reverse order. [5+5]
(b) Write a C program to copy the contents from one file to another file.
8. Write a C program to count no.of characters, spaces, lines, words of a file. [10]
9. (a) Discuss command line arguments in detail with examples. [5+5]
Page 5
(b) Write a short notes on
i. fgets() ii. fputs()
10. (a) Explain the following preprocessor directives: [4+6]
i. #include ii. #define
(b) Write a program in C that reads the name of a file and displays the contents of the file on the
user screen.

Page 6
UNIT-1 : OVERVIEW OF COMPUTERS AND C-PROGRAMMING

1. Which of the following is used to perform computations on the entered data?


(A) Memory (B) Processor (C) Input device (D) Output device
2. Which of the following is not an input device?
(A) Plotter (B) Scanner (C) Keyboard (D) Mouse
3. Which of the following is not an output device?
(a) Plotter (b) Scanner (c) Printer (d) Speaker
4. Which of the following is used as a primary memory of the computer?
(a) Magnetic storage device (b) RAM
(c) Optical storage device (d) Magneto-optical storage device
5. Which one of the following is a volatile memory?
(a) RAM (b) Auxiliary memory (c) ROM (d) Secondary memory
6. Software is defined as
(a) Set of memory cells (b) Set of Programs (c) Set of hardware (d) None
7. Which statement is a valid?
(a) 1KB=1024 bytes (b) 1 MB=2018 bytes
(c) 1 MB=10000 kilobytes (d) i KB=100 bytes
8. symbol is used for input/output in flowchart

(a) (b) (c) (d)


9. Which of the following is a pictorial representation of an algorithm?
(a) Program (b) Flowchart (c) Algorithm (d) Pseudo code
10. Among the following, which converts assembly language into machine language
(a) Interpreter (b) Compiler (c) Assembler (d) Algorithm
11. Which one of the following is known as the ―language of computer‖?
(a) Programming language (b) High-level language
(c) Machine language (d) Assembly language
12. translates high level language into machine language
(a) Compiler (b) Translator (c) Processor (d) Loader
13. Which of the following is not a valid variable declaration
(a) int 2class; (b) int class2; (c) int class_2; (d) int ELSE;

14. The range of ―unsigned int‖ data type is


(a) -32768 to 32767 (b) 0 to 65535 (c) -65536 to 65535 (d) -128 to 127
15. The size of ―long double‖ data type in 16-bit machine is
(a) 8 bytes (b) 10 bytes (c) 2 bytes (d) 4bytes
16. The range of ―char‖ data type is
(a) -128 to 127 (b) 0 to 255 (c) -32768 to 32767 (d) None
17. The size of ―char‖ data type is
(a) 1 byte (b) 2 bytes (c) 4 bytes (d) 10 bytes
18. The format specifier that is used to read or write a character is
(a) %f (b) %d (c) %c (d) %s
19. Which one of the following is a string constant
(a) ‗3‘ (b) “hello” (c) 30 (d) None
20. If no precision is specified for floating point number then printf() prints decimal

Page 7
positions.
(a) Two (b)Four (c) Six (d) Zero
21. What is the result of 8 | 4 ?
(a) 0 (b) 1 (c) 4 (d) 12
22. Which of the following operator is used to combine two or more relational expressions
(a) ^ (b) ~ (c) & (d) &&
23. ~(100111) gives
(a) 010010 (b) 011000 (c) 010100 (d) 111001
24. 10<<3 gives
(a) 40 (b) 1 (c) 80 (d) 30
25. Shifting a number ‗n‘ by ‗s‘ bits to left is equivalent to which of the following?
(a) 2s/n (b) n/2s (c) s2/n (d) n*2s
26. Shifting a number ‗n‘ by ‗s‘ bits to right is equivalent to which of the following?
(a) 2s/n (b) n/2s (c) s2/n (d) n*2s
27. Based on the precedence levels and associativity the 8+4*5+6/2 expression yields
(a) 43 (b) 34 (c) 31 (d) 41
28. operators are used for shifting bits to right and left
(a) >> and << (b) > and < (c) ?and : (d) None
29. The expression a++ is referred as
(a) Pre increment (b) Post increment (c) Before increment (d) After increment
30. The expression ++a referred as
(a) Pre increment (b) Post increment (c) Before increment (d) After increment
31. If a=3, b=5 the value of the expression ++a+b++ is
(a) 10 (b) 9 (c) 8 (d) None of the above
32. defines the order of evaluation when operators have the same precedence
(a) Priority (b) Precedence (c) Associativity (d) None of the above
33. Which one of the following is having highest precedence
(a) ++ (b) && (c) ( ) (d) ,
34. Which one of the following is having least precedence
(a) ++ (b) && (c) ( ) (d) ,
35. String constants are enclosed in

(a) ‗ ‗ (b) “ “ (c) ( ) (d) [ ]


36. Character constants are enclosed in
(a) „ „ (b) ― ― (c) ( ) (d) [ ]
37. The escape sequence character causes the cursor to move to the next line on the screen
(a) \t (b) \n (c) \r (d) \v
38. The assignment statement ―sum=sum+i;‖ is equivalent to
(A) sum=+i; (B) sum+=i; (C) sum= =sum+i; (D) None
39. sizeof() operator returns the size of an operand in
(A) Bits (B) Nibble (C) Bytes (D) None
40. Which of the following is the correct way of using type casting
(A) c=(int)a/b; (B) c=a(int)/b; (C) c=int a/b; (D) None

Page 8
UNIT-2 : DECISION & LOOP CONTROL STATEMENTS

1. Which of the following is not a loop structure?


(a) for (b) do-while (c) repeat-until (d) while
2. If statement is a —————statement
(a) One-way decision (b) Multi-way decision (c) Two way decision (d) Loop construct
3. ‗break‘ statement in a loop is used for
(a) Terminating the loop (b) De-allocating memory
(c) Terminating the program (d) Terminating the function
4. The keyword ―else‖ can be used with
(a) for statement (b) do.. while ( ) statement (c) if statement (d) switch ( ) statement
5. The two different ways to implement a multiway selection in C are
(a) Simple if and if-else (b) if-else and nested if-else
(c) else-if ladder and switch (d) None
6. The minimum number of time that a do-while loop executes
(a) 0 (b) 1 (c) infinitely (d) variable
7. The while loop is terminated when the conditional expression returns
(a) 1 (b) 2 (c) 3 (d) Zero
8. C provides as a convenient alternative to the traditional if-else for two way
selection.
(a) Conditional operator (b) Short hand assignment (c) Increment (d) None
9. The statement used to send back any value to the calling function is
(a) break (b) continue (c) exit (d) return
10. The statement is used to skip the remaining part of the statements in a loop and continue
with next iteration.
(a) break (b) goto (c) continue (d) exit
11. should be avoided as part of structured programming approach
(a) break (b) goto (c) continue (d) exit
12. The minimum number of times ―for‖ loop executes
(a) 2 (b) can‘t be predicted (c) 0 (d) 1
13. What will be output when you will execute following c
code? void main()

{ int fruit=1;
switch(fruit+2)
{
default:printf("apple");
case 4: printf(" banana");
case 5: printf(" orange");
case 8: printf(" grape");
}
}
(a) applebanana orange grape (b) grape (c) orange (d) banana orange grape
14. Which for loop has range of similar indexes of 'i' used in for (i = 0;i< n; i++)?
(a) for (i = n; i>0; i–) (b) for (i = n; i >= 0; i–)

Page 9
(c) for (i = n-1; i>0; i–) (d) for (i = n-1; i>-1; i–)
15. What will be output when you will execute following C
code? void main()
{
int check=2;
switch(check)
{
case 2: printf("1");
break;
case 3: printf(" 2");
break;
}
}
(a) 12 (b) 2 (c) 1 (d) Compilation error
16. Which one among the following is the correct syntax of for loop?
(a) for(i=0;i<n;i++); (b) for(i<n;i=0;i++);
(c) for(i=0;i<n:i++); (d) None
17. ‗for‘ loop in C program , if the condition is missing
(a) assumed to be present and taken to be false
(b) assumed to be present and taken to be true
(c) syntax error
(d) execution will be terminated abruptly
18. if c is initialized to 1, how many times following loop is executed
While((c>0)&&(c<60))
{ c++; }
(a) 60 (b) 59 (c) 61 (d)1
19. The library function exit () causes an exit from

(a) loop (b) block (c)function (d) None


20. break statement can use with
i) loop ii)switch iii) block
(a) only i,ii (b) only ii,iii (c) only i, iii (d) All
21. What is the output of this C code?
int main()
{
while ()
printf("In while loop ");
printf("After loop\n");
}
(a) In while loop after loop (b) After loop (c) Compile time error(d) Infinite loop
22. Which among the following is not checked in switch case
(a) character (b) integer (c) float (d) None

Page 10
23. What is the output of the following program
main()
{
int i;
for(i=1;i<5;i++)
{ if(i==3)
break;
Printf(―%d‖,i);
}
}
(a) 12345 (b)124 (c)1245 (d)12
24. What is the output of the following program
main()
{ int i;
for(i=1;i<5;i++)
{
if(i==3)
continue;
Printf(―%d‖,i);
}
}
(a) 12345 (b)124 (c)1245 (d)12
25. What are the entry controlled loops among the following
i. while ii. Do-while iii. For
(a) only i (b) only ii,iii (c) only iii (d) only i, iii
26. What is the output of the following program?
main()
{
int i=1;
while(i<=5)
printf(―%d‖,i);

}
(a) 12345 (b)1234 (c) 2345 (d) Leads to infinite loop
27. for(;;) can be terminated by
(a) break (b) exit(0) (c) return (d) All the above
28. What is the output of the following program
main()
{
for(i=1;i<=5;i++);
printf(―%d‖,i);
}
(a) 12345 (b)1234 (c) 6 (d) leads to infinite loop
29. What is the correct syntax of for loop
(a) for(i=0;i<n;i++){ } (b) for(i<n;i=0;i++){ }
(c) for(i=0;i<n:i++){} (d) for(i=0:i<n:i++){ }
30. Array is an example of which of the following?
(a) Derived types (b) Fundamental types (c) User-defined types (d) None
31. Which of the following is used to display a string on the screen?
Page 11
(a) %s (b) %c (c) %d (d) %f
32. What is the final value of x when the code int x; for(x=0; x<10; x++) {} is run?
(a) 10 (b) 9 (c) 0 (d) 1
33. Which of the following is exit controlled loop
(a) for (b) while (c) do-while (d) None
34. The default statement is executed when
(a) All the case statements are false (b) One of the case is true
(c) One of the case is false (d) None
35. How many times the following C code prints
―Hello‖ int main()
{
while (1)
printf("Hello ");
}
(a) One (b) zero (c) Infinite (d) Produce error
36. How many times the following C code prints
―Hello‖ int main()
{
do
{
printf("Hello ");
}while(0);
}
(a) One (b) zero (c) Infinite (d) Produce error

37. How many bytes the array price occupies. float price[10];
(a) 10 bytes (b) 4 bytes (c) 40 bytes (d) 20 bytes
38. Which of the following is syntactically correct?
(a) for(); (b) for(;); (c) for(,); (d) for(;;);
39. What is the output of the following code
main()
{
int a= 0,b = 20;
char x =1,y =10;
if(a,b,x,y)
printf("hello");
}
(a) Syntax error (b) hello (c) 10 (d) None
40. is used to terminate from the entire program
(a) return (b) break (c) exit (d) goto

Page 12
UNIT-3 : Arrays and Functions
1. Array is an example of which of the following?
(a) Derived types (b) fundamental types (c) user-defined types (d) None
2. Array elements are stored in
(a) Scattered memory locations (b) Sequential memory locations
(c) Direct memory locations (d) None
3. int a[10] will reserve how many locations in the memory?
(a) 10 (b) 9 (c) 11 (d) None of the above
4. Which one of the following is the correct syntax for initialization of one-dimensional arrays?
(a) int num[3]={0 0 0}; (b) int num[3]={0,0,0};
(c) int num[3]={0;0;0}; (d) int num[3]=0;
5. Under which of the following conditions, the size of the array need not be specified?
6. (a) When the compiler is smart (b) When initialization is a part of definition (c) Both
(d) None
7. Which of following is correct array declaration
A) int num(25); B) int array num[25]; C) int num[25]; D) num[25];
8. Array subscripts in ‗C‘ starts from
A) 0 B) compiler dependent C) 1 D) -1
9. Array elements are stored in
A) Column major order B) in diagonal order
C) Row major order D) either in row major or column major order
10. Which of the following statements is used to read a string of characters into the array words?
A) scanf(―%d‖, words); B) scanf(‖% \n‖, words);
C) scanf(“%s”, words); D) scanf(― %c‖, words);

11. A string constant is one dimensional array of characters terminated by a


A) Comma B) Full stop C) Semicolon D) Null character („\0‟)
12. Which of the following multi-dimensional array declaration is correct for realizing
a 2 X 3 matrix
(a) int m[2][3]; (b) int m[3][2]; (c) int m[3],m[2]; (d) None
13. Which of the following is the correct syntax for initialization of two-dimensional arrays?
(a) table[2][3]={0,0,0,1,1,1} (b) table[2][3]={{0,0,0,}{1,1,1}}
(c) table[2][3]={0,1},{0,1}{0,1} (d) None
14. What will be assigned for marks[3] and marks[4] in the following
initialization int marks[5]={30,45,80};
(a) 80 and garbage (b) garbage and garbage (c) 0 and 0 (d) None
15. Which of the following is correct initialization of string TITAN
(a) char name[ ]=‖TITAN\0‖ (b) char name[10]=‖TITAN\0‖
(c) char name[ ]=”TITAN” (d) char name[ 10]={―TITAN‖}
16. Which of the following initialization is wrong
(a) x[5]=15 (b) x[10.3]=30 (c) x[0]=20 (d) None
17. char ch[ ]={‗a‘,‘b‘,‘c‘,‘\0‘};
Page 13
int sum=ch[1]+ch[2];
What is the value of sum?
(a) 195 (b) 197 (c) ab (d) error
18. What happens if we initialize an array as int group[20]={0};
(a) Produce an error (b) Only 0th element is initialized with zero
(c) Every element is initialized with zero (d) None
19. To store a table of values which of the following is used
(a) One dimensional array (b) Two dimensional array
(c) Three dimensional array (d) None
20. int rank[3]={3,2,4,1,5};
(a) Compile time error (b) Initializes only 3 elements with first 3 values
(c) Initializes only 3 elements with last 3 values (d) Initialize all elements with zeros
21. How to refer an element in ith row jth column of a two dimensional array
(a) x[i,j] (b) x[i][j] (c) x[ij] (d) x[i]x[j]
22. A function can be called in a program
A. Only two times B. Only once C. Any number of times D. Only three times
23. When you pass an array as an argument to a function, what actually gets passed
A. Address of the array B. Values of the elements of the array
C. Number of elements of the array D. None
24. The statement used to send back any value to the calling function is
A. break B. continue C. exit D. return
25. The function sqrt( ) is part of header file.
A. conio.h B. stdio.h C. math.h D. iostream.h

26. A function can return only value


A. Zero B. One C. two D. three
27. Actual and formal parameters must agree in
A. Data types B. Number of arguments and Data types
C. Names and Data type D. None
28. Any function can be called from any other function. This statement is
A. True sometimes B. Neither true nor false C. False D. True
29. The header file that must be included at the beginning of a C program to use a library function
cos() is
A. stdlib.h B. conio.h C. dos.h D. math.h
30. function is said to be function calling itself.
A. Call by reference B. Call by value C. Recursive D. All above
31. void funct (void);
The above function declaration indicates A. it returns
a value and had arguments B. it returns nothing and had arguments
C. it returns a value and no arguments D. it returns nothing and no arguments
32. The parameters of the called function(function definition) are called A. Casual
parameters B. formal parameters C. usual parameters D. actual parameter
33. Recursion means
A. Function calling same function B. Function calling a function
C. Both D. None
34. A function is one that returns no value has return type A. Void
B. Integer C. Float D. Recursive
35. The parameters in a function call are
Page 14
A. Real parameters B. Formal parameters C. Actual parameters D. Dummy
parameters
36. Based on arguments and return types, functions are classified into
A. 1 type B. 2 types C. 3 types D. 4 types
37. Maximum number of arguments can be passed to a function are
A. 2 B. 3 C. 4 D. Any
38. The default parameter passing mechanism is
(a) Call by value (b) Call by reference (c) Call by name (d) None
39. Any C program
(a) Must contain at least one function (b) need not contain any function
(c) Needs input data (d) None
40. Call by reference is also known as
(a) Call by address or Call by location (b) Call by address or Call by value
(c) Call by value or Call by name (d) None
41. Determine output:
main()
{
int i=abc(10);
printf(―%d‖,--i);
}
int abc(int i)
{ return(i++); }

(a) 10 (b) 9 (c) 11 (d) None

UNIT-4 : POINTERS AND STRINGS

1. Address stored in pointer variable is of type


A. Integer B.character C. Float D.Double
2. Pointer variable is declared using preceding with sign
A. % B.& C.^ D.*
3. * is called as
A. Value at pointer B.Address operator C. Scope resolution operator D.None
4. Multiple indirection operator is
A.--> B.& C.* D.**
5. Prior to using a pointer
A. it should be declared B. it should be initialized
C. it should be declared and initialized D.None
6. int *p1,*p2; find out valid statement
A. p1-p2 B.p1*p2 C.p1+p2 D.p1/p2
7. int k[3]={1,2,3};int *p;
one of the following statement is equal to p=k is
A. p=&k[0] B. p=&k[1] C.p=&k[2] D. None
8. A pointer to pointer points to the address of a
A. Structure B.Union C.Array D.Pointer
9. Size of the pointer depends upon
A. Processor B. RAM C. Hard disk D.All
10. What is the size of the double pointer? Ex: double *ptr; in 16 bit processor
A. 4 bytes B. 2 bytes C. 10 bytes D. 8 bytes
Page 15
11. Which is the correct way to declare a pointer?
A. int *ptr; B.int * ptr; C. int* ptr; D. All
12. Generally , functions are classified into
A. 1 type B. 2 types C. 3 types D. 4 types
13. How to combine the following two statements into one?
char *p;
p=(char*)malloc(100);
(a) char p=*malloc(100); (b) char *p=(char)malloc(100);
(c) char *p=(char*)malloc(100); (d) char *p=(char*)(malloc*)(100);
14. A pointer is
(a) A keyword used to create variables
(b) A variable that stores address of an instruction
(c) A variable that stores address of other variable
(d) All of the above
15. The operator used to get value at address stored in a pointer variable is
(a)* (b) & (c) && (d) ||
16. What would be the equivalent pointer expression for referring the array element a[i][j][k][l]
(a) ((((a+i)+j)+k)+l) (b) *(*(*(*(a+i)+j)+k)+l)
(c) (((a+i)+j)+k+l) (d) ((a+i)+j+k+l)
17. If the size of integer is 4 bytes, what will be the output of the program?

int main()
{
int arr[]={12,13,14,15,16};
printf(―%d, %d, %d\n‖,sizeof(arr),sizeof(*arr),sizeof(arr[0]));
return 0;
}
a) 10, 2, 4 (b) 20, 4, 4 (c) 16, 2, 2 (d) 20, 2, 2
18. Which of the following statements correct about k used in the below statement?
char ****k;
(a) k is a pointer to a pointer to a pointer to a char
(b) k is a pointer to a pointer to a pointer to a pointer to a char
(c) k is a pointer to a char pointer
(d) k is a pointer to a pointer to a char
19. What will be the output?
main()
{
char *p;
printf(―%d %d‖,sizeof(*p),sizeof(p));
}
(a) 1 1 (b) 1 2 (c) 2 1 (d) 2 2
20. What will be the output?
main()
{
printf(―%d %d‖,sizeof(int *),sizeof(int **));
}
(b) 4 4 (b) 0 2 (c) 2 2 (d) 2 4

Page 16
21. Which one of the following is a string constant
(a) ‗3‘ (b) “hello” (c) 30 (d) None
22. Which of the following is used to display a string on the screen?
(a) %s (b) %c (c) %d (d) %f
23. Which of the following is used to determine the length of a string?
(a) strlen (b) strcmp (c) strcpy (d) strcat
24. Which of the following is the correct syntax for copying a string S1 into S2?
(a) strcpy(S2,S1); (b) strcpy(S1,S2); (c) strcmp(S1.S2); (d) strcmp(S2,S1);
25. The function strcat(S2,S1) appends to
(a) S1,S2 (b) S2,S1 (c) S2,S2 (d) S1,S1
26. Which of the following is used to read a string
(a) getchar() (b) gets() (c) getstr() (d) getch()
27. Which function is used to search for a substring in a string?
(a) strchr (b) strstr (c) strspn (d) strcpy
28. How many arguments that the strcmp() function can take?
(a) 2 (b) 3 (c) 4 (d) 0

29. What will be the result of the following character arithmetic expression?
X=‘A‘-2
(a) 63 (b) 64 (c) 65 (d) 66
30. Which of the following header file is required for performing string operations
(a) stdio.h (b) conio.h (c) string.h (d) ctype.h
31. Which function is used to count and return the number of characters in a given string
A) strcmp() B) strlen() C) strrev() D) strcat()
32. If the two strings are identical, then strcmp() returns
(a) -1 (b) 1 (c) 0 (d) yes
33. Which of the following function is more appropriate for reading in a multi-word string?
(a) printf() (b) scanf() (c) gets() (d) puts()
34. Which of the following not belongs to String functions?
A. strcmp() B. strcat() C.strlen() D. isdigit()
35. Which function is used to reverse the string?
(a) reverse() (b) strrev() (c) rev() (d) None
36. What will be the output of the
program? void main()
{
char str1[20] = "Hello", str2[20] = " World";
printf("%sn", strcpy(str2, strcat(str1, str2)));
}
(a) HelloWorld (b) World (c) WorldHello (d) Hello
37. What will be the output of the
program? void main()
{
char str[ ] = "online\0exam‖;

Page 17
printf(―%s‖,str);
}
(a) online\0exam (b) online (c) onlineexam (d) exam
38. String concatenation means
(a) Combining two strings (b) Extracting a substring out of a string
(c) Comparing two strings (d) partitioning the string into two strings
39. Which function locates the first occurrence of the character in a given string
(a) strstr() (b) strchr() (c) strrchr() (d) strrstr()
40. What is the output of the following code
main()
{ char str1[ ]=‖mahendra singh‖,str2[ ]=‖dhoni captain‖;
strncat(str1,str2,5);
printf(―\n %s‖,str1);
}

(a) mahendra singhdhoni (b) mahendra singhdhoni captain


(c) mahendra singh (d) None

UNIT-5 : STRUCTURES AND FILE MANAGEMENT IN C

1. Which of the following is true for definition of a structure


A) Items of the same data type B) Items of the different data type
C)Integers with user defined names D) List of Strings
2. The keyword used to define a structure is
A) stru B) struct C) structure D) STRUC
3. The operator used to access the structure member is
A) * B) & C) . D) |
4. The operator exclusively used with pointer to structure is
A) . B) [ ] C)  D) *
5. Which of the following is correct for a Structure definition?
A) Scalar data type B) Derived data type C) Enumerated type D) Null Type
6. When accessing a structure member, the identifier to the left of the dot operator is
A) A structure member B) The structure tag
C) A structure variable D) The keyword struct
7. When a structure is an element to another structure, it is called as a
A) Union B) Structure within a structure
C) Pointer to Structure D) Array of Structures
8. A structure is one which contains a pointer to its own type.
A) Self-referential B) Nested C) Array D) Pointer
9. Consider the following declaration of
Union union st

char c;
int x;
float y;
Page 18
}p;
How many bytes are allocated to union variable p?
A) 7 bytes B) 4 bytes C) 1 byte D) 2 bytes
10. In C language the Bit fields are used to
A) Save time B) Save memory
C) Change order of allocation of memory D) Save Program
11. The size of structure and union is same when they contain
A) Single member B) any number of members
C) Arrays of different types D) Pointers to different types
12. The operator used to find the size of any variable
A) sizeof() B) sizof() C) size of() D) size()
13. The operator  is same as the combination of the operators

A) * and . B) &and . C) * and & D) & and |


14. Union can store number of values at a time
A) All its members B) Only 1 C) 2 D) Cannot hold value
15. ‘C‘ provides a facility for user defined data type using concept
A) Array B) Function C) Pointer D) Structure
16. In the expression p value, p is a
A) Address B) Pointer C) Structure D) Header
17. In C language the expression(*ps).x is equal to
A) ps->x B) x->ps C) ps->*x D) None
18. Which of the following is a list of named integer constants?
A) typedef B)enumeration C)structure D) union
19. Which of the following is a memory location that is shared by two or more different types of
variables?
A) typedef B)enumeration C)structure D) union
20. argv[0] points to
A) Program name B) First argument C) Both D) None
21. Which of the following is true about a File in C?
A) It is a data type B) A region of storage in Disk
C) A variable D) Pointer
22. If the function fopen() fails, it returns
A) -1 B) 1 C) NULL D) Address
23. The function used for writing a character to a file is
A) putc() B) fputs() C) fputchar() D) putw()
24. The function used for reading a formatted input data from a file is
A) getchar() B) fscanf() C) fgetc() D)fgets()
25. function set the pointer position anywhere in the data file
A) fseek() B) feof() C) ftell() D) rewind()
26. The mode used for opening an existing file for reading a binary stream is
A) r B) rb C) wb D) w
27. The mode used for opening an existing file for reading & writing a text stream is
A. r+ B) r C) w+ D) w
28. In C, file processing function fseek()
A) needs 2 arguments B)makes rewind function unnecessary
C)takes 3 arguments D)none of the above
29. rewind() function takes number of arguments.
Page 19
A) 1 B) 2 C) 3 D) 0
30. fseek(fptr,0,0) is equivalent to
A) ftell B) rewind C)a & b D) none of the above
31. Which among the following is odd one out?
A) printf B) fprintf C) putchar D) scanf
32. The value of EOF is
A) -1 B) 0 C) 1 D) 10
33. Which of the following fopen statements are illegal?
A) fp = fopen(―abc.txt‖, ―r‖);
B) fp = fopen(―/home/user1/abc.txt‖, ―w‖);

C) fp = fopen(―abc‖, ―w‖);
D) None of the mentioned
34. What does the following segment of code
do fprintf(fp, ―Copying!‖);
A) It writes “Copying!” into the file pointed by fp
B) It reads ―Copying!‖ from the file and prints on display
C) It writes as well as reads ―Copying!‖ to and from the file and prints it
D) None of the mentioned
35. FILE reserved word is
A) A structure tag declared in stdio.h
B) One of the basic datatypes in c
C) Pointer to the structure defined in stdio.h
D) It is a type name defined in stdio.h
36. Which of the following causes an error
A) Trying to read a file that doesn‘t exist
B) Inability to write data in a file.
C) Failure to allocate memory with the help of malloc
D) All of the menioned
37. fputs adds newline character
A) true B) false
C) Depends on the standard D) Undefined behavior
38. In fseek() function , the position value 2 indicates
A) Beginning of file B) End of file C) Current position D) All
39. Which of the following are C preprocessors?
A) #ifdef B) #define C) #endif D) All
40. In fseek() function , the position value 1 indicates
A) Beginning of file B) End of file C) Current position D) All

Page 20

You might also like