Exercise: Questions on Storage Classes and Type Qualifiers


Questions on Storage Classes and Type Qualifiers : Question 1 :
Which of the following is not a storage class specifier in C?

auto
register
static
extern
volatile
typedef
Show Answer
Questions on Storage Classes and Type Qualifiers : Question 2 :
Output of following program?
#include <stdio.h>
int main()
{
    static int i=5;
    if(--i){
        main();
        printf("%d ",i);
    }
}

4 3 2 1
1 2 3 4
0 0 0 0
Compiler Error
Show Answer
Questions on Storage Classes and Type Qualifiers : Question 3 :
#include <stdio.h>
int main()
{
    static int i=5;
    if (--i){
        printf("%d ",i);
        main();
    }
}

4 3 2 1
1 2 3 4
4 4 4 4
0 0 0 0
Show Answer
Questions on Storage Classes and Type Qualifiers : Question 4 :
#include <stdio.h>
int main()
{
    int x = 5;
    int * const ptr = &x;
    ++(*ptr);
    printf("%d", x);
  
    return 0;
}

Compiler Error
Runtime Error
6
5
Show Answer
Questions on Storage Classes and Type Qualifiers : Question 5 :
#include <stdio.h>
int main()
{
    int x = 5;
    int const * ptr = &x;
    ++(*ptr);
    printf("%d", x);
  
    return 0;
}

Compiler Error
Runtime Error
6
5
Show Answer
Questions on Storage Classes and Type Qualifiers : Question 6 :
#include<stdio.h>
int main()
{
  typedef static int *i;
  int j;
  i a = &j;
  printf("%d", *a);
  return 0;
}

Runtime Error
0
Garbage Value
Compiler Error
Show Answer
Questions on Storage Classes and Type Qualifiers : Question 7 :
Output?
#include<stdio.h>
int main()
{
   typedef int i;
   i a = 0;
   printf("%d", a);
   return 0;
}

Compiler Error
Runtime Error
0
1
Show Answer
Questions on Storage Classes and Type Qualifiers : Question 8 :
#include<stdio.h>
int main()
{
  typedef int *i;
  int j = 10;
  i *a = &j;
  printf("%d", **a);
  return 0;
}

Compiler Error
Garbage Value
10
0
Show Answer
Questions on Storage Classes and Type Qualifiers : Question 9 :
Output?
#include <stdio.h>
int fun()
{
  static int num = 16;
  return num--;
}

int main()
{
  for(fun(); fun(); fun())
    printf("%d ", fun());
  return 0;
}

Infinite loop
13 10 7 4 1
14 11 8 5 2
15 12 8 5 2
Show Answer
Questions on Storage Classes and Type Qualifiers : Question 10 :
#include <stdio.h>
int main() 
{ 
  int x = 10; 
  static int y = x; 
  
  if(x == y) 
     printf("Equal"); 
  else if(x > y) 
     printf("Greater"); 
  else
     printf("Less"); 
  return 0; 
}

Compiler Error
Equal
Greater
Less
Show Answer