0
What will be the output of the questions?( C programming)
#include<stdio.h> void main(){ int a=4,b=2; if( a^b==printf("practice")) printf("sucess"); else printf("c"); }
6 Answers
+ 1
Diptansu das put your a^b inside brackets like this (a^b) and the output would be practicec only.
+ 1
Output will be practicec.
Explanation:
printf returns the length of output. In this case length of "practice". As you can see it is 8 characters long.
8 is not equal to a^b so it will result "c" .
You have recently printed practice without a new line so the final output is practicec.
However if you changed a^b to a*b it will result in "success" as 4*2 is 8.
(edited. There was a mistake. I confused ^ as 'to the power of' as I was working with a lot of calculators lately rather than programming. :) It's fixed now)
+ 1
In if loop 1st it calculate xor of a and b (4^2=6) and second condition print success on screen and return no. Length of string ie 8
So 6==8 gives false
therefore else part get executed
Output : practicec
0
Diptansu das Why don't you run it and see for yourself. If you don't understand something then post it.
0
Actually the answer is not corr ct
0
Output will be : practicec