/*This program is a very basic one, but still a quite long use, making it useful for learning*/
/* I HAVE WRITTEN THIS BY MYSELF, and I give FULL RIGHTS TO ANYONE willing to take this code for learning purpose, or for experimenting with this! And, 'please' don't use this for "copy&paste" purposes*/
#include<iostream>
#include<conio.h>
#include<math.h>
#include<stdlib.h>
#define 1/0 Not_Defined
using namespace std;
void delay(void)
{
for(int i=0;i<3000;i++)
for(int j=0;j<9090;j++) {}
}
void expan(void);
long double fact(long int a);
//long double pow(long int x,long int y) has been removed by me due to no need
void pac();
void trigo(void);
void genac();
int main()
{
float a,b; long int x,n,p,choice;
punarvichaar:
clrscr();
cout<<"Enter : "<<endl<<"@ 1 for expansion of (1+x)^n"<<endl
<<"\n@ 2 for factorial calculation"<<"@ 3 for power calculation"<<endl<<"@ 4 Permutations and Combinations"<<endl
<<"@ 5 for Trigonometric calculations"<<"\n@ 6 for General Arithmetic Calculations and others"<<"\n@ 7 To exit"<<"\n\n";
cin>>choice;
switch(choice)
{
case 1: clrscr(); expan();
break;
case 2: clrscr();
cout<<"\n\nEnter the number : "<<"\n";
cin>>a;
cout<<endl<<fact(a)<<endl;
break;
case 3: clrscr();
cout<<"\n\nEnter number and power:";
cout<<"\nNumber : "; cin>>a;
cout<<"\nPower : " ; cin>>b;
cout<<"\n\n"<<a<<" to the power "<<b<<" is "<<"\n"<<pow(a,b); break;
case 4: clrscr();
pac();
break;
case 5: clrscr();
trigo();
break;
case 6: clrscr();
genac();
break;
default: cout<<endl<<"Kripya phir se prayas kare...@-@"<<endl;
delay(); goto punarvichaar;
break; }
getch();
}
void expan(void)
{
int x,n;
cout<<"\n\nEnter the values of x and n [in computation of (1+x)^n]";
cout<<"\n\n x : "; cin>>x;
cout<<"\n\n n : "; cin>>n;
long double exp=0.0;
for(long double i=0;i<=97675684;i++)
{
exp+=fact(n)*pow(x,i-1)/(fact(i)*fact(n-i));
}
cout<<"\n\n"<<exp;
}
long double fact(long int a)
{
long double factorial=1;
while(a!=0)
{ factorial*=a;
a--; }
return factorial;
}
//long double pow(long int x,long int y) has been removed by me due to no need
void pac(int n,int r)
{
clrscr();
cout<<"\n\nEnter the number of total objects(index), and the no. of places(r)";
cout<<"\nIndex(n) : "; cin>>n;
cout<<"\nNo. of Places(r) : "; cin>>r;
cout<<"\n\nPermutations : "<<fact(n)/fact(n-r);
cout<<"\n\nCombinations : "<<fact(n)/(fact(r)*fact(n-r));
cout<<"\n\nCircular Permutations : "<<fact(n-1)/(fact(r-1)*fact(n-r));
}
void trigo(void)
{
clrscr();
int ch,x;
cout<<"Enter what u need (Enter 1,2,3 or 4):"<<"\n\n1. Claculation of Trigonometric Functions"<<"\n\n2. Calculation of T-functions for Half Angles"
<<"\n\n3. Lenght of sides of triangles if any two/one is given"<<"\n\n4. Back to main menu"<<"\n\n";
switch(ch)
{
case 1: cout<<"Enter the value of x (in radians)"; cin>>x;
cout<<"\n\nsinx = "<<sin(x);
cout<<"\n\ncosx = "<<cos(x);
cout<<"\n\ntanx = "<<tan(x);
cout<<"\n\ncosecx = "<<1/sin(x);
cout<<"\n\nsecx = "<<1/cos(x);
cout<<"\n\ncotx = "<<1/tan(x);
break;
case 2: cout<<"Enter the value of x (in radians)"; cin>>x;
cout<<"\n\nsin(x/2) = "<<sin(x/2);
cout<<"\n\ncos(x/2) = "<<cos(x/2);
cout<<"\n\ntan(x/2) = "<<tan(x/2);
cout<<"\n\ncosec(x/2) = "<<1/sin(x/2);
cout<<"\n\nsec(x/2) = "<<1/cos(x/2);
cout<<"\n\ncot(x/2) = "<<1/tan(x/2);
break;
case 3: cout<<"Enter the lenght of two sides";
break;
case 4: break;
}
}
void genac(void)
{
clrscr();
int a,b;
cout<<"This section will help you in arithmetic calculations"
<<"\n\nEnter two numbers one by one";
cin>>a>>b;
cout<<"\n\n"<<a<<" + "<<b<<" is : "<<a+b;
cout<<"\n\n"<<a<<" - "<<b<<" is : "<<a-b;
cout<<"\n\n"<<a<<" * "<<b<<" is : "<<a*b;
cout<<"\n\n"<<a<<" / "<<b<<" is : "<<a/b;
}
/*ANY suggestions will be very helpful, and btw its me who will be more benefited, so THANX for that*/ /*I WILL NOT CLAIM IT MINE, any suggestions will be a great help*/
/* I HAVE WRITTEN THIS BY MYSELF, and I give FULL RIGHTS TO ANYONE willing to take this code for learning purpose, or for experimenting with this! And, 'please' don't use this for "copy&paste" purposes*/
#include<iostream>
#include<conio.h>
#include<math.h>
#include<stdlib.h>
#define 1/0 Not_Defined
using namespace std;
void delay(void)
{
for(int i=0;i<3000;i++)
for(int j=0;j<9090;j++) {}
}
void expan(void);
long double fact(long int a);
//long double pow(long int x,long int y) has been removed by me due to no need
void pac();
void trigo(void);
void genac();
int main()
{
float a,b; long int x,n,p,choice;
punarvichaar:
clrscr();
cout<<"Enter : "<<endl<<"@ 1 for expansion of (1+x)^n"<<endl
<<"\n@ 2 for factorial calculation"<<"@ 3 for power calculation"<<endl<<"@ 4 Permutations and Combinations"<<endl
<<"@ 5 for Trigonometric calculations"<<"\n@ 6 for General Arithmetic Calculations and others"<<"\n@ 7 To exit"<<"\n\n";
cin>>choice;
switch(choice)
{
case 1: clrscr(); expan();
break;
case 2: clrscr();
cout<<"\n\nEnter the number : "<<"\n";
cin>>a;
cout<<endl<<fact(a)<<endl;
break;
case 3: clrscr();
cout<<"\n\nEnter number and power:";
cout<<"\nNumber : "; cin>>a;
cout<<"\nPower : " ; cin>>b;
cout<<"\n\n"<<a<<" to the power "<<b<<" is "<<"\n"<<pow(a,b); break;
case 4: clrscr();
pac();
break;
case 5: clrscr();
trigo();
break;
case 6: clrscr();
genac();
break;
default: cout<<endl<<"Kripya phir se prayas kare...@-@"<<endl;
delay(); goto punarvichaar;
break; }
getch();
}
void expan(void)
{
int x,n;
cout<<"\n\nEnter the values of x and n [in computation of (1+x)^n]";
cout<<"\n\n x : "; cin>>x;
cout<<"\n\n n : "; cin>>n;
long double exp=0.0;
for(long double i=0;i<=97675684;i++)
{
exp+=fact(n)*pow(x,i-1)/(fact(i)*fact(n-i));
}
cout<<"\n\n"<<exp;
}
long double fact(long int a)
{
long double factorial=1;
while(a!=0)
{ factorial*=a;
a--; }
return factorial;
}
//long double pow(long int x,long int y) has been removed by me due to no need
void pac(int n,int r)
{
clrscr();
cout<<"\n\nEnter the number of total objects(index), and the no. of places(r)";
cout<<"\nIndex(n) : "; cin>>n;
cout<<"\nNo. of Places(r) : "; cin>>r;
cout<<"\n\nPermutations : "<<fact(n)/fact(n-r);
cout<<"\n\nCombinations : "<<fact(n)/(fact(r)*fact(n-r));
cout<<"\n\nCircular Permutations : "<<fact(n-1)/(fact(r-1)*fact(n-r));
}
void trigo(void)
{
clrscr();
int ch,x;
cout<<"Enter what u need (Enter 1,2,3 or 4):"<<"\n\n1. Claculation of Trigonometric Functions"<<"\n\n2. Calculation of T-functions for Half Angles"
<<"\n\n3. Lenght of sides of triangles if any two/one is given"<<"\n\n4. Back to main menu"<<"\n\n";
switch(ch)
{
case 1: cout<<"Enter the value of x (in radians)"; cin>>x;
cout<<"\n\nsinx = "<<sin(x);
cout<<"\n\ncosx = "<<cos(x);
cout<<"\n\ntanx = "<<tan(x);
cout<<"\n\ncosecx = "<<1/sin(x);
cout<<"\n\nsecx = "<<1/cos(x);
cout<<"\n\ncotx = "<<1/tan(x);
break;
case 2: cout<<"Enter the value of x (in radians)"; cin>>x;
cout<<"\n\nsin(x/2) = "<<sin(x/2);
cout<<"\n\ncos(x/2) = "<<cos(x/2);
cout<<"\n\ntan(x/2) = "<<tan(x/2);
cout<<"\n\ncosec(x/2) = "<<1/sin(x/2);
cout<<"\n\nsec(x/2) = "<<1/cos(x/2);
cout<<"\n\ncot(x/2) = "<<1/tan(x/2);
break;
case 3: cout<<"Enter the lenght of two sides";
break;
case 4: break;
}
}
void genac(void)
{
clrscr();
int a,b;
cout<<"This section will help you in arithmetic calculations"
<<"\n\nEnter two numbers one by one";
cin>>a>>b;
cout<<"\n\n"<<a<<" + "<<b<<" is : "<<a+b;
cout<<"\n\n"<<a<<" - "<<b<<" is : "<<a-b;
cout<<"\n\n"<<a<<" * "<<b<<" is : "<<a*b;
cout<<"\n\n"<<a<<" / "<<b<<" is : "<<a/b;
}
/*ANY suggestions will be very helpful, and btw its me who will be more benefited, so THANX for that*/ /*I WILL NOT CLAIM IT MINE, any suggestions will be a great help*/
Comments
Post a Comment
You are free to leave any kind of suggestion, or improvement. It doesn't require you to sign in either.