I barely know what I\'m doing, I have this code where I try to solve some simple math:
#include
#include
#include
Corrected code (fixes as pointed out in the comments):
#include<stdio.h>
//#include<conio.h> // You don't use anything from these headers (yet?)
//#include<stdlib.h>
//main()
int main() // main has to be defiend as an int function
{
int n, sum = 0;
printf("ENTER NUMBER:");
// scanf("%i", n);
scanf("%i", &n); // scanf need the ADDRRESS of variables
while (n > 0)
{
sum += n;
n--;
}
// printf("\n sum is:", sum);
printf("\n sum is: %i", sum); // printf needs a format specifier for each variable
return 0;
}
The compiler is warning you that you forgot to specify the field for sum in the format string. You probably wanted:
printf("\n sum is: %d",sum);
As above, it will not print the sum, and the sum value will not be used. Hence the warning.