Thursday, 7 June 2018

ch-9 Storage Classess

1 . What is the output of the following code?
main()
 {
static int num=8;
printf(“%d ”,num=num-2);
if(num!=0)
 main();
 }
 A) 8 6 4 2
 B) Infinite output
 C) 6 4 2 0
 D) Invalid because main function can’t call itself.

2. Register variable are active 
A) outside the function  
B) throughout the program 
C) only in the function where it is defined 
D) surrounding of that function 

3. What is the output of this C code?  
#include <stdio.h>  
void main()  
{  
static int x; 
 if (x++ < 2)  
main();  


A) Infinite calls to main 
B) Run time error 
C) Varies 
D) main is called twice 


 What is the output of the following code?
main()
 {
static int num=8;
printf(“%d ”,num=num-2);
if(num!=0)
 main();
 }
 A) 8 6 4 2
B) Infinite output
C) 6 4 2 0


D) Invalid because main function can’t call itself.

True/False
1. The default initial value of a static int variable is zero.

2.   If no storage class is mentioned for a variable defined in a function then it is by default auto.   

3.  ‘auto’ keyword is used to declare a local variable.

4.  The default initial value of a static int variable is zero.

Question:

1. Explain the following: i) static variable ii) auto variable iii) register variable

2.  What is the scope of global, local and register variables.

No comments:

Post a Comment

ch-12 File Handling

Mcq 1. What does fp point to in the program?   #include<stdio.h> int main() {   FILE *fp;   fp=fopen("trial",...