This repository has been archived on 2023-10-26. You can view files and clone it, but cannot push or open issues or pull requests.
VSMechatronics/Exercises/C7/Scanf2/scanf_example_2.c

28 lines
745 B
C

#include <stdio.h>
int main(void)
{
// Declare some variables
int a,b,c;
float f,g;
// Use printf to prompt the use to enter 3 integers
printf ("Please enter three integer\n");
// use scanf with %d to read into a, b and c
scanf ("%d %d %d",&a, &b, &c); // note the important &
// And display on the screen
printf ("The values entered were %d %d %d\n", a, b, c);
// Use printf to prompt the use to enter an float
printf ("Please enter two floats\n");
// use scanf with %f to read into f ang g
scanf ("%f %f",&f, &g); // note the important &
// And display on the screen
printf ("The value you entered were %f and %f \n", f,g);
return 0; // Exit from main
}