C Programming and Technical

output?
#define clrscr() 100
main()
{
clrscr();
printf("%dn",clrscr());
}

A. 100

Explanation: Preprocessor executes as a seperate pass before the execution of the compiler.
So textual replacement of clrscr() to 100 occurs. The input program to compiler looks like this :
main()
{
100;
printf("%dn",100

Read Solution (Total 0)

C Other Question

output?
main()
{
char *p="hai friends",*p1;
p1=p;
while(*p!='') ++*p++;
printf("%s %s",p,p1);
}

Answer. ibj!gsjfoet

Explanation: ++*p++ will be parse in the given order
_ *p that is value at the location currently pointed by p will be taken
_ ++*p the retrieved value will be incremented
_ when; is encountered the location will be incremented that is p++ will be executed Hence, in
the while loop initial value pointed by p is ‘h’, which is changed to ‘i’ by executing ++*p and
pointer moves to point, ‘a’ which is similarly changed to ‘b’ and so on. Similarly blank space is
converted to ‘!’. Thus, we obtain value in p becomes “ibj!gsjfoet” and since p reaches ‘’ and p1
points to p thus p1doesnot print anything
output??
main()
{
41printf("%p",main);
}8

Answer: Some address will be printed.

Explanation: Function names are just addresses (just like array names are addresses). main() is also a function. So the address of function main will be printed. %p in printf specifies that the argument is an address. They are printed as hexadecimal numbers.