Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Theory Examination Question Paper

Pre-DAC
Module Name – Prog. In C
Duration : 45Min Max. Marks : 30

1. What is the output of the following program: c) It only provides code evaluation. You must use the
main() linker to assemble and link program.
{ d) It interprets files at runtime
int c= -- 2;
printf(“c=%d”,c); 6. Identify the unconditional control structure-
} a) do-while
a) c=1 b) switch-case
b) c=2 c) goto
c) compiler error d) if
d) linker error
7. int I; I=2; I++; if(I=4) { printf(“I=4”); } else
2. What is a variable decleration? { printf(“I=3”); } what is the output of the
a) The assignment of properties to a variable program?
b) The assignment of memory space to a variable a) I=4
c) The assignment of properties and memory space to b) I=3
a variable c) Unpredictable
d) The assignment of properties and identification to a d) None
variable
8. main() { int i=0, j=0 ; for(j=1;j<10;j++) {i=i+1;}}
3. What is the output of the following program: a) 1
main() b) 3
{ c) 9
unsigned int i; d) 10
for( i=1; i>-2;i--)
printf(“ C Aptitude”); 9. int x=2,y=2, z=1;
} what is the value of x after the following statement?
a) C Aptitude If ( x=y%2) z+=10; else z+=20;
b) No output a) 0
c) Compiler error b) 2
d) Linker error c) 1
d) none
4. Consider the following code:
f(unsigned int x, unsigned int y) 10. Pointer variable may be assigned
{ a) an address value represented in hexadecimal
while(x!=y) b) an address value represented in octal
{ c) the address of another variable
if(x>y) x=x-y; d) an address value represented in binary
else y=y-x;}
printf(“%d”,x); 11. What is the output of the program?
} main()
what does the above code do? {
a) Compute the GCD(greatest common divisor) of int rows=3 , colums=4;
two number int a[rows][colums]={1,2,3,4,5,6,7,8,9,10,11,12};
b) Divide the largest number by the smallest number int i,j,k; for( i=0; i<rows; i++) for ( j=0; j<colums; j++)
c) Compute the LCM of two number if ( a[i][j] <k) k=a[i][j]; printf(“%d\n”,k);
d) None of the above }

5. What does invoking the C compiler accomplish? a) syntax error


a) It links together object files. b) runtime error
b) It creates machine code. c) 1
d) none of these

TCM / F / 11 Rev. –00 Page 1 of 3


int i=5,j=0;
12. char base[5]= “a”; const char *ptr; while(i-- && ++ j)
given the above, which of the following statement is {
legal? printf(“\n%d\t%d\n”, i , j );
a) ptr= base; }
b) *ptr=”a”; }
c) *ptr=base; a) 5 1,4 2,3 3,2 3,1 4
d) ptr=’a’; b) 4 0,3 0,2 0,1 0,0 0
c) 4 1,3 2,2 3,1 4,0 5
13. Identify the correct statement: d) None of these
a) A function can be defined more than once in a
program. 19. void main(){
b) Function definition cannot appear in any order. clrscr();
c) Function cannot be distributed in many files. printf(“%d”,sizeof(3.8));
d) Once function cannot be defined within another getch();
function definition. }
Which of the following is true?
14. Parameters are used a) 4
a) to return values from the called function b) 8
b) to send values from the calling function c) 10
c) options a and b d) Compiler error
d) to specify the data type of the return value e) None of these

15. What is the output of the following code: 20. void main(){
#include<stdio.h> int a=5;{
main() a++;
{ }
int a=5; clrscr();
printf(“%d%d%d%d%d”,a++,a--,++a,--a,a); printf("%d",a);
} getch();
a) 55665 }
b) 56655 Which of the following is true?
c) 45654 a) 5
d) 45545 b) 6
c) 7
16. What is the output of the following code? d) Compiler error
#include<stdio.h> e) None of these
void main()
{ 21. What is the output of the program given below
int arr[ ]={0,1,2,3,4,5,6}; #include<stdio.h>
int i,*ptr; main()
for(ptr = arr+4, i=0; i<=4; i++) {
printf(“\n%d”,ptr[-i]); char i=0;
} for(;i>=0;i++) ;
a) error printf(”%d\n”,i);
b) 65432 }
c) 0 garbage garbage garbage garbage a) Compile Time Error
d) 43210 b) –128
c) 0
17.What does a preprocessor do? d) Runtime Error
a) Compiles a program e) None
b) It loads program into memory for execution
c) It links all the required modules and file to the 22. void main( ){
program int x=10, y=20;
d) It provides an expanded source to the compiler if(!(!x) && x)
printf(“x=%d”,x);
18. What is the output of the following code? else
#include<stdio.h> printf(“y=%d”,y);
void main() }
{ a) 10

TCM / F / 11 Rev. –00 Page 2 of 3


b) 20 d) A declaration occurs once, but a definition may
c) 1 occur many times.
d) 0 e) e)Both can occur multiple times, but a definition
must occur first

27. int a=10,b;


23. void main( ){ b=a++ + ++a;
int a=30, b=40, x; printf("%d,%d,%d,%d",b,a++,a,++a);
x=(a!=10) && (b=50); what will be the output when following code is executed
printf(“x= %d”,x); a) 12,10,11,13
} b) 22,10,11,13
a) 10 c) 22,11,11,11
b) 50 d) 12,11,11,11
c) 1 e) 22,13,13,13
d) 0
28. String constants should be enclosed between
24. void main( ) { a) Single quotes
int i=2; b) Double quotes
printf(“i-- = %d”, i--); c) Both a and b
} d) None of these
a) i-- = 2
b) i-- = 3 29. void main( ){
c) i-- = 1 float x=12.25, y=13.65;
d) none of the above if(x=y)
printf(“x and y are equal”);
25. void main( ){ else
static int c=5; printf(“x and y are not equal”);
printf(“%d\t”,c--); }
if(c) a) x and y are not equal
main( ); b) x and y are equal
} c) No output

a) 5 4 3 2 1 30. void main( ) {


b) 1 2 3 4 5 float y=0.9;
c) 5 4 3 3 3 long double z= 0.9;
d) none of the above if(y = = z)
printf(“hello world”);
26. What is a difference between a declaration and a else
definition of a variable? printf(“hai world”);
a) Both can occur multiple times, but a declaration }
must occur first. a) hello world
b) There is no difference between them. b) hai world
c) A definition occurs once, but a declaration may c) no output
occur many times.

TCM / F / 11 Rev. –00 Page 3 of 3

You might also like