C.Sum of first 10 natural numbers using for loop

 


#include<stdio.h>

int main()

{

   int j,sum=0;

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

      for (j=1;j<=10;j++)

   {

       sum=sum+j;

       printf("%d ",j);

   }

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

return 0;

}

Comments