Question: (Printing Values with printf) Write a program that prints the numbers 1 to 4 on the same line. Write the program using the following methods.
- Using one printf statement with no conversion specifiers.
- Using one printf statement with four conversion specifiers.
- Using four printf statements.
1 2 |
/* <br /> * Author: AGHATISE OSAZUWA<br /> * Website: www.cscprogrammingtutorials.com<br /> *<br /> * Program that prints the numbers 1 to 4 on the same line using three<br /> * different methods.<br /> */<br /><br />#include <stdio.h><br />int main ( ){<br /> printf("1 2 3 4n");<br /> printf("%d %d %d %dn", 1, 2, 3, 4);<br /> printf("1 ");<br /> printf("2 ");<br /> printf("3 ");<br /> printf("4n");<br /> return 0;<br />}<br /> |
Program output |
Click here to see other solutions to Deitel C How To Program exercises.