c
-
-
i'm a newbie in IT and i'm learning C program.i'm wrote this code and it has error message. -------
#include <stdio.h>
#include <conio.h>
void main()
{
int n,i;
long s;
scanf ("%d" ,&n);
s=0;
i=1;
while (i<=n)
{
s=s+i;
i=i+1;
}
printf("%ld",s);
}What is the error message you are getting? Also, in future posts, use a more descriptive subject line, and place in the correct forum since you have a C program problem and this is the C# forum.
"I've seen more information on a frickin' sticky note!" - Dave Kreskowiak
-
What is the error message you are getting? Also, in future posts, use a more descriptive subject line, and place in the correct forum since you have a C program problem and this is the C# forum.
"I've seen more information on a frickin' sticky note!" - Dave Kreskowiak
-
i'm a newbie in IT and i'm learning C program.i'm wrote this code and it has error message. -------
#include <stdio.h>
#include <conio.h>
void main()
{
int n,i;
long s;
scanf ("%d" ,&n);
s=0;
i=1;
while (i<=n)
{
s=s+i;
i=i+1;
}
printf("%ld",s);
}I just built and ran your code and there are no error messages. There is one warning about using
scanf_s
instead ofscanf
, but that can be safely ignored for now. I suggest you post the full details in the C forum, making sure you include the exact text of the error message.