Recent Posts
printf("ho_tari\n");
sumOne2Ten 본문
#include <stdio.h>
int main(void)
{
int total = 0;
int i = 1;
while (i <= 10)
{
total += i; // total = total + i;
++i;
}
/*
int i;
i = 1;
while (i <= 10)
{
total = total + i + i + 1;
i = i + 2;
}
*/
printf("sum : %d\n", total);
return 0;
}
#include <stdio.h>
int main(void)
{
/*
int total = 0;
int i = 1;
while (i <= 10)
{
total += i; // total = total + i;
++i;
}
*/
int total = 0;
for (int i = 1; i <= 10; ++i)
{
total += i;
}
printf("sum: %d\n", total);
/*
int i;
i = 1;
while (i <= 10)
{
total = total + i + i + 1;
i = i + 2;
}
*/
//printf("sum : %d\n", total);
return 0;
}
<compile 결과>