100% found this document useful (2 votes)
138 views10 pages

Functions and Storage Class

The document contains 16 multiple choice questions related to C programming concepts such as functions, storage classes, recursion, and parameter passing. The questions cover topics like pre-increment and post-increment operators, call by value, static variables, recursion, register keyword, extern keyword, and more. Sample code snippets are provided with each question to demonstrate the concept being tested.

Uploaded by

pratik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
138 views10 pages

Functions and Storage Class

The document contains 16 multiple choice questions related to C programming concepts such as functions, storage classes, recursion, and parameter passing. The questions cover topics like pre-increment and post-increment operators, call by value, static variables, recursion, register keyword, extern keyword, and more. Sample code snippets are provided with each question to demonstrate the concept being tested.

Uploaded by

pratik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Functions And Storage Class

1.
#include<stdio.h>
int function(int,int);
int main(void)
{
int i=135,a=135,k;
k=function(!++i,!++a);
printf("i=%d a=%d k=%d\n",i,a,k);
return 0;
}
int function(int j,int b)
{
int c;
c=j++ + b++;
return !c;
}

A. i=136 a=136 k=1


B. i=136 a=136 k=0
C. i=136 a=136 k=272
D. i=135 a=135 k=1

Answer: A

2.
#include<stdio.h>
int function(int,int);
int main(void)
{
int i=10,j=20;
printf("before fun call :: i=%d j=%d \n",i,j);
i=i+j;j=i-j;i=i-j;
function(i,j);
i=i+j;j=i-j;i=i-j;
printf(" after fun call :: i=%d j=%d \n",i,j);
return 0;
}

Augest 2019 – December 2019 1


Functions And Storage Class
int function(int i,int j)
{
i=i+j;j=i-j;i=i-j;
}

A. before fun call :: i=10 j=20


after fun call :: i=10 j=20
B. before fun call :: i=10 j=20
after fun call :: i=20 j=10
C. before fun call :: i=20 j=10
after fun call :: i=10 j=20
D. complie time error

Answer: A

3.
#include<stdio.h>
int main(void)
{
int result;
int i=10,j=20;
result=add(i,j);
printf("i=%d \n",result);
return 0;
}
int add(int a,int b)
{
int result;
result=a+b;
return result, a+b, a-b;
}

A. Compile time error :function declaration is missing.


B. i=40
C. i=30
D. i=-10

Answer: D

Augest 2019 – December 2019 2


Functions And Storage Class
4.
#include<stdio.h>
int myFunction(int,int);
int main(void)
{
int result;
int i=2,j=3;
i=myFunction(i,j);
printf("i=%d j=%d\n",i,j);
return 0;
}
int myFunction(int a,int b)
{
a=a+a;
b=b+b;
return b-b;
return a-a;
}

A. i=0 j=0
B. i=4 j=0
C. i=4 j=6
D. i=0 j=3

Answer: D

5.
#include<stdio.h>
int function(int z);
int main(void)
{
int z=111;

z = z + function(z++);
printf("result=%d",z);

return 0;
}

Augest 2019 – December 2019 3


Functions And Storage Class
int function(int z)
{
return ++z;
}

A. result=225
B. result=224
C. result=222
D. result=223

Answer :B

6.
#include<stdio.h>
int main(void)
{
if((printf("Hello C\n")-8))
{
main();
}
printf("Hello C\n");
return 0;
}

A. stack overflow error


B. prints Hello C only once
C. prints Hello C twice
D. prints Hello C infinte number of times
Answer: C

7.
#include<stdio.h>
void fun(int);
int main( void )
{
static int i=1; fun(i);
return 0;
}

Augest 2019 – December 2019 4


Functions And Storage Class
void fun(int i)
{
static int j=1;
i=j;j++;i++;
printf("%d,",i);
if(i<=3)
fun(i);
}

A. 1,1,1
B. 2,2,3
C. 2,3,4
D. 3,4,5

Answer: C

8.

#include<stdio.h>
void rec(int);
int main()
{
int a=3;

rec(a);
return 0;
}
void rec(int n)
{
if(n>0)
{
rec(--n);
printf(",%d",n);
rec(--n);
}
else
printf("\t");
}

Augest 2019 – December 2019 5


Functions And Storage Class
A. ,1,2,0,0
B. ,0,1,2,1
C. ,0,1,2,0
D. ,0,1,0,0

Answer: C

9.
#include<stdio.h>
int main(void)
{
int i;
for(i=0;i<3;i++)
{
int x=0;
static int y=0;
printf("x=%d , y=%d \t",x++,y++);
}
return 0;
}

A. x=0,y=0 x=1,y=1 x=2,y=2


B. x=0,y=0 x=1,y=0 x=2,y=0
C. x=0,y=0 x=0,y=1 x=0,y=2
D. x=0,y=0 x=0,y=0 x=0,y=0
Answer: C

10.

#include<stdio.h>
register int i;
int main(void)
{
printf("\n Enter value of i::");
scanf("%d",&i);
printf("\n i=%d i=%u", i, &i);
return 0;
}

Augest 2019 – December 2019 6


Functions And Storage Class

A. register variables can not declare globaly


B. we can not print the address of register variables
C. Both A and B
D. Run time error
Answer: C

11.
#include <stdio.h>
void func(void);
int main(void)
{
func(); func();
return 0;
}
void func(void)
{
auto int i=0;
register int j=0;
static int k=0;
i++;j++;k++;
printf("i=%d j=%d k=%d\t",i,j,k);
}

A. i=1 j=1 k=1 i=1 j=1 k=2


B. i=0 j=0 k=0 i=0 j=0 k=0
C. i=1 j=1 k=1 i=2 j=2 k=2
D. compile time error

Answer: A

12.
The Statement extern int var is
A. Declaration of identifier var
B. Defination of identifier var
C. Declaration as well as defination
D. None of the above
Answer: A

Augest 2019 – December 2019 7


Functions And Storage Class
13.
#include <stdio.h>
int main(void)
{
extern int var=1000;
printf(" var = %d",++var);
return 0;
}
A. var = 1000
B. var = 0
C. var = 1001
D. compile time error

Answer: D

14.
#include <stdio.h>
int fun(float a);
int main( void )
{
static float x;
x=(float)fun(100);
printf(" x = %.f ",x);
return 0;
}
int fun(float a)
{
return a ==100.0f ? 1000 : 500;
}

A. compile time error


B. x = 1000.000000
C. x = 500
D. x = 1000

Answer: D

Augest 2019 – December 2019 8


Functions And Storage Class
15.
#include<stdio.h>
static int num=9;
int main(void)
{
if(num<0)
return 0;
else if(num%2==1)
{
num--;
printf("%3d,",num-=1);

}
else
{
printf("%3d,",num-=2);
}
main();
return 0;
}

A. 8, 6, 4, 2, 0,
B. 8, 5, 4, 1, 0, -3,
C. 8, 6, 4, 2, 0, -2,
D. 7, 5, 3, 1, -1,

Answer: D

16.

#include<stdio.h>
int fun(int x,int y)
{
if(x==0)
return y;
return fun(x-1,x+y);
}

Augest 2019 – December 2019 9


Functions And Storage Class
int main(void)
{
static int x=fun(2,2);
printf("X is %d",x);
return 0;
}

A. X is 5
B. X is 2
C. X is 3
D. Compile time error

Answer: D

Augest 2019 – December 2019 10

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy