C.Sum of first 10 natural numbers using while loop

 #include<stdio.h>

int main()

{

   int j,sum=0;

   printf("The first 10 natural number is:\n");

   while(j<10)

{

    j++;

    sum=sum+j;

    printf("%d",j);

}

printf("\n The sum is %d",sum);

return 0;

}

Comments