Welcome Guest | Sign in | Register

Home > C Programming > Functions > Questions and Answers

01. What will be printed as the result of the operation below?
#define swap(a,b) a=a+b;b=a-b;a=a-b;
void main()
{
int x=5, y=10;
swap (x,y);
printf("%d %d",x,y);
swap2(x,y);
printf("%d %d",x,y);
}
int swap2(int a, int b)
{
int temp;
temp=a;
b=a;
a=temp;
return 0;
}  
A. 5,10 B. 10,5
C. 0,5 D. 10,0

Answer and Explanation

Answer: 10,5

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
02. What is the output of the following code?
#include "stdio.h"
extern int a;
main(){
void fun();
printf("\n a= %d",a);
fun();
return 0;
}
int a;
void fun(){
printf("\n in fun a=%d",a);
}
A. a=5 in fun a=0 B. a=0 in fun a=5
C. a=5 in fun a=5 D. a=0 in fun a=0

Answer and Explanation

Answer: a=5 in fun a=5

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
03. What will be printed as the result of the operation below?
int x;
int modifyvalue()
{
return(x+=10);
}
int changevalue(int x)
{
return(x+=1);
}
void main()
{
int x=10;
x++;
changevalue(x);
x++;
modifyvalue();
printf("First output:%dn",x);
x++;
changevalue(x);
printf("Second output:%dn",x);
modifyvalue();
printf("Third output:%dn",x);
}
A. 12, 12, 12 B. 12, 12, 13
C. 12, 13, 13 D. 13, 13, 13

Answer and Explanation

Answer: 12, 13, 13

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
04. What is the output of the following program?
#include "stdio.h"
void fun(int _){
printf("%d",_);
}
main(){
fun(23);
return 0;
}
A. 0 B. 23
C. garbage D. error

Answer and Explanation

Answer: 23

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
05. What is the output of the following program?
void fun(auto int _){
print("%d",_);
}
main(){
fun(23);
return 0;
}
A. 0 B. garbage
C. error D. 23

Answer and Explanation

Answer: error

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
06. What is the output of following program?
void main(){
int a=1;
void xyz(int , int);
xyz(++a,a++);
xyz(a++,++a);
printf("%d",a);
}
void xyz(int x, inty){
printf("%d%d",x,y);
}
A. 3 1 3 4 5 B. 3 1 4 4 5
C. 3 1 4 4 4 D. 3 1 4 5 5

Answer and Explanation

Answer: 3 1 4 4 5

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
07. What is the output of following program?
void f1(){
static int s=5;
++s;
printf("%d",s);
}
main(){
f1();
f1();
printf("%d",s);
}
A. 6 6 6 B. 6 7 7
C. 6 7 6 D. error

Answer and Explanation

Answer: error

Explanation:
s in out of scope in main()   

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
08. What is the output of following program?
void f1(){
static int s=5;
++s;
printf("%d",s);
}
main(){
f1();
f1();
}   
A. 5 6 B. 6 6
C. 6 7 D. 5 5

Answer and Explanation

Answer: 6 7

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
09. What is the output of following program?
void abc(int a){
++a;
}
void main(){
int a=10;
abc();
abc();
printf("%d",a);
}  
A. 10 B. 11
C. 12 D. 13

Answer and Explanation

Answer: 10

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
10. What is the output of following program?
void xyz(int b){
++b;
}
void main(){
int b=200;
xyz(b);
xyz(b);
printf("%d",b);
}
A. 200 B. 201
C. 202 D. 203

Answer and Explanation

Answer: 200

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
11. What is the output of following program?
void f1(){
extern int g;
static int s=5;
int a;
++g;
a=s++;
printf("%d%d%d",a,s,g);
if(a<=6)
f1();
printf("%d%d%d",a,s,g);
}
void f2(){
static int s;
int a;
a=++s;
++g;
printf("%d%d%d",a,s,g);
if(a<=2)
f2();
printf("%d%d%d",a,s,g);
}
main(){
f1();
f2();
}
A. 0 5 garbage B. 1 6 1
C. 1 6 2 D. error

Answer and Explanation

Answer: error

Explanation:
linking error undefined symbol - g   

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
12. What is the output of the following program?
#include "stdio.h"
void fun(int _){
printf("%d",_);
}
main(){
fun(23);
return 0;
}
A. 0 B. 23
C. garbage D. error

Answer and Explanation

Answer: 23

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum



Partner Sites
LucentBlackBoard.com                  SoftLucent.com                  LucentJobs.com
All rights reserved © 2012-2015 SoftLucent.