If I run the code below it won't display the whole answer (last printf("")
is the answer). I would like to know why it doesn't display the whole answer. Does anyone know this problem?
#include <stdio.h>
int main()
{
int M,T,P,K,H;
printf("Teekonna pikkus:\n");
scanf("%u", &P);
printf("Tarbitud k\u00FCtuse kogus:\n");
scanf("%u", &K);
printf("K\u00FCtuse liitri hind:\n");
scanf("%u", &H);
T = K/(P/100);
M = K*H;
printf("Olete s\u00F5itnud %u", P," kilomeetrit ning kulutanud %u", K," liitrit kütust. Teie auto k\u00FCtusekulu oli %u", T," liitrit 100 kilomeetri kohta. S\u00F5idu maksumus oli %u", M," eurot.");
while(1);
}
while(1)
at the end of your program? First of all, lookupprintf
syntax. Thenprintf
is probably not flushing the string tostdout
, try adding a\n
at the end of the format string, or addfflush(stdout);
after theprintf
statement. Also, technically your program has undefined behavior because you have a infinite loop.