Click here to Skip to main content
15,891,851 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
C
main() {
   double=1/2.0-1/2;
   printf("d=%.21f",d);
}

Output: 0.50000000000000


shouldn't it be 0?

C
main() {
   int a=5;
   a=printf("Good")
   printf("%d",a);
}

Output:Good4


How come this?

C
main() {
   printf("\nab");
   printf("\bsi");
   printf("rha");
}

Output:hai


How?
Posted
Updated 21-Jun-15 7:43am
v2
Comments
Andreas Gieriet 21-Jun-15 13:46pm    
Homework assignment?
What does your text book tell about your questions?
You learn most if you do your homework yourself.
Regards
Andi
[no name] 21-Jun-15 20:14pm    
They are all correct.

You should do some basic learning about C and especially the use of formatters in printf. It isnt a easy deal and needs some pratice.

Tip: The blackslash is a control character and leads to special behaviour. like "\n" means "new line" like hitting Enter.

Please read some hours and play around with that stuff. ;-)
 
Share this answer
 
For your first problem. Look up operator precedence.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900