MIT Aurangabad FE Computer Engineering Unit 1: Introduction to C 1. The symbol # is called a. Header file c. include b. Preprocessor d. semicolon 2. The size of integer number is limited to a. -32768 to +32767 c. 3.4e-38 to 3.4e+38 b. -128 to +127 d. none of these 3. Characters usually stored in----byte a.1 byte c. 2 byte b. 4 byte d. none of these 4. A character constant is a single alphabet, a single digit or a single special symbol enclosed in? a. Single quotes c. Floating b. Double quotes d. None of these 5. Comments are. A. Executable statements C. Assignment statements B. Non executable statements D. Input/Output statements 6. Blank spaces are allowed while declaring variable. a. True b. False 7. Which of the following is legal variable name? abc 1, stud_1, view1-a, ans2^3 a. abc 1 b. stud_1 b. view1-a d. ans2^3 8. In C language reading data from keyboard? a. printf() c. scanf() b. int d. main() 9. The real constants could be written in a. Fractional form only c. ASCII form only b. Exponential form d. Both Fractional and Exponential form 10. Which of the following is not valid data type? a. int c. float b. char d. main 11. which of the following is odd one out a. + c. - b. & d. % 12. In a C language && is a?
a. Relational operator c. Logical operator b. Arithmetic operators d. None of these 13. Which of the following is not relational Operator a. >= c. * b. == d. < 14. Which of the following is not Logical Operator a. c. < b. && d.! 15. Values of data items of types int, float, char are displayed by writing in printf statement in C A. %d, %f, %s C. %d, %d, %c B. %f, %d, %c D. %d, %f, %c 16. if a=3, b=0 and c=-4, what is the value of the expression a && b c A. 1 C. 3 B. 2 D. 4 17. Basic symbols of flow chart are. A. Start and End C. Input Output B. Processing, Decision D. All of above 18. Diamond shape in flow chart denotes. A. Start C. End B. Decision D. Input - Output task 19. Which of the following is used for representing a Conditional Statement in a Flow chart A. Parallelogram C. Trapezoid B. Rhombus D. Rectangle 20. Amongst the flowchart symbols, which of the following is an Auxiliary symbol? A. Sequence C. Decision B. Connector D. Repetition 1. is used to write the algorithms. A. Computer Language C C. Computer Language C++ B. Any Programming Language D. English Language 21. Algorithm halts in A. Finite time C. Logarithmic time B. Infinite time D. Exponential time 22. C programs are converted into machine language with the help of A. An Editor C. An Operating System B. A Compiler D. An interpreter 23. Which are the types of errors that can occur in a computer program? A. Logical errors C. Both A and B B. Syntax errors D. None of these 24. What is output of following program?
#include<stdio.h> #include<conio.h> void main() { int a=7,b=2,c,d; c=a%b; d=a/b; printf( c=%d \n,c); printf( d=%d\n,d); getch(); } a. c=3.5, d=1 c. c=1, d=3 b. c=1, d=3.500000 d. none of these 25. What is the following program doing? main () { int d = 1; do printf( %d\n, d++); while (d < = 9);} (A) Adding 9 integers (B) Adding integers from 1 to 9 (C) Displaying integers from 1 to 9 (D) None of these
Unit 5: Data Input Output, Decision Control and Loop Control Structure: 1. The output of the code below is #include <stdio.h> void main() { int x = 5; if (x < 1) printf("hello"); if (x == 5) printf("hi"); else printf("no"); } a) hi b) hello c) no d) None of the mentioned Answer: (a) 2. The output of the code below is 1. #include <stdio.h> 2. int x; 3. void main() 4. { 5. if (x) 6. printf("hi"); 7. else 8. printf("how are u"); 9. } a) hi b) how are you c) Compile time error d) None of the mentioned Answer: (b) 3. Comment on the following code below 1. #include <stdio.h> 2. void main() 3. { 4. int x = 5; 5. if (true); 6. printf("hello"); 7. } a) It will display hello b) It will throw an error
c) Nothing will be displayed d) Compiler dependent Answer: (b) 4. The output of the code below is 1. #include <stdio.h> 2. void main() 3. { 4. int x = 0; 5. if (x == 0) 6. printf("hi"); 7. else 8. printf("how are u"); 9. printf("hello"); 10. } a) Hi c) hello b) how are you d) hihello Answer: (d) 5. The output of the code below is 1. #include <stdio.h> 2. void main() 3. { 4. int x = 5; 5. if (x < 1); 6. printf("hello"); 7. 8. } a) Nothing b) Run time error c) Hello d) Varies Answer: (c) 6. What will be the output of the sample code shown above? void main() { int a=12,b=12; if(a==b) printf( a and b are equal ); } a) 12 c) compile time error b) run time error d) a and b are equal Answer: (d) 7. The output of the code below is(when 1 is entered)
1. #include <stdio.h> 2. void main() 3. { 4. char *ch; 5. printf("enter a value btw 1 to 3:"); 6. scanf("%s", ch); 7. switch (ch) 8. { 9. case "1": 10. printf("1"); 11. break; 12. case "2": 13. printf("2"); 14. break; 15. } 16. } a) 1 b) 2 c) Compile time error d) No Compile time error Answer: (c) 8) What is the output of code: 1. #include <stdio.h> 2. int main() 3. { 4. int x = 1; 5. if (x > 0) 6. printf("inside if\n"); 7. else if (x > 0) 8. printf("inside elseif\n"); 9. } a) inside if b) inside elseif c) inside if inside elseif d) Compile time error Answer: (a) 9) What is the output of this C code? a) True c) false b) Compile time error d) Undefined behavior Answer: (c)
10) What is the output of this C code? 1. #include <stdio.h> 2. int main() 3. { 4. int x = 0; 5. if (x == 1) 6. { 7. if (x == 0) 8. printf("inside if\n"); 9. else 10. printf("inside else if\n"); 11. } 12. else 13. printf("inside else\n"); 14. } a) inside if b) inside else if c) inside else d) Compile time error Answer: (c) 11) What is the output of this C code? 1. #include <stdio.h> 2. int main() 3. { 4. if (printf("%d", printf("))) 5. printf("we are Happy"); 6. else if (printf("1")) 7. printf("we are Sad"); 8. } a) 0We are Happy b) 1We are Happy c) 1We are Sad d) Compile time error Answer: (d) 12) What is the output of this C code 1. #include <stdio.h> 2. const int a = 1, b = 2; 3. int main() 4. { 5. int x = 1; 6. switch (x) 7. { 8. case a: 9. printf("yes "); 10. case b: 11. printf("no\n");
12. break; 13. } 14. } a) yes no b) yes c) no d) Compile time error Answer: (d) 13) The Correct syntax for the ` for ` loop in ` C ` is. A. for(i=1; i<=5 ; i++) C. for(i=1, i<=5, i++) B. for(i=1: i<=5: i++) D. None of the above Answer: (a) 14) Comment on the output of this C code? main() { void fun(); int i=1; while(i<=5) { printf(\"%d\",i); if(i>2) goto here; } } a) Syntax Error : Undefined label 'here' b) No Error, Program run c) 1111 d) 11 Answer: (a) 15) In Do-While loop, statements are executed a. At least once c. both a & b b. More than once d. None of them Answer: (c) 16) Which statement is used to restart the loop skipping rest of the statements in loop? a. For statement c. Continue statement b. goto statement d. break statement Answer: (c) 17) Do-while loop is a. Entry controlled c. Break controlled b. Exit controlled d. None of these Answer: (b) 18) In do-while loop, loop condition is checked at the.
a. Beginning of loop c. End of program b. End of loop d. Start of program Answer: (b) 19) In following statement which is not a conditional statement a. break c. If.else b. Do..while d. All of them c. Answer: (a) 20) What is Nested if else statements means a. If else within if else c. only if then if..else b. Continuous if..else d. none of these Answer: (a) 21) The control statement that allows us to make a decision from number of choices is called as. A. if-else C. switch B. for D. do-while Answer: (c) 22) A case in ` switch ` statement is terminated by if control should not fall through the successive cases. A. Break C. ; B. break; D. break Answer: (b) 23) Goto statement is used for. A. Conditional jump only C. both conditional and unconditional jumps B. Unconditional jump only D. None of the above Answer: (b) 24) The Correct syntax for the ` for ` loop in ` C ` is. i. for(i=1; i<=5 ; i++) c. for(i=1, i<=5, i++) ii. for(i=1: i<=5: i++) d. None of the above Answer: (a) 25) If ` a ` is a variable defined in a ` C ` program then &a denotes the. A. content of a C. Both A and B B. address of a D. none of these Answer: (b) 26) getchar() function is used for a. Writing a Character c. Reading a Character b. Explaining a Character d. Printing a Character Answer: (c)
Unit 6: Arrays and Functions: Q.1 A function that calls itself is known as a) inline function b) nested function c) Overloaded function d) recursive function Answer: (d) Q.2 The return type of a function that does not have any return type is declared as a) long b) double c) int d) void Answer:( d) Q.3 Parameters passed to a function are separated with a) comma b) semicolon c) colon d) none of the above Answer: (a) Q.4 According to the following statements, select the best suitable statement int x=5,y=3,z; a=add(x,y) a) The function add is called by passing the values b) The function add is called by passing reference c) Both a& b above d )None of the above Answer=(a) Q.5 According to the following code, select the best suitable statement
int x=5,y=3,z; A=add(&x,&y) Answer:(b) a) The function add is called by passing the values b) The function add is called by passing reference c) Both a& b above d) None of the above Q.6 The return type of the function cannot be a)void b) main c) int Answer:(b) d) Float Q.7 Every program must have at least function(s). a) 1 b) 2 c) 3 Answer:(a) d) None of the above Q.8 In the function definition, the argument list must always be accompanied with the corresponding data type Answer:(a) a) True b) False Q.9 The value returned by a function is returned to the a) main function b) operating system c) caller function d) called function
Answer:(c) Q.10 The function that does not return any data is called as fuction a) void b) recursive c) int d) Float Answer:(a) Q.11 The parameters passed by the caller function are called as the parameters a) actual b) formal c) informal d) reference Answer:(a) Q.12 The parameters received by the called function are called as the parameters a) actual b) formal c) informal d) reference Answer:(b) Q.13 The number of actual and formal parameters a) can be different b) should not be the same c) should be same d) cannot be same Answer:(c) Q.14 The data type of actual and formal parameters a) can be different
Answer:(c) b) should not be the same c) should be same d) cannot be same Q.15 The prototype of a function can be written Answer:(c) a) only outside a function b) only inside a fuction c) both inside and outside a function d) only with prefix # Q.16 The prototype of a function should contain the data type of the parameters to be passed to that function Answer:(a) a) True b) False Q.17 The return type of the function and that of the variable accepting the returned value can be different Answer:(b) a) True b) False Q.18 The actual and formal parameters are Answer:(d) a) same variables with different names b) different variables with same memory locations c) different memory locations with same variable names d) different memory locations s with same or different names Q.19 Array is a collection of mixed data types a) True
b) False Answer:(b) Q.20 The starting index of an array is always a) 0 b) 1 c) 2 d) None of the above Answer:(a) Q.21 The index of the last element of an array of n elements will be a) n+1 b) n c) n-1 d)none of the above Answer:(c) Q.22 The memory space allocated to the array declared as: int a[10]; Will be bytes a) 10 b) 20 c) 30 d) 40 Answer:(b) Q.23 The memory space allocated to the array declared as: float a[10]; Will be bytes a)10 b) 20 c) 30 d) 40 Answer:(d) Q.24 To access an element of an array the operator is used
a) comma b) semicolon c) & Answer:(d) d) square brackets [] Q.25 The 10 th element of an array can be accessed as Answer:(b) a) a[8] b) a[9] c) a[10] d) a[11] Q.26 What 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 Answer:(c) 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. Q.27 Which of the following statements are correct about an array? 1:The array int num[26] can store 26 elements 2:The expression num[1] designates the very first element in the array 3: It is necessary to initialize the array at the time of declaration. 4: All of the above a) 1 b) 2 c) 3 d) 4 Answer:(a) Q.28. Maximum number of elements in the array declaration int a[5][8] is Answer:(D) A. 28 B. 32 C. 35 D. 40
Q.29 Array subscripts in C always start at a )-1 b) 1 c) 0 Answer:(c) d) Value provided by user Q.30. 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 Answer:(c) Q.31 An array elements are stored in memory locations Answer: (a) a) sequential b) random c) sequential and random d) None of the above Q.32 What is the maximum no. of dimensions an array in c may have a)2 b)8 c)20 d)50 Answer: (e) e)theoretically no limitation. The only practical limits are memory size and compilers.