Tricky C Programs Collection
hey 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
int main()
{
printf("%d",printf("computer"));
return (0);
}
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
int main()
{
printf("%d",printf("computer"));
return (0);
}
Replies
-
nareshkumar6539
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
int main()
{
printf("%d",printf("computer"));
return (0);
}
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 Tiwarianswer 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.
-
Kaustubh KatdareNote: Please wrap your code in
[code]
.....
[/code]
tags so that it looks nice and properly formatted 😀
Example:
#include
int main() { printf("%d",printf("computer")); return (0); } -
Gaurav Deshmukhtry out for this guys....
give the o/p of following program....
and also write some tricky program as reply😀..
#include
int main() { int i; for(i=0;i<5;i++) { int i = 10; printf("%d",i); } return (0); } -
Shailaja TiwariWell i' value will be printed 5 times.
1010101010(as no space and newline demand in your program). -
Shailaja Tiwaricheck the output of this code :
#include
int main() { int i; for(i=0;i<5;i++); { int i = 10; printf("%d",i); } return (0); } -
Gaurav Deshmukh
Rite dear😀
-
Vishal SharmaI think "the CE coding challenge" thread is kinda same! why to have two of such threads? 😨
-
rahul69
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? 😨
Here is another one:
Give the output of the following program:
#include
int main() { int i=1; for(i=1,j=5;i<5;i++,j--) { printf("%c %c\n",i,j); } } -
Shailaja Tiwari@#-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
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. -
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. -
rahul69
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.
😀 -
Ashutosh TripathyCan any one show me a better kind of tricky c program?
-
krishna vamsi ChinnapaReddyv
vr
vrs
vrse
vrsec
vrse
vrs
vr
v -
sunilmitShailaja Tiwaricheck the output of this code :
#include
int main() { static int i; for(i=0;i<5;i++); { static int i = 10; printf("%d",i); } return (0); } -
nikhila golinareshkumar6539Answer: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 Jain
#-Link-Snipped-#Â
I think that i'll give a compile time error because the variable j is not declared
#includeint main(){ int i=1; for(i=1,j=5;i<5;i++,j--) { printf("%c %c\n",i,j); } }
You are reading an archived discussion.
Related Posts
By shifting the solar panel inside the aerodynamically designed shell, Cambridge University students have upped the ante on the
October’s World Solar Challenge, a gruelling four-day-long, 3,000km race across the...
MIT ha scome up with Hyperform that makes 3D printing of large bojects literally a snap. This radically different approach can dramatically change 3D printing nad herald a major advance....
The Telegraph of UK has published this interesting gallery of pictures showing the 150 years history of the London Tube Railway. Amazing engineering of yester years.
https://www.telegraph.co.uk/travel/p...ears-of-London-Underground.html?frame=2447187
(Originally posted by...
Quote:
Multiple entries are accepted, but each entrant can only win one prize. Contest is open to entries from US, Canada [excluding Quebec], UK, China, Belgium, the Netherlands, Australia, Colombia,...
We've been receiving serious concerns over the news items being shared for the sake of creating new threads and accumulating points for CEoM contest.
We need to address this concern....