Sum of n natural numbers || do while loop || C Programming
In this, we are going to see the do-while loop, the program is based on the do-while loop which basically Prints sum of n natural numbers with the help of the C Programming language.
 



#include <stdio.h>
int main()
{

    int n, i = 1;
    int sum = 0;
    printf("Enter value of n to find sum upto that number\n");
    scanf("%d", &n);
    do
    {
        sum = sum + i;
        i++;
    } while (i <= n);
    printf("Sum of %d  natural numbers is %d", n, sum);
    return 0;
}

//..........Coded by ARADHANA MISHRA


#ENJOY CODING

Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post