C Programming: 1. Which of The Following About The Following Two Declaration Is True
C Programming: 1. Which of The Following About The Following Two Declaration Is True
C Programming: 1. Which of The Following About The Following Two Declaration Is True
Choice :
a) Both are identical
b) The first is a correct declaration and the second is wrong
c) The first declaration is a function returning a pointer to an integer and the second is a pointer to
function returning int
d) Both are different ways of declaring pointer to a function
main()
{
int x=7;
int y=3;
dprintf(x/y);
}
Choice:
a) #2 = 2 b) expr=2 c) x/y=2 d) none
main()
{
char *c;
int *ip;
c =(char *)malloc(100);
ip=(int *)c;
free(ip);
}
choice:
a) The function can change values in the original array
b) In C parameters are passed by value. The function cannot change the original value in the array
c) It results in compilation error when the function tries to access the elements in the array
d) Results in a run time error when the function tries to access the elements in the array
a) 7 b) 28 c) 3 d) 14 e) None
if(a=3)
b++;
printf("%d %d\n",a,b++);
}
main()
{
int l=6;
switch(l)
{ default : l+=2;
case 4: l=4;
case 5: l++;
break;
}
printf("%d",l);
}
a)8 b)6 c)5 d)4 e)none
14. What is the output of the following program?
main()
{
int x=20;
int y=10;
swap(x,y);
printf("%d %d",y,x+2);
}
swap(int x,int y)
{
int temp;
temp =x;
x=y;
y=temp;
}
struct Node {
char *word;
int count;
struct Node left;
struct Node right;
}
a) Incorrect definition
b) structures cannot refer to other structure
c) Structures can refer to themselves. Hence the statement is OK
d) Structures can refer to maximum of one other structure
17. What is the size of the following union.
Assume that the size of int =2, size of float =4 and
size of char =1.
Union Tag{
int a;
flaot b;
char c;
};
18. What is the output of the following program? (. has been used to indicate a space)
main()
{
char s[]="Hello,.world";
printf(%15.10s",s);
}
a)Hello,.World...
b)....Hello,.Wor
c)Hello,.Wor.... (this option is correct for
%s-15.10s)
d) None of the above
main()
{
int a[10]={1,2,3,4,5,6,7,8,9,10};
int *p=a;
int *q=&a[9];
printf("%d",q-p+1);
}
20.
main()
{
int i=6;
int *p=&i;
free(p);
printf("%d",i);
}
Options:
a. No Error.
b. Free can't be used for p,
c. Compiler Error.
d. In printf we should use *p instead of i.
21.
What is the output of the Program?
main()
{
int i=5;
i=!i>3;
printf("%d",i);
}
22.
What is the output of the Program?
main()
{
int a[10];
3[a]=10;
printf("%d",*(a+3));
}
23.
int (*p[10]) ();
24.
What is the output of the Program?
struct emp
{
int a=25;
char b[20]="tgk";
};
main
{
emp e;
e.a=2;
strcpy(e.b,"tellapalli");
printf("%d %s",e.a,e.b);
}
25.
What is the output of the Program?
main()
{
int a=5;
const int *p=&a;
*p=200;
printf("%d",*p);
}
26.
What is the output of the Program?
#define SQ(x) x*x
main()
{
int a=SQ(2+1);
printf("%d",a);
}
27.
What is the output of the Program?
main()
{
struct t
{
int i;
} a,*p=&a;
p->i=10;
printf("%d",(*p).i);
}
28.
This program will be Compiled? [Yes/No]
zzz.c file
----------
/* This is zzz.c file*/
/*printf("tellapalli");*/
abc.c file
----------
main()
{
#include"zzz.c"
printf("Tellapalli");
}
void main()
{
float arr[2][3] = {{0,1,2},{3,4,5}};
float **fl_arr;
fl_arr = (float *)arr;
print_arr(fl_arr);
fl_arr++;
print_arr(fl_arr);
}
31.What is the output of the following code:-
(a) c
(b) 99
(c) Compilation error
(d) Execution error
void main()
{
printf("%d",printf("ABC\\"));
}
(a) ABC\\
(b) 1
(c) ABC\4
(d) ABC\3
void main()
{
int i;
for(i=0;i<3;i++)
{
int i=100;
i--;
printf("%d..",i);
}
}
(a)0..1..2..
(b)99..98..97..
(c)100..100..100..
(d)99..99..99..
void main()
{
int a[]={9,4,1,7,5};
int *p;
p=&a[3];
printf("%d",p[-1]);
}
(a)6
(b)1
(c)7
(d)Error
void main()
{
int a[]={10,20,30,40,50};
int *p;
p= (int*)((char *)a + sizeof(int));
printf("%d",*p);
}
(a)10
(b)20
(c)30
(d)40
for(i=0;i<100;i++)
for(j=0;j<10;j++)
a[i][j]=0;
OR
for(j=0;j<10;j++)
for(i=0;i<100;i++)
a[i][j]=0;
(a)First code
(b)Second code
(c)Same
(d)Compiler and hardware dependent