#include<stdio.h>
main()
{
int num,sum=0,i=1;
printf("\nEnter a number=");
scanf("%d",&num);
while(i<=num)
{
sum+=2*i-1;
i++;
}
printf("\nThe sum =%d",sum);
}
main()
{
int num,sum=0,i=1;
printf("\nEnter a number=");
scanf("%d",&num);
while(i<=num)
{
sum+=2*i-1;
i++;
}
printf("\nThe sum =%d",sum);
}
No comments:
Post a Comment