Computer Science, asked by kuldeeptripathi2912, 1 year ago

C++ program to find sum of first 10 natural numbers

Answers

Answered by Prathamattri2062
0
#include <iostream.h>
#include <conio.h>

void main( )
{
clrscr ( );
cout<<"Press Enter to see Sum of first ten natural numbers";
clrscr ( );
int a,d,n,S;
a = 1;
d = 1;
n = 10;
S = (n*(2a + (n-1)*d) ) /2;
cout<<"The sum of first 10 natural numbers is "<< S;
getch ( );
}


OR


#include <iostream.h>
#include <conio.h>

int main(void)
{
clrscr ( );
cout<<"Press Enter to see Sum of first ten natural numbers";
clrscr ( );
int a,d,n,S;
a = 1;
d = 1;
n = 10;
S = (n*(2a + (n-1)*d) ) /2;
cout<<"The sum of first 10 natural numbers is "<< S;
getch ( );
return 0;
}
Similar questions