Professional Documents
Culture Documents
printf("test %s\n", NULL); printf("test %s\n", NULL); prints: test (null) test (null) test 2: printf("%s\n", NULL); printf("%s\n", NULL); prints Segmentation fault (core dumped) what is the difference in the above tests ? Why is segmentation fault not thrown in test 1 above ?
0
of 0 votes
32
Answers
What is wrong with this program : main() { char *p,*q; p=(char *)malloc(25); q=(char*) malloc(25); strcpy(p,"amazon" ); strcpy(q,"hyd"); strcat(p,q); printf("%s",p); }
0
of 0 votes
22
Answers
What s the error in this snippet. main() { extern int i; i=20; printf("%d", i); }
What is the o/p explain. main() { float me = 1.1; double you = 1.1; if(me==you) printf("I love U"); else printf("I hate U"); }
find the error .. main() { float me = 1.1; double you = 1.1; if(me==you) printf("I love U"); else
main() sturct date { char name[20]; int age ; float sal; }; sturct data d ={"rajesh"}; printf("%d%f",d.age,d.sal); } tell the output & explain
9.What is the error : main() {int j=10; switch(j) { case 20: pritnf("Less than 20"); break; case 30: printf("Less than 30"); break; default: printf("hello"); } 15.main() { int i; if(i=0) //it,s assisnment not logical operator printf(" Hell "); else printf("Heaven"); } Output & explain..
;) 1
; =
ed
m u
n i n , u mb e r } # i n c l u # m a i n ( ) { i n t f i i p s r i n t f ( " i ed d i
} # i # m a { i n f i i t l e s s " % p i r ( f t n } # # i m a i n ) ( i
s h
{ i ; n t = < = 1 i ;+ % = i } # i n c lu # i m a i n ( ) { i ; n t f e d
: 0 p r
esa c */ esa c
: 1 p i r n o w } }
i n { i n i * n p t o i n t e r ;
po i
tn
a= b c / s * 3 * e t= pr = % a " ( f t n i }
c o
When you have an if-else statement nested in another if statement, always put braces around the if-else. Thus, never write like this:
i fa ) r b ( e l l ose ( ; )
s takes c a n pointers to the variables that are going to be set. The following