Professional Documents
Culture Documents
Sol:
Using printf
Example: What is the output from the following program?
Sol:
Using printf
Example: Write printf statement(s) to print the following:
Sol:
printf("Where the mind is without fear\n\n");
printf("And the head is held high\n");
or
printf("Where the mind is without fear\n");
printf("\nAnd the head is held high\n");
or
printf("Where the mind is without fear\n");
printf("\n");
printf("And the head is held high\n");
Using printf
Example: Write printf statement(s) to print the following:
Sol:
printf("Use \" to begin and end a string\n");
Prompting Messages
This statement displays the literal "Enter first integer" and positions
the cursor to the beginning of the next line.
This message is called a prompt because it tells the user to take a
specific action.
Variables
All variables must be defined with a name and a data type before
they can be used in a program.
The C standard allows you to place each variable definition
anywhere in main before that variable’s first use in the code.
For example:
Keywords are reserved, that is, you cannot use them as your
identifiers.
Examples of invalid Identifiers:
identifiers
Examples of valid Identifiers: