#include<constream.h> void main() { int sum(); int x; clrscr(); x=sum(); cout<<"sum="<<x; getch(); } int sum() { int s=0,n,i; cout<<"\nenter n:"; cin>>n; for(i=0;i<=n;i++) s+=i; return s; }
Sunday, 7 December 2014
C++ program to print sum of first n numbers
Posted by Madan
Posted on 14:25