Coding Contest With Answers
Coding Contest With Answers
#include<stdio.h>
int main()
{
float a = 0.7;
if(0.7 > a)
printf("Hi\n");
else
printf("Hello\n");
return 0;
}
A. Hi
B. Hello
C. None of these
D. error
A. Error: in *NODEPTR
B. Error: typedef cannot be used until it is defined
C. No error
D. None of above
A. ERROR
B. IncludeHelp
C. NO OUTPUT
D. I
4. Which of the following statements correctly assigns 12 to month using pointer variable pdt?
#include<stdio.h>
struct date
{
int day;
int month;
int year;
};
int main()
{
struct date d;
struct date *pdt;
pdt = &d;
return 0;
}
A. pdt.month = 12
B. &pdt.month = 12
C. d.month = 12
D. pdt->month = 12
#include<stdio.h>
int main()
{
struct emp
{
char n[20];
int age;
};
struct emp e1 = {"Dravid", 23};
struct emp e2 = e1;
if(e1 == e2)
printf("The structure are equal");
return 0;
}
A. Prints: The structure are equal
B. Error
C. No output
D. None of above
6. Output?
main()
int a=10,*j;
void *k;
j=k=&a;
j++;
k++;
printf("\n %u %u ",j,k);
A. 10 11
B. ERROR: illegal type casting
C. ERROR: void pointer cannot be incremented
D. NO OUTPUT
A. AB
B. BC
C. CD
D. No output
8.main()
{
char*p;
int*q;
long*r;
p=q=r=0;
p++;
q++;
r++;
printf("%p...%p...%p",p,q,r);
}
A.0001...0002...0004 bbb
B.0002...0003...0004
C.0000...0001...0004
D.0001...0004...0002
A.4
B.3
C.2
D.1
10.main()
{
inti=_l_abc(10);
printf("%d\n",--i);
}
int_l_abc(inti)
{
return(i++);
}
A.10
B.9
C.8
D.11
11. In C, if you pass an array as an argument to a function, what actually gets passed?
A.Value of elements in array
B.First element of the array
C.Base address of the array
D.Address of the last element of array
12. . In the following program add a statement in the function fun() such that address of a gets
stored in j?
#include<stdio.h>
int main()
{
int *j;
void fun(int**);
fun(&j);
return 0;
}
void fun(int **k)
{
int a=10;
/* Add a statement here */
}
A. **k=a;
B. k=&a;
C.*k=&a;
D. &k=*a
return(a+b)
void main()
cout<<add(2,4);
A.14
B.6
C.garbage value
D.error
A.Only a
B.Only b
C.Both a and b
D.None of these option
16. One that can be modified by the class even when the object of the class or the member
function doing the modification is const it is known as______________
A.member function
B.mutable member
C.constant member
D.none of these
17.classSample
{
public:
int*ptr;
Sample(inti)
{
ptr=newint(i);
}
~Sample()
{
deleteptr;
}
voidPrintVal()
{
cout<<"Thevalueis"<<*ptr;
}
};
voidSomeFunc(Samplex)
{
cout<<"Say I am in someFunc "<<endl;
}
intmain()
{
Samples1=10;
SomeFunc(s1);
s1.PrintVal();
}
B. Say I am in someFunc
int main()
{
base BaseArr[5];
SomeFunc(BaseArr,5);
deriDeriArr[5];
SomeFunc(DeriArr,5);
}
A.00000,11111
B.00000,00000
C.00000,10101
D.00000,01010
main()
inti=5;
printf("%d%d%d%d%d%d",i++,i--,++i,--i,i);
A.45545
B.55544
C.55432
D.65655
A. 127
B.0
C.infinite loop
D.runtime eroor
A. x = 15, y =45
B. x =15, y =15
C. x =45 ,y =15
D. x =45 y = 45
A.0 byte
B.2 byte
C.1 byte
D.8 byte
23. voidmain(){
intres;
res= 56>76 ? return0:return1;
printf("%d",res);
A. 0
B.1
C.compiler error
inti=2;
switch(i)
default:printf("zero");
case1: printf("one");
break;
case2:printf("two");
case3: printf("three");
break;
A.two
B.two three
C. zero
D. error
27. . 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)
1. char c1 = 064770;
2. char c2 = 'face';
3. char c3 = 0xbeef;
4. char c4 = \u0022;
5. char c5 = '\iface';
6. char c6 = '\uface';
A.1, 2, 4
B.1, 3, 6
C.3, 5
D.5 only
29.
void main()
int d=5;
printf("%f",d);
A. 5
B. 5.0
C. compiler error
D. no output
float j;
j=1000*1000;
printf("%f",j);
A. 1000000
B. Overflow
C. Error
D. None
int main(void)
{
free(NULL);
return 0;
}
A. Yes
B. No
C. Implementation-dependant
D. Error
printf("Eh???/n");
34. main()
{
char string[]="Hello World";
display(string);
}
void display(char *string)
{
printf("%s",string);
}
A.Hello World
B. compiler error
C. runtime error
D. syntax error
35. main()
{
char s[]={'a','b','c','\n','c','\0'};
char *p,*str,*str1;
p=&s[3];
str=p;
str1=s;
printf("%d",++*p + ++*str1-32);
}
A. 47
B. 55
C. 67
D. 77
36. main()
{
int i=400,j=300;
printf("%d..%d");
}
A. No output
B. 400..300
C. Compiler error
D. Syntax error
37. main()
{
int i;
printf("%d",scanf("%d",&i)); // value 10 is given as input here
}
A. 1
B. 10
C. no output
D. error
38. main()
{
int i=0;
for(;i++;printf("%d",i)) ;
printf("%d",i);
}
A. 0
B. 1
C. no output
D. infinite loop
39. main()
{
int *j;
{
int i=10;
j=&i;
}
printf("%d",*j);
}
A. compiler error
B. syntax error
C. 10
40. aaa() {
printf("hi");
}
bbb(){
printf("hello");
}
ccc(){
printf("bye");
}
main()
{
int (*ptr[3])();
ptr[0]=aaa;
ptr[1]=bbb;
ptr[2]=ccc;
ptr[2]();
}
A. error
B. no output
C. bye
D. hello
41. main()
{
int i;
i = abc();
printf("%d",i);
}
abc()
{
_AX = 1000;
}
A. _AX undeclered
B. 1000
C. error
D. no output
42. main(){
int a= 0;
int b = 20;
char x =1;
char y =10;
if(a,b,x,y)
printf("hello");
}
A.no output
B. error
C. hello
D. not compile
43. main()
{
char *p;
p="%d\n";
p++;
p++;
printf(p-2,300);
}
A. 300
B. warning
D. not compiled
44. main()
{
int a[10];
printf("%d",*a+1-*a+3);
}
B. 4
A. 10
B. error
C. 12
D. 11
printf("%d..%d",sizeof(farther),sizeof(farthest));
}
A. 4,2
B. 2,2
C. 2,1
D. 1,1
B. 12
C. 11
D. error
48. The library function used to find the last occurrence of a character in a string is
A.strnstr()
B.laststr()
C.strrchr()
D.strstr()
main()
inti;
i = 64/square(4);
printf("%d",i);
A. 16
B. 4
C. 64
D. none of these
50.
main()
{
int i=5,j=10;
i=i&=j&&10;
printf("%d %d",i,j);
}
A. 0 0
B. 0 10
C.error
D.1 10