Saturday, May 22, 2010

What is the O/P of the following C Program?

#include%26lt;stdio.h%26gt;


main()


{


char s[]={'a','b','c','\n','c','\0'};


char *p,*str,*str1;


p=%26amp;s[3];


str=p;


str1=s;


printf("%d",++*p + ++*str1-32);


}

What is the O/P of the following C Program?
*p = 'c';


p = {'c', '\0'... not sure what is originally written after that.


str = {'c', '\0'...


str1 = {'a', 'b', 'c', '\n', 'c', '\0'...


the printout


++*p, if written ++(*p) = '\0', value = 0;


++*str1, if written ++(*str1) = 'b', value = 98;


therefore


0 + 98 - 32 = 66 character: 'B';





Your print out should be the capital letter 'B';
Reply:77...thatz what it is givin me...it depends what comes after \n in the ASCII table and also what is 'b' + 32 in the table.
Reply:what the previous post said, but it is ACII value of the 'b' minus 32. Which is the ACII value of 'B'.
Reply:Answer is the Compilation Error for illegal pointer declaration and usage.

sweet pea

No comments:

Post a Comment