Back To C++ User Defined Functions Index
//program to create a function that calculates sum of numbers between two numbers a and b (a nd b are passed to function as integer arguments ) #include
#include
void sum(int,int); void sum(int a,int b) { int sum=0; int i; for(i=a;i<=b;i++) { sum=sum+i; } cout<<"sum of numbers between a and b is "<
>a; cout<<"enter value for b"; cin>>b; sum(a,b); getch(); }