C Program take multiple inputs same line
I want to be able to enter three integers as lengths of a triangle and store them in side1, side2 and side3 in the order they're entered.
Ex.
Enter the sides of the triangle: 3 4 5
stores 3 in side1
stores 4 in side2
stores 5 in side3
What is the correct format of doing so?
Code:
#include <stdio.h>
/* function main begins program execution */
int main()
{
int side1;
int side2;
int side3;
printf( "Enter the sides of the triangle: " ); //prompt
scanf( "%d", &side1, &side2, &side3 ); //reads integers
printf("Your sides are: ", side1, side2, side3);
return 0;
}
|