C programs pbq final
-
Upload
azad-public-school -
Category
Education
-
view
141 -
download
9
Transcript of C programs pbq final
![Page 1: C programs pbq final](https://reader031.fdocuments.us/reader031/viewer/2022020208/55b7fa61bb61eb006d8b4733/html5/thumbnails/1.jpg)
![Page 2: C programs pbq final](https://reader031.fdocuments.us/reader031/viewer/2022020208/55b7fa61bb61eb006d8b4733/html5/thumbnails/2.jpg)
1. What will be output when you will execute following c code?#include<stdio.h>
int main(){ printf("%d\t",sizeof(6.5));
printf("%d\t",sizeof(90000)); printf("%d",sizeof('A'));
return 0;}
![Page 3: C programs pbq final](https://reader031.fdocuments.us/reader031/viewer/2022020208/55b7fa61bb61eb006d8b4733/html5/thumbnails/3.jpg)
2.What will be output when you will execute following c code?
#include<stdio.h>int main(){
signed x; unsigned y;
x = 10 +- 10u + 10u +- 10; y = x;
if(x==y) printf("%d %d",x,y);
else if(x!=y) printf("%u %u",x,y);
return 0;}
![Page 4: C programs pbq final](https://reader031.fdocuments.us/reader031/viewer/2022020208/55b7fa61bb61eb006d8b4733/html5/thumbnails/4.jpg)
3.What will be output when you will execute following c code?#include<stdio.h>
int main(){ double num=5.2;
int var=5; printf("%d\t",sizeof(!num));
printf("%d\t",sizeof(var=15/2)); printf("%d",var);
return 0;}
![Page 5: C programs pbq final](https://reader031.fdocuments.us/reader031/viewer/2022020208/55b7fa61bb61eb006d8b4733/html5/thumbnails/5.jpg)
4.What will be output when you will execute following c code?
#include<stdio.h>enum A{ x,y=5,
enum B{ p=10,q
}varp;}varx;
int main(){ printf("%d%d",x,varp.q);
return 0;}
![Page 6: C programs pbq final](https://reader031.fdocuments.us/reader031/viewer/2022020208/55b7fa61bb61eb006d8b4733/html5/thumbnails/6.jpg)
![Page 7: C programs pbq final](https://reader031.fdocuments.us/reader031/viewer/2022020208/55b7fa61bb61eb006d8b4733/html5/thumbnails/7.jpg)
6.What will be the output of the following.#include<stdio.h>
#include<conio.h>void main()
{int a=1,b=1,c=0,i;
clrscr();printf("%d\t%d\t",a,b);
for(i=0;i<=10;i++){
c=a+b;
if(c<100){printf("%d\t",c);}a=b;b=c;}getch();}
![Page 8: C programs pbq final](https://reader031.fdocuments.us/reader031/viewer/2022020208/55b7fa61bb61eb006d8b4733/html5/thumbnails/8.jpg)
7.What will be the output of the following code.#include<stdio.h>
#include<conio.h>void main()
{int uabs(int), x;
clrscr();printf(“enter a negative value:”);
scanf(“%d”, x);x=uabs(x);
printf(“X=%d”, x);return 0;
}
uabs(int y){if(y<0)return(y*-1);elsereturn(y);}
![Page 9: C programs pbq final](https://reader031.fdocuments.us/reader031/viewer/2022020208/55b7fa61bb61eb006d8b4733/html5/thumbnails/9.jpg)
8.What will be the content of 'file.c' after executing the following program?
#include<stdio.h>int main(){ FILE *fp1, *fp2; fp1=fopen("file.c", "w"); fp2=fopen("file.c", "w"); fputc('A', fp1); fputc('B', fp2); fclose(fp1); fclose(fp2); return 0; }
![Page 10: C programs pbq final](https://reader031.fdocuments.us/reader031/viewer/2022020208/55b7fa61bb61eb006d8b4733/html5/thumbnails/10.jpg)
9.What is the output of the following program?
void main(){
static int i=i++, j=j++, k=k++;printf(“i = %d j = %d k = %d”, i, j, k);
}
![Page 11: C programs pbq final](https://reader031.fdocuments.us/reader031/viewer/2022020208/55b7fa61bb61eb006d8b4733/html5/thumbnails/11.jpg)
10.What is the output of the following program?
main(){
unsigned int i=10;while(i-->=0)
printf(“%u ”,i);}
![Page 12: C programs pbq final](https://reader031.fdocuments.us/reader031/viewer/2022020208/55b7fa61bb61eb006d8b4733/html5/thumbnails/12.jpg)
11.What is the output of thefollowing program?#include<conio.h>
main(){
int x,y=2,z,a;if(x=y%2) z=2;
a=2;printf(“%d %d”,z,x);
}
![Page 13: C programs pbq final](https://reader031.fdocuments.us/reader031/viewer/2022020208/55b7fa61bb61eb006d8b4733/html5/thumbnails/13.jpg)
12.What is the output of thefollowing program?
main(){
int a[10];printf(“%d”,*a+1-*a+3);
}
![Page 14: C programs pbq final](https://reader031.fdocuments.us/reader031/viewer/2022020208/55b7fa61bb61eb006d8b4733/html5/thumbnails/14.jpg)
13. What is the output of the following program?
#define prod(a,b) a*bmain(){
int x=3,y=4;printf(“%d”,prod(x+2,y-1));
}
![Page 15: C programs pbq final](https://reader031.fdocuments.us/reader031/viewer/2022020208/55b7fa61bb61eb006d8b4733/html5/thumbnails/15.jpg)
14.What is the output of the following program?
main(){
unsigned int i=65000;while(i++!=0);printf("%d",i);
}
![Page 16: C programs pbq final](https://reader031.fdocuments.us/reader031/viewer/2022020208/55b7fa61bb61eb006d8b4733/html5/thumbnails/16.jpg)
15. What is the output of the following program?
main(){
float f=5,g=10;enum{i=10,j=20,k=50};
printf(“%d\n”,++k);printf(“%f\n”,f<<2);printf(“%lf\n”,f%g);
printf(“%lf\n”,fmod(f,g));}
![Page 17: C programs pbq final](https://reader031.fdocuments.us/reader031/viewer/2022020208/55b7fa61bb61eb006d8b4733/html5/thumbnails/17.jpg)
16. What is the output of the following program?
main(){
signed char i=0;for(;i>=0;i++) ;
printf(“%d\n”,i);}
![Page 18: C programs pbq final](https://reader031.fdocuments.us/reader031/viewer/2022020208/55b7fa61bb61eb006d8b4733/html5/thumbnails/18.jpg)
17. What is the output of the following program?
main(){
unsigned char i=0;for(;i>=0;i++) ;
printf(“%d\n”,i);}
![Page 19: C programs pbq final](https://reader031.fdocuments.us/reader031/viewer/2022020208/55b7fa61bb61eb006d8b4733/html5/thumbnails/19.jpg)
18.What is the output of the following program?
main(){
char *p = “ayqm”;printf(“%c”,++*(p++));
}
![Page 20: C programs pbq final](https://reader031.fdocuments.us/reader031/viewer/2022020208/55b7fa61bb61eb006d8b4733/html5/thumbnails/20.jpg)
![Page 21: C programs pbq final](https://reader031.fdocuments.us/reader031/viewer/2022020208/55b7fa61bb61eb006d8b4733/html5/thumbnails/21.jpg)
20.What is the output of the following program?
main(){
char str1[] = {‘s’,‘o’,‘m’,‘e’};char str2[] = {‘s’,‘o’,‘m’,‘e’,‘\0’};
while (strcmp(str1,str2))printf(“Strings are not equal\n”);
}
![Page 22: C programs pbq final](https://reader031.fdocuments.us/reader031/viewer/2022020208/55b7fa61bb61eb006d8b4733/html5/thumbnails/22.jpg)
21. What is the output of thefollowing program?
void main(){
static int i;while(i<=10)(i>2)?i++:i--;
printf(“%d”, i);}
![Page 23: C programs pbq final](https://reader031.fdocuments.us/reader031/viewer/2022020208/55b7fa61bb61eb006d8b4733/html5/thumbnails/23.jpg)
22.What is the output of the following program?
main(){
register int a=2;printf(“Address of a = %d”,&a);
printf(“Value of a = %d”,a);}
![Page 24: C programs pbq final](https://reader031.fdocuments.us/reader031/viewer/2022020208/55b7fa61bb61eb006d8b4733/html5/thumbnails/24.jpg)
23. What is the output of thefollowing program?
main(){
float i=1.5;switch(i)
{case 1: printf(“1”);case 2: printf(“2”);
default : printf(“0”);}}
![Page 25: C programs pbq final](https://reader031.fdocuments.us/reader031/viewer/2022020208/55b7fa61bb61eb006d8b4733/html5/thumbnails/25.jpg)
24.What is the output of the following program?
main(){
extern i;printf(“%d\n”,i);
{int i=20;
printf(“%d\n”,i);}}
![Page 26: C programs pbq final](https://reader031.fdocuments.us/reader031/viewer/2022020208/55b7fa61bb61eb006d8b4733/html5/thumbnails/26.jpg)
25.What is the output of thefollowing program?
main(){
int i = 257;int *iPtr = &i;
printf(“%d %d”, *((char*)iPtr), *((char*)iPtr+1));}
![Page 27: C programs pbq final](https://reader031.fdocuments.us/reader031/viewer/2022020208/55b7fa61bb61eb006d8b4733/html5/thumbnails/27.jpg)
26. What is the output of thefollowing program?
main(){
char a[4]=“HELLO”;printf(“%s”,a);
}
![Page 28: C programs pbq final](https://reader031.fdocuments.us/reader031/viewer/2022020208/55b7fa61bb61eb006d8b4733/html5/thumbnails/28.jpg)
27.What is the output of thefollowing program?
void main(){
int const * p=5;printf("%d",++(*p));
}
![Page 29: C programs pbq final](https://reader031.fdocuments.us/reader031/viewer/2022020208/55b7fa61bb61eb006d8b4733/html5/thumbnails/29.jpg)
28.What is the output of the following program?
main(){
char s[ ]=“man”;int i;
for(i=0;s[ i ];i++)printf(“\n%c%c%c%c”,s[ i ],*(s+i),*(i+s),i[s]);
}
![Page 30: C programs pbq final](https://reader031.fdocuments.us/reader031/viewer/2022020208/55b7fa61bb61eb006d8b4733/html5/thumbnails/30.jpg)
29.What is the output of the following program?
main(){
char *p;printf(“%d %d ”,sizeof(*p),sizeof(p));
}
![Page 31: C programs pbq final](https://reader031.fdocuments.us/reader031/viewer/2022020208/55b7fa61bb61eb006d8b4733/html5/thumbnails/31.jpg)
30. What is the output of thefollowing program?
#define int char
main(){
int i=65;printf(“sizeof(i)=%d”,sizeof(i));
}