Tricky C Programs Collection
just write any tricy c code ...
as the game everyone will answer it ..
ok 1st my turn,,,
what will be the output of following code
#include<stdio.h>
int main()
{
printf("%d",printf("computer"));
return (0);
}
Member • Sep 19, 2013
Answer:computer8Gaurav v. Deshmukhhey guys ,
just write any tricy c code ...
as the game everyone will answer it ..
ok 1st my turn,,,
what will be the output of following code
#include<stdio.h>
int main()
{
printf("%d",printf("computer"));
return (0);
}
Member • Sep 19, 2013
Administrator • Sep 19, 2013
#include<stdio.h> int main() { printf("%d",printf("computer")); return (0); }
Member • Sep 20, 2013
#include<stdio.h> int main() { int i; for(i=0;i<5;i++) { int i = 10; printf("%d",i); } return (0); }
Member • Sep 20, 2013
Member • Sep 20, 2013
#include<stdio.h> int main() { int i; for(i=0;i<5;i++); { int i = 10; printf("%d",i); } return (0); }
Member • Sep 20, 2013
Rite dear😀
Member • Sep 20, 2013
Member • Sep 20, 2013
I think this thread is to give output of tricky codes, whereas in other one we have to give solutions for problems.Vishal0203I think "the CE coding challenge" thread is kinda same! why to have two of such threads? 😨
#include<stdio.h> int main() { int i=1; for(i=1,j=5;i<5;i++,j--) { printf("%c %c\n",i,j); } }
Member • Sep 20, 2013
Member • Sep 20, 2013
Actually I used C++ compiler so that multiple declaration didn't gave error (but will give error in C compiler)😁. So it's edited 👍.Shailaja Tiwari@#-Link-Snipped-# I guess multiple declaration of i=1 won't be allowed.
And u have to guess that weird o/p 😀Shailaja Tiwari@#-Link-Snipped-#
and %c (meant for characters) is not valid format specifier for printing integers.
So I guess the above program will give a wierd o/p.
Member • Sep 20, 2013
Member • Sep 20, 2013
Yes u are right. It will print different characters like smile face, diamonds, hearts etc.Shailaja Tiwaria number printed in %c format specifier would get converted to it's equivalent character in terms of ascii codes.So it might be a sort of symbols.
Correct me if i'm wrong.
Member • Sep 26, 2015
Member • Feb 29, 2016
Member • May 19, 2016
Shailaja Tiwaricheck the output of this code :
#include<stdio.h> int main() { static int i; for(i=0;i<5;i++); { static int i = 10; printf("%d",i); } return (0); }
Member • May 21, 2016
nareshkumar6539Answer:computer8
First it will print computer and printf() is a predefined function it will return how many characters printed In this case it is printing 8 characters it will return 8.
OutPut :computer8
Member • Sep 2, 2018
#-Link-Snipped-#Â
I think that i'll give a compile time error because the variable j is not declared
#include<stdio.h> int main(){ int i=1; for(i=1,j=5;i<5;i++,j--) { printf("%c %c\n",i,j); } }