Replies
Welcome, guest
Join CrazyEngineers to reply, ask questions, and participate in conversations.
CrazyEngineers powered by Jatra Community Platform
-
@nareshkumar6539-BKuVbx • Sep 19, 2013
Gaurav 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);
}Answer: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 -
@shailaja-tiwari-lKhGjd • Sep 19, 2013
answer is computer8 as printf will return the number charcters enclosed within it's function parentheses and one clue is the format specifier %d that is usually used with numbers.
-
@thebigk • Sep 19, 2013
Note: Please wrap your code in
[code]
.....
[/code]
tags so that it looks nice and properly formatted 😀
Example:
#include<stdio.h> int main() { printf("%d",printf("computer")); return (0); } -
@gaurav-ToXXkA • Sep 20, 2013
try out for this guys....
give the o/p of following program....
and also write some tricky program as reply😀..
#include<stdio.h> int main() { int i; for(i=0;i<5;i++) { int i = 10; printf("%d",i); } return (0); } -
@shailaja-tiwari-lKhGjd • Sep 20, 2013
Well i' value will be printed 5 times.
1010101010(as no space and newline demand in your program). -
@shailaja-tiwari-lKhGjd • Sep 20, 2013
check the output of this code :
#include<stdio.h> int main() { int i; for(i=0;i<5;i++); { int i = 10; printf("%d",i); } return (0); } -
@gaurav-ToXXkA • Sep 20, 2013
Rite dear😀
-
@vishal-pysGmK • Sep 20, 2013
I think "the CE coding challenge" thread is kinda same! why to have two of such threads? 😨
-
@rahul69-97fAOs • Sep 20, 2013
Vishal0203I think "the CE coding challenge" thread is kinda same! why to have two of such threads? 😨
I think this thread is to give output of tricky codes, whereas in other one we have to give solutions for problems.
Here is another one:
Give the output of the following program:
#include<stdio.h> int main() { int i=1; for(i=1,j=5;i<5;i++,j--) { printf("%c %c\n",i,j); } } -
@shailaja-tiwari-lKhGjd • Sep 20, 2013
@#-Link-Snipped-# I guess multiple declaration of i=1 won't be allowed.
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. -
@rahul69-97fAOs • Sep 20, 2013
Shailaja Tiwari@#-Link-Snipped-# I guess multiple declaration of i=1 won't be allowed.
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-#
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.And u have to guess that weird o/p 😀
-
@shailaja-tiwari-lKhGjd • Sep 20, 2013
a 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. -
@rahul69-97fAOs • Sep 20, 2013
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.Yes u are right. It will print different characters like smile face, diamonds, hearts etc.
😀 -
@ashutosh-0dVf7M • Sep 26, 2015
Can any one show me a better kind of tricky c program?
-
@krishna-vamsi-VN90ls • Feb 29, 2016
v
vr
vrs
vrse
vrsec
vrse
vrs
vr
v -
@sunilmit-XRUPLd • 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); } -
@nikhila-qQeKdQ • 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 -
@anshul-cKlY2E • 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); } }