#include<conio.h>
#include<iostream.h>
float sum_of_series(float x);
void main()
{ clrscr();
float x,y;
cout<<"Enter no. of terms ";
cin>>x;
y=sum_of_series(x);
cout<<"Sum of "<<x<<" terms of Series = "<<y;
getch();
}
float sum_of_series(float x)
{ float sum=0;
for (int i=1;i<=x;i++)
{ sum=sum+i;
}
return(sum);
}
#include<iostream.h>
float sum_of_series(float x);
void main()
{ clrscr();
float x,y;
cout<<"Enter no. of terms ";
cin>>x;
y=sum_of_series(x);
cout<<"Sum of "<<x<<" terms of Series = "<<y;
getch();
}
float sum_of_series(float x)
{ float sum=0;
for (int i=1;i<=x;i++)
{ sum=sum+i;
}
return(sum);
}
No comments:
Post a Comment