C Data Types, Variables & Storage Classes

C Language- Data types,variables and storage Classes

22 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

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);
}

  1. 3
  2. 5
  3. 7
  4. 8
Question 2 Multiple Choice (Single Answer)

What will be the output of the following C code?
int T;
static T= 8;
extern T;
void main()
{
printf(%d,T);
}

  1. 8
  2. 0
  3. Compile error
  4. Runtime error
Question 3 Multiple Choice (Single Answer)

What will be the output of the following C code?
void main()
{
char ch=321;
printf(%d %c,ch,ch);
}

  1. 65 A
  2. 66 B
  3. 67 C
  4. 97 A
Question 4 Multiple Choice (Single Answer)

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);
}

  1. 10 90
  2. 90 10
  3. 10 10
  4. Compilation error
Question 5 Multiple Choice (Single Answer)

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. 1 2 4
  3. 1 2 2
  4. 2 4 4
Question 6 Multiple Choice (Single Answer)

What will be the output of the following C code?
void main()
{
static int t=7;
printf(%d,t);
if(t--)
main();
}

  1. 76543210
  2. 7654321
  3. 7654321 - 1
  4. Infinite loop
Question 7 Multiple Choice (Single Answer)

What will be the output of the following C code?
void main()
{
int T='T';
printf(%c,T+6);
}

  1. Z
  2. Y
  3. X
  4. W
Question 8 Multiple Choice (Single Answer)

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. 1 2 3 4 5 6 7 8 9 10
  2. 1 1 1 1 1 1 1 1 1 1
  3. 0 0 0 0 0 0 0 0 0 0
  4. Compile error
Question 9 Multiple Choice (Single Answer)

By which values are t and c initialized to print - 25536 and - 20536, respectively?
void main()
{
int t=,c=;
printf(%d %d,t,c);
}

  1. 41000, 46000
  2. 40000, 46000
  3. 41000, 50000
  4. 40000, 45000
Question 10 Multiple Choice (Single Answer)

What error will occur while running the following program?
void main()
{
int const *t=8;
printf(%d,++(*t));
}

  1. Lvalue required
  2. Invalid pointer
  3. Cannot modify the constant object
  4. Runtime error
Question 11 Multiple Choice (Single Answer)

What will be the output of the following C code?
void main()
{
int t=70,c=14,d;
d=t/**//c;
printf(%d,d);
}

  1. 4
  2. 5
  3. 6
  4. 3
Question 12 Multiple Choice (Single Answer)

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);
}

  1. 10
  2. 11
  3. 10.9000
  4. 10.9375
Question 13 Multiple Choice (Single Answer)

What error will occur while running the following program?
void main()
{
int i=j+5,j=6;
printf(%d %d,i,j);
}

  1. Undefined Symbol i
  2. Lvalue required
  3. Undefined symbol j
  4. No error
Question 14 Multiple Choice (Single Answer)

What is the correct C language expression for the following mathematical expression?
Sin2x + Cos2x + Sin(ex + log10x)

  1. pow(sinx,2) + cos(2*x) + sin(exp(x) + log10(x))
  2. pow(sin,2x) + cos(2*x) + sin(exp(x) + log10(x))
  3. pow(sinx,2) + cos(2x) + sin(exp(x) + log10(x))
  4. pow(sinx,2) + cos(2*x) + sin(exp(x) + log10(x))
Question 15 Multiple Choice (Single Answer)

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);
}

  1. - 25215
  2. - 25216
  3. - 25217
  4. - 25218
Question 16 Multiple Choice (Single Answer)

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?

  1. 922
  2. 32767
  3. 923
  4. 999
Question 17 Multiple Choice (Single Answer)

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);
}

  1. Compile error
  2. Linker error
  3. No error
  4. Runtime error
Question 18 Multiple Choice (Single Answer)

Which of the following is a range of long signed int?

  1. -2147483648 to +2147483647
  2. -2147483647 to +2147483648
  3. - 2147483647 to + 2147483647
  4. - 32768 to + 32767
Question 19 Multiple Choice (Single Answer)

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++);
}

  1. 288 0
  2. 32 1
  3. 0 1
  4. Compilation error
Question 20 Multiple Choice (Single Answer)

Which of the following programs prints ABCDEFG?

  1. void main()
    {
    int i;
    for(i=65;i<=71;printf(%d,i),i++);
    }
  2. void main()
    {
    int i;
    for(i=65;i<=71;printf(%c,i));
    }
  3. void main()
    {
    int i;
    for(i=65;i<=71;printf(%c,i),i++);
    }
  4. void main()
    {
    int i;
    for(i=65;i<=70;printf(%c,i),i++);
    }
Question 21 Multiple Choice (Single Answer)

What type of error will occur while running the following program?

void main()
{
extern int t;
t =100;
printf(Value of t = %d,t);
}

  1. Linker error
  2. Compilation error
  3. Runtime error
  4. No error
Question 22 Multiple Choice (Single Answer)

If any signed integer data type takes 4 bytes, what maximum value can be stored?

  1. + 24
  2. + 232 - 1
  3. + 231
  4. + 231 - 1