C Program to Calculate Sum of Natural Numbers from beginning




C Program to Find the Sum of First N Natural Numbers

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

int n,sum = 0;

    printf("Enter any positive number: ");
    scanf("%d",&n);

    for(i=1;i<=n;i++){
        sum = sum + 1;
    }

printf("Sum of n numbers: %s",sum);

    return 0;
}




Post a Comment