I am having issues with trying to read in a float variable – it only prints out the numbers after the decimal point.
Here is my code:
#include <stdio.h>
int main() {
int num;
float fnum;
printf("type: ");
scanf("%d %f", &num, &fnum);
printf("You typed: %d (integer), %f (float)n", num, fnum);
return 0;
}
I’m getting this as output:
type: 4.556 4
You typed: 4 (integer), 0.556000 (float)
New contributor
skibidifortnite is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.