Friday, July 31, 2009

Wat the ans & why on c pbm?

main()


{


int i=0,n=6;


while(n--%26gt;0);


i+=n;


printf("%d\n",i);


}





Ans: -1





a=3,b=2,c=1;


What's the value of k?


k= a%26lt; b %26lt; c-1;


k=0








main()


{


int sum=0,count;


for(count=1;sum+=count)


printf("%d\t",sum);


}


Ans: Error

Wat the ans %26amp; why on c pbm?
For First you place while(n--%26gt;0); ( ie) Loop finish with there so the answer is -1 where as is post decrement loop





Second ; the condition false for comparing two value so it is 0 return so K = 0





third : your syntax is false for For loop
Reply:-1


coz last loop wud check 0--%26gt;0 which is false so out of loop with n=-1


so i=-1








error becoz for loop needs a condition along with 3 statements which is not the case
Reply:first : you have place semi-colon at the end of While so it loop It self thats y its shows output -1 ( post decrement )





second : fist statement false ie a %26lt; b %26lt; c-1 but not ; generally c will execute from right to left so its return 0 as its value





Third : syntax is Wrong for Loop it need to has alleast "for ( ; ; )"

radiata

No comments:

Post a Comment