My book says "Statements can be divided over any number of lines. The following statement for example, is so long that it would be hard to squeeze it onto a single line."
printf ("Dimensional weight (pounds): %d\n",
(volume + cubic_in_per_lb - 1 / cubic_in_per_lb) ;
As you can see above, the part of the statement that printf actually "prints", which is between the quotations is all in the first line.
My book also shows this statement,
printf ("To C, or not to C: ") ;
printf ("that is the question. \n) ;
This "to C or not to C" also prints the two lines together when the program is run.
I have taken my below code, which was a working proven code before, and I just changed the last printf to be a very long statement, just to experiment and see how it would output, but no matter what I tried, I couldn't get it to work. This particular code doesn't compile, but I have done a few diff things, such as paranthesizing each line, and also added the printf to the last two lines, etc. In those other experiments, it would compile, but when conditions further up were tested and were true, sometimes my compiler would print the correct printf, and also part of the printf from the last two lines at the bottom.
Sorry to be so confusing, it's probably difficult to know exactly what I mean, but anyway, what must I do to that last long printf to make it all print, without part of it printing for another unrelated printf. I know I can put it all on one long line, my text editor will allow me to write a very long line, but I'm trying to figure out how to split up the line into shorter parts and have it compile and run the same. My book says it can be done as above, but I have tried to make mine look like those examples but it didn't work. If you need further evidence, I will rewrite the code a couple times, compile, then copy past the results if need be.
printf ("Dimensional weight (pounds): %d\n",
(volume + cubic_in_per_lb - 1 / cubic_in_per_lb) ;
As you can see above, the part of the statement that printf actually "prints", which is between the quotations is all in the first line.
My book also shows this statement,
printf ("To C, or not to C: ") ;
printf ("that is the question. \n) ;
This "to C or not to C" also prints the two lines together when the program is run.
I have taken my below code, which was a working proven code before, and I just changed the last printf to be a very long statement, just to experiment and see how it would output, but no matter what I tried, I couldn't get it to work. This particular code doesn't compile, but I have done a few diff things, such as paranthesizing each line, and also added the printf to the last two lines, etc. In those other experiments, it would compile, but when conditions further up were tested and were true, sometimes my compiler would print the correct printf, and also part of the printf from the last two lines at the bottom.
Sorry to be so confusing, it's probably difficult to know exactly what I mean, but anyway, what must I do to that last long printf to make it all print, without part of it printing for another unrelated printf. I know I can put it all on one long line, my text editor will allow me to write a very long line, but I'm trying to figure out how to split up the line into shorter parts and have it compile and run the same. My book says it can be done as above, but I have tried to make mine look like those examples but it didn't work. If you need further evidence, I will rewrite the code a couple times, compile, then copy past the results if need be.
Code:
#include <stdio.h>
main ()
{
int velocity ;
printf ("Enter wind velocity (knots): ") ;
scanf ("%d", &velocity) ;
if (velocity < 1 )
printf ("Conditions are calm.\n") ;
else if (velocity < 4 )
printf ("Conditions are light.\n") ;
else if (velocity < 28 )
printf ("Conditions are breezy.\n") ;
else if (velocity < 48 )
printf ("Conditions are gale, monitor conditions closely.\n") ;
else if (velocity < 64 )
printf ("Conditions are stormy, take precautions.\n") ;
else if (velocity > 63 )
printf ("Hurricane conditions, seek shelter,
immediately, call 800-555-8733 for safety information,
and the location of your nearest shelter.\n") ;
return 0 ;
}