write a program to print first n odd numbers and their sum(while loop)
Answers
Answered by
0
Easy :)
Explanation:
#include<stdio.h>
void main(void)
{
int n,i=1,sum=0;
printf("\nEnter n :");
scanf("%d",&n);
while(i<=n)
{
sum+=i;
printf("\n%d",i);
i=i+2;
}
printf("\nSum is: %d",sum);
return;
}
Don’t hesitate to consult for doubt in the comments below and Don't forget to mark it the brainliest if it helps.. #BAL #answerwithquality
Similar questions
Social Sciences,
5 months ago
Social Sciences,
5 months ago
English,
5 months ago
Sociology,
11 months ago
Physics,
11 months ago
Chemistry,
1 year ago