/*to find the sum of first n odd natural number*/
#include<stdio.h>
#include<stdlib.h>
int main( )
{
int i,j=1,n,sum=0;
printf ("enter n: ");
scanf ("%d",&n);
for (i=1; i<=n; i++)
{
sum+=j;
j+=2;
}
printf ("\nsum of odd natural number=%d",sum);
system ("pause");
return 0;
}
your program is not working idiot
ReplyDeleteThe logic is basically the same in every C compiler as for me, I'm using DEV C++ compiler. I think you're using Turbo C++ so it's not working.
Delete