So first of my program is written in a foreign language, sorry about that.
What i'm trying to program is a calculator that sums upp numbers. And the program will terminate when the user writes a negative number.
I have been able to construct the first part of the program. the part which sums up float/int numbers. but where i have run into a problem is the second part, which is to find the largest number.
Code:#include <stdio.h> #include <stdlib.h> #include <time.h> int main () { float tal, summan=0, max=0; int i; for (;;) { printf("Skriv in ett tal att summera: "); scanf("%f", &tal); if (tal>=0) { summan+=tal; printf("Summan är: %.2f\n", summan); } else break; } for (i=0; i<tal; i++) { if (max<tal) { max=tal; printf("Det största inmatade talet var %.2f\n", max); } } return 0; }