Tuesday, 31 July 2018

Series Menu

===========================================================================
                                CODING



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

void main()
{
int n,m;
float S;
clrscr();
cout<<"\nQ)What to find Sum:-";
cout<<"\n  1:- 1+2+3+....+n";
cout<<"\n  2:- 1ý+2ý+3ý+....+ný";
cout<<"\n  3:- (1+2+3+....+n)ý";
cout<<"\n\n¯What kind of Series do you select:- ";
cin>>m;
switch(m)
{
case 1:
cout<<"\n Enter last term(n): ";
cin>>n;
S=n*(n+1)/2.0;
cout<<"\n The sum of the Series is: "<<S;
break;
case 2:
cout<<"\n Enter last term(n): ";
cin>>n;
S=n*(n+1)*(2*n+1)/6.0;
cout<<"\n The sum of the Series is: "<<S;
break;
case 3:
cout<<"\n Enter last term(n): ";
cin>>n;
S=pow(n*(n+1)/2.0,2);
cout<<"\n The sum of the Series is: "<<S;
break;
default: cout<<"Wrong input!!!!";
}
getch();
}



===========================================================================


                                OUTPUT



No comments:

Post a Comment