1)
#include<stdio.h>
void main()
{
int i;
for(;scanf("%d",&i);printf("%d",i))
;
}
void main()
{
int i;
for(;scanf("%d",&i);printf("%d",i))
;
}
O/p: the for loop will be executed infinite number of times.\
eg:
8
8
10
10
2)
#include<stdio.h>
void main()
{
extern int i;
i=20;
printf("%d",sizeof(i));
}
// O/p: error. because extern int i is a declaration and not a definition.
void main()
{
extern int i;
i=20;
printf("%d",sizeof(i));
}
// O/p: error. because extern int i is a declaration and not a definition.
3)
#include<stdio.h>void main()
{
extern int a;
printf("%d",a);
}
int a=20;
//Output :: 20
4)
#include<stdio.h>
void main()
{
char *s1;
char far *s2;
char near *s3;
char huge *s4;
printf("%d %d %d %d", sizeof(s1),sizeof(s2),sizeof(s3),sizeof(s4));
}
// Output : 4 4 2 4
void main()
{
char *s1;
char far *s2;
char near *s3;
char huge *s4;
printf("%d %d %d %d", sizeof(s1),sizeof(s2),sizeof(s3),sizeof(s4));
}
// Output : 4 4 2 4
No comments:
Post a Comment