Wap to find sum of first 10 odd numbers

/*write a c program to add first 10 odd numbers*/

#include<stdio.h>
#include<conio.h>

void main()

{
 int n,sum=0;
 clrscr();
 printf("sum of first 10 odd numbers");
  for(n=1;n<=20;n=n+2)
  {
   sum=sum+n;
  }
  printf("sum:%d",sum);
 getch();
}

No comments:

Post a Comment