Sie sind auf Seite 1von 1

//WAP to find out sum of n natural numbers using for loop. #include<iostream.h> #include<conio.

h> main() { int i,n,sum; cout<<"\n Enter the value of n :"<<endl; cin>>n; sum=0; for(i=1;i<=n;i++) sum=sum+i; cout<<"sum="<<sum; getch(); }

Das könnte Ihnen auch gefallen