Your main issue is that you declare all your variables as int
s, but smp2
and total
must hold floating point values.
Change your declarations to
int smp1;
double smp2, total;
unsigned int smp3;
This way, the types of the variables match up with the conversion specifiers used in the printf
and scanf
calls.
Types matter in C, and it’s up to you that the types of the arguments in each printf
and scanf
call match up with the conversion specifiers.
Check your compiler documentation on how to enable warnings (even better, to treat all warnings as errors). Most compilers should warn about type mismatches like this, but sometimes you have to set a flag in order for those warnings to appear.