Choose the correct answers:
1. C was developed at:
a) Microsoft b) Oracle Corporation c) IBM d) Bell Labs
2. A variable declared as 'char' in C is provided ___ bytes of memory.
a) 4 b) 2 c) 1 d) 8
3. A variable declared as pointer in C is allocated ___ bytes of memory.
a) 2 b) 1 c) 4 d) 8
4. ______ is an unconditional branching statement in C.
a) goto b) if c) switch b) while
5. The following is an exit-restricted loop.
a) While b) do-while c) for d) None of these
6. The following is a counter controlled loop.
a) while b) do-while c) for d) None of these
7. ______ statement is used to terminate a block permanently.
a) break b) continue c) jump d) exit()
8. Find the odd one.
a) goto b) if c) continue d) break
9. The founder of C is:
a) James Gosling b) John Backus c) Oreilly d) Dennis Ritchie
10. What is the output of the following statement?
void main()
{
printf("%d",printf("welcome"));
}
a) welcome7 b) welcome1 c) 7 d) Error
11. What is the output of the following statement?
void main()
{
printf("%d",scanf("%d%d",&a,&b));
}
a) 6 b) 4 c) 8 d) 2
12. The following function reads a character as input,but does not echo it.
a) getch() b) getche() c) getchar() d) scanf()
13. The return type of getch() is :
a) char b) string c) int d) none of these
14. What is the equalent of the above statement?
i = i+1;
a) ++i; b) i+=1; c) Both a and b d) Neither a nor b
15. Which of the following is not a bitwise operator.
a) & b) ! c) ^ d) |
16. Which of the following is not an operator.
a) $ b) % c) * d) &
17. Which of the following is not a keyword?
a) return b) exit c) if d) goto
18. Which of the following statements are true?
a) goto is an unconditional branching statement.
b) In do-while loop, statements are executed atleast once.
c) Functions are modules in C
d) All of the above
19. What is the output of the following program?
void main()
{
int a = 10,b = 7;
printf("%d",a ^ b);
}
a) 15 b) 11 c) 13 d) 16
20. What is the output of the following code?
#include<stdio.h>
#define PI 3.1428
#define PI 6.2856
void main()
{
printf("%f",PI);
}
a) 3.1428 b) 6.2856 c) Error d) 1
21) What is the output of following code?
if(5>2);
printf("Hi");
else
printf("Bye");
a) Hi b) Bye c) HiBye d) Error
22) What is the output of following code?
if(6%2 == 0)
printf("Even");
else;
printf("Odd");
a) Even b) Odd c) EvenOdd d) Error
23) What is the output of following code?
i = 1;
while(i <= 10);
{
printf("%d",i);
i++;
}
a) 1 2 3 4 5 6 7 8 9 10 b) 11 c) 1 d) Infinite Loop
24) What is the output of following code?
for(i=1;i<=10;i++);
printf("%d",i);
a) 1 2 3 4 5 6 7 8 9 10 b) 11 c) 1 d) Infinite Loop
25) C Language was derived from :
a) BCPL b) Algol c) Assembly language d) CPL
26) What is the output of following code?
void main()
{
int _ = 100;
printf("%d",_);
}
a) 199 b) 100 c) 101 d) Error
27) Which one of the declarations is correct?
a) _1 b) _a c) a_ d) All of the Above
28) What is the output of following code?
void main()
{
char ch = 65.317623;
printf("%c",a);
}
a) 65 b) A c) a d) Error
29) What is the output of the following code?
void main()
{
char ch[] = "welcome";
printf("%d",sizeof(ch));
}
a) 2 b) 8 c) 7 d) 1
30) Which of the following is a macro in C?
a) getchar() b) getch() c) scanf() d) getche()
31) getchar() is used to read input from :
a) keyboard b) file c) Both a and b d) None of these
32) Which is not a primtive datatype in C?
a) int b) void c) long d) double
33) To store 5 integer values in continuous memory locations:
a) Store them under an integer array variable.
b) Declare 5 variables of integer type.
c) Both a and b are valid
d) None of these
34) The following function is used to for dynamic memory deallocation.
a) free() b) destroy() c) release() d) deallocate()
35) The tranlator of C language is :
a) assembler b) compiler c) Interpreter d) Debugger
36) What is the output of the following code?
int a = 5;
while(a<=5)
{
if(a == 5)
break;
printf("%d",a);
++a;
}
a) 1 2 3 4 b) 1 2 3 4 5 c) Error d) Infinite loop
37) Which of the following is not assignment operator?
a) += b) %= c) != d) <<=
38) Which of the following is supported by C?
a) call-by-value b) call-by-address c) call-by-reference d) both a and b
40) Parameters at the called function are called :
a) actual parameters b) function parameters c)formal parameters d) default
parameters
41) Which of the following is a valid declaration?
a) int main(){} b) float main(){} c) char* main(){} d) All of the above
42) In the following datatypes, all the members share common memory space?
a) arrays b) unions c) structures s) enum
43) Escape sequence for bell character is :
a) \a b) \b c) \l d) \e
44) Which of the following statements is invalid in C:
a) printf("%d",5%3.0);
b) printf("%d",5.0%3);
c) printf("%d",5.0%3.0);
d) All of the Above
45) The format identifier "%i" is used for __________ datatype.
a) char b) float c) int d) double
46) What is the output of following code:
void main()
{
unsigned int a = -125;
printf("%d",a);
}
a) -125 b) 0 c) Garbage value d) Error
47) What is the output of following code:
void main()
{
if(-120)
printf("Hi");
else
printf("Bye");
}
a) -125 b) 0 c) Garbage value d) Error
48) Identify which one is warning message in C?
a) 'a' is assigned a value that is never used
b) unreachable code
c) condition is always true
d) All of the above
49) What is the output of the following code?
void main()
{
float a = 100;
clrscr();
printf("%e",a);
getch();
}
a) 100e+00 b) 1.000000e02 c) 0.000000e03 d) None of the above
50) To get the value at address stored by pointer variable, the following
operator is used:
a) & b) && c) * d) **
51) How many bytes are occupied by huge pointer?
a) 4 b) 8 c) 2 d) 12
52) What is the output of following code?
void main()
{
int a[] = {10,20,30,40,50};
printf("%d",0[a]);
}
a) 10 b) 50 c) Garbage d) Error
53) What is the output of following code?
void main()
{
int a[2][2] = {10,20,30,40};
printf("%d",a[1][0]);
}
a) 10 b) 30 c) 20 d) Garbage
54) Which is of the following statements is not valid?
a) char ch[] = {'w','e','l','c','o','m','e'};
b) char ch[] = "welcome";
c) char *ch = "welcome";
d) char *ch[] = "welcome";
55) What is the output of following code?
void main()
{
int a[5] = {10};
printf("%d",a[3]);
}
a) 0 b) 10 c) 3 d) Error
56) Which one of the following functions compares string and ignores case?
a) strcmp() b) strcmpi() c) stricmp() d) Both b and c
57) What is the return value of the following statement:
strcmp("hello","HELLO");
a) 0 b) -32 c) 32 d) 5
58) What is the output of the following code:
void main()
{
char *s1 = "hello";
char s2[] = "hello";
if(strcmp(s1,s2) == 0))
printf("Equal");
else
printf("Not Equal");
}
a) Equal b) Not Equal c) Error d) None of these
59) What is the library used to find the last occurence of a character in a
string:
a) strnstr() b) laststr() c) strrchr() d) strstr()
60) What is the output of the following code?
void main()
{
int i=1;
printf("APEC");
if(i==5) exit(0);
main();
}
a) APEC printed 5 times
b) Infinite Loop
c) Error
d) Naresh IT
61) Function calling itself is called:
a) Iteration b) Recursion c) Excursion b) Loop
62) The default return type of a function is :
a) int b) void c) double d) string
63) Which of the following is not a valid declaration?
a) #include"stdio.h"
b) #include<stdio.h>
c) #include'stdio.h'
d) All are valid
64) Which of the following statements are valid for the code given below:
void add(int,int){}
a) add(10,20); b) add(10) c)add(10,20,30) d) All of the above
65) What is the output of the following code?
void main()
{
printf("hello","world");
}
a) helloworld b) hello c) world d) Error
66) Which of the following keyword is not a storage class in C?
a) extern b) external c) auto d) static
67) What is the output of the following code?
int a;
void main()
{
printf("%d",a);
}
a) 0 b) 100 c) -1 d) 2
68) what is the output of the following code?
void main()
{
int a = 100;
printf("%d",*&a);
}
a) address of a b) garbage c) Error d) 100
69) Consider the following declaration:
union Sample
{
int a,b,c;
}s;
-> How much memory is created for variable 's'?
a) 6 bytes b) 4 bytes c) 12 bytes d) 2 bytes
70) Consider the following declaration:
struct Sample
{
int rollno;
char name[20],course[20];
}s;
-> How much memory is created for variable 's'?
a) 4 bytes b) 32 bytes c) 42 bytes d) 82 bytes
71) In which header file, the identifier FILE is declared?
a) stdlib.h b) stdio.h c) ctype.h d) conio.h
72) The ASCII value of '0' is :
a) 28 b) 38 c) 48 d) 58
73) Which is of the following is not a valid file open modes?
a) b b) a c) r d) None of the above
74) What is the output of the following statement?
sleep(5);
a) blocks a program for 5 seconds
b) blocks a program for 5 milliseconds
c) blocks a program for 5 nanoseconds
d) blocks a program for 5 minutes
75) Which one of the following makes the program run faster?
a) function
b) macro
c) Both
d) loop
76) Which storage class remembers the value of a variable during the next
call?
a) auto b) extern c) static d) register
77) Which of the following is an invalid pre-processor directive.
a) #if b) #return c) #pragma d) #define
78) What is argc in the following code?
a) arguments conversion
b) arguments vector
c) arguments array
d) arguments count
79) Which of the following is created when a 'C' program is run?
a) filename.obj b) filename.exe c) filename.bak d) All of these
80) Which one of the following syntax is valid for drawing a line?
a) void far line(int,int,int,int);
b) int far line(int,int,int,int);
c) void far line(int,int);
d) int far line(int,int);
Answer the questions given below.
1. Explain bitwise operators.
2. Write a program in C to print the mathematical table of a given number.
Eg: if n = 5, then output will be:
5 X 1 = 5
5 X 2 = 10
...
5 X 10 = 50
3. Write the logic to display the trace of a given matrix
4. Explain the importance of functions.
5. Write the logic for reversing a string without using strrev() function.
--- ALL THE BEST ---