Computer Science, asked by BugB, 11 months ago

write a program to print first n odd numbers and their sum(while loop)​

Answers

Answered by aditimoulik2001
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