The sum of n number of odd natural number in C | Free code Center

The sum of n number of odd natural number in C

Write a C program to display the n terms of odd natural numbers and their sum.
like: 1 3 5 7 … n

#include<stdio.h>
void main ()
{
    int i,n,odd=0,sum=0;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
if(i%2!=0){
    printf ("%d",i);
sum=i+n;
}

}

    printf("\nThe odd numbers are :%d\n",i);
    printf("The Sum of odd Natural Numbers upto 10 terms : %d\n",sum);
}

C programming examples 

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top
NEW TOXIC ROCKET CYCLE DECK in Clash Royale 2023 Best Deck in Clash Royale Best Deck for Arena 8 in Clash Royale Best Hog deck for Pro players Best Clash Royale Deck