C Data Types, Variables & Storage Classes
C Language- Data types,variables and storage Classes
Questions
What will be the output of the following C code?
void main()
{
int t;
char *pc=(char *)0;
float *pf=(float *)0;
t=(int)(pc+1) + (int)(pf+1);
printf(%d,t);
}
- 3
- 5
- 7
- 8
What will be the output of the following C code?
int T;
static T= 8;
extern T;
void main()
{
printf(%d,T);
}
- 8
- 0
- Compile error
- Runtime error
What will be the output of the following C code?
void main()
{
char ch=321;
printf(%d %c,ch,ch);
}
- 65 A
- 66 B
- 67 C
- 97 A
What will be the output of following C code?
void main()
{
int t,*pt;
register int y,*py;
pt=&t;
py=&y;
t=10;
y=90;
printf(%d %d,*pt,*py);
}
- 10 90
- 90 10
- 10 10
- Compilation error
Find the output of the following C code.
void main()
{
char Rch;
int Rn;
float Rr;
printf(%d %d %d, sizeof(Rch),sizeof(Rn),sizeof(Rr));
}
- 1 1 1
- 1 2 4
- 1 2 2
- 2 4 4
What will be the output of the following C code?
void main()
{
static int t=7;
printf(%d,t);
if(t--)
main();
}
- 76543210
- 7654321
- 7654321 - 1
- Infinite loop
What will be the output of the following C code?
void main()
{
int T='T';
printf(%c,T+6);
}
- Z
- Y
- X
- W
If the input of the following program is 10, what will be the output?
void print(int);
void main()
{
int n;
scanf(%d,&n);
print(n);
}
void print(static int x)
{
int i;
for(i=1;i<=x;i++)
printf(%d,i);
}
- 1 2 3 4 5 6 7 8 9 10
- 1 1 1 1 1 1 1 1 1 1
- 0 0 0 0 0 0 0 0 0 0
- Compile error
By which values are t and c initialized to print - 25536 and - 20536, respectively?
void main()
{
int t=,c=;
printf(%d %d,t,c);
}
- 41000, 46000
- 40000, 46000
- 41000, 50000
- 40000, 45000
What error will occur while running the following program?
void main()
{
int const *t=8;
printf(%d,++(*t));
}
- Lvalue required
- Invalid pointer
- Cannot modify the constant object
- Runtime error
What will be the output of the following C code?
void main()
{
int t=70,c=14,d;
d=t/**//c;
printf(%d,d);
}
- 4
- 5
- 6
- 3
What will be the output of the following C code?
void main()
{
double t=9.0,c=78.50;
float Res;
Res = (t+c)/8;
printf(%.4f, Res);
}
- 10
- 11
- 10.9000
- 10.9375
What error will occur while running the following program?
void main()
{
int i=j+5,j=6;
printf(%d %d,i,j);
}
- Undefined Symbol i
- Lvalue required
- Undefined symbol j
- No error
What is the correct C language expression for the following mathematical expression?
Sin2x + Cos2x + Sin(ex + log10x)
- pow(sinx,2) + cos(2*x) + sin(exp(x) + log10(x))
- pow(sin,2x) + cos(2*x) + sin(exp(x) + log10(x))
- pow(sinx,2) + cos(2x) + sin(exp(x) + log10(x))
- pow(sinx,2) + cos(2*x) + sin(exp(x) + log10(x))
What will be the output of the following C code?
void main()
{
int fact=1,i;
clrscr();
for(i=2;i<=8;i++)
fact=fact*i;
printf(%d,fact);
}
- - 25215
- - 25216
- - 25217
- - 25218
void main()
{
int i,n,sum=0;
scanf(“%d”,&n);
for(i=0;i<=n;i++)
sum=sum+i;
printf(“%d”,sum);
}
The above program is for sum of the numbers from 0 to n.
What is the maximum value of n for which the program gives the desired output?
- 922
- 32767
- 923
- 999
Find out the error in the following program.
void main()
{
int t,c;
scanf(Enter the values of t and c = %d %d,&t,&c);
printf(t=%d c=%d, t, c);
}
- Compile error
- Linker error
- No error
- Runtime error
Which of the following is a range of long signed int?
- -2147483648 to +2147483647
- -2147483647 to +2147483648
- - 2147483647 to + 2147483647
- - 32768 to + 32767
What will be the output of the following C code?
void main()
{
int a;
char *pr;
int Num=288;
pr=(char *)&Num;
for(a=0;a<2;a++)
printf(%d ,*pr++);
}
- 288 0
- 32 1
- 0 1
- Compilation error
Which of the following programs prints ABCDEFG?
- void main()
{
int i;
for(i=65;i<=71;printf(%d,i),i++);
} - void main()
{
int i;
for(i=65;i<=71;printf(%c,i));
} - void main()
{
int i;
for(i=65;i<=71;printf(%c,i),i++);
} - void main()
{
int i;
for(i=65;i<=70;printf(%c,i),i++);
}
What type of error will occur while running the following program?
void main()
{
extern int t;
t =100;
printf(Value of t = %d,t);
}
- Linker error
- Compilation error
- Runtime error
- No error
If any signed integer data type takes 4 bytes, what maximum value can be stored?
- + 24
- + 232 - 1
- + 231
- + 231 - 1