Pyq C (2018)
Pyq C (2018)
December 2018
C PROGRAMMING
A. Choose the correct answer from the given alternatives (any ten): 1x10=10
i) C language has been developed by (a) Ken Thompson (b) Dennis Ritchie (c) Peter Norton
(d) Martin Richards.
The expression x=4+2%-8 evaluates to (a) -6 (b) 6 (c) 4 (d) 2.
Pick the odd one out : (a) a=a+1 (b) at=1 (c) at++ (d) a=+1.
Which operator produces the 1’s complement of the given binary value? (a) logical AND
(b) bitwise AND (c) logical OR (d) bitwise NOT.
A statement block consists of how many statements? (a) 0 (b) 1 (c) n (d) none of the
above.
If an array is declared as int arr[5][5], how many elements can it hold? (a) 5 (b) 10 (c) 25
(d) 50.
vii) Which variable retains its value in-between function calls? (a) Auto (b) Static (c) Register
(d) Extern.
Array name is a (a) keyword (b) structure (c) union (d) pointer.
The function malloc() is declared in which header file? (a) stdio.h (b) stdlib-h (c) conio.h
(d) iostream.h
Memory for the structure is allocated at the time of (a) structure definition (b) structure
variable declaration (c) structure declaration (d) function declaration.
xi) The preprocessor directives must be preceded by which symbol? (a) * (b) & (c) ! (d) #
B. What will be the output of the following codes? (any five): $x2=10
i) fiain()
int i=1;
for(;;)
{
printf("\n%d" i++);
if(i<=10)
Se
break;
}
}
ii)
int prodtint x. int y)
return(x*y)s
}
main()
intx=2y=3.25
z=prod(x,prod(x,y))s
print{("%d",2);
}
iii) main()
{ :
int arr{}={1,2,3,4,5}5
int *ptr,i;
ptr=arr+4; He
for(i=4;i>=051-- ;
printf("%d " *(ptr-i));
}
iv) #define cube(x) (x*x*x)
main()
Ch int J;
j=cube(2+1);
printf("%d".j)
}
main()
int i=30;
switch(i)
default:
printf("\nNo matching value");
break;
case 1:
printf("\nThe value is 1");
break;
case 2:
printf("\nThe value is 2");
break;
case 3:
printf("\nThe value is 3");
}
BAe
}
main()
{
int x=10,y=20;
if(x==y);
printf("%d %d" x,y);
printf("\nGood by");
What is the difference between i++ and ++i? Explain with proper example.
to
Wnite a program to get the sum of digits of a number entered through keyboard.
Write a program to print the following using nested loop: ae]
10
110
1110