Skip to main content

The MultiMatics - A C++ Project

/*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*/

Comments

Popular posts from this blog

AP, GP Generator (using Linked List)

//Future advancements-> add save as file, in text or in a database option (for the sequences) //                      add more series to this //Programmer - Aditya Gupta #include<iostream> #include<stdlib.h> #include<math.h> //#include<fstream> //reqd when save support is added to this! using namespace std; struct Node{ int data; Node* next; }; void inline title(void){ system("cls"); cout<<"\tNAMASTE!...\n\nProgram-AP,GP Generator\nPrograammer - MR. ADITYA GUPTA (TEChY 3)\n\n"; } class List{ //NOTE: I HAVE REMOVED ALL COMMENTS, REFER TO THE LINKED LIST TEMPLATE FOR DETAILED COMMENTS             //here only generator specific comments are there, and that too which are not in template Node *top,*rear; public: void Push(int dat); int isempty(); int search(int dat); int noofelements(); void Pop(); //CAUTION- will decrease number of terms by 1 each time it runs, and pushing the last element again will be same

More_Inferences_in_C++(1Aug'19-16thOct'19)

Programmer/Tester- Aditya Gupta (aka Techy3.5 :-) I used g++ to compile these on linux 1. Type casting of floating point numeral to integer (either automatic or by type casting)- Conversion of floating point to integer is by taking the GIF (Greatest Integer Funtion) and NOT ROUNDING OFF Greatest Integer Function(Maths,12th) it gives the integer part when the original number is written as integer+fractional part (where fractional part is less than 1 but positive) 2. NEsted MultiLine Comment [actually wont work as expected?!] if you do this in C++.... /*  blah /*blah blah blah*/ blah*/ the last blah will be visible to the compiler!!! (Inference- Multiline-Comment ends whenever */ is encountered, no matter where!!)NEsted MultiLine Comment 3. Size of various types (of C++) on 'Linux' Mint - (and same as in later versions of windows, and most PCs nowadays) char - 1 int - 4  (and: short - 2, unsigned long - 8) long long - 8 float - 4 double - 8 (and: lo

Decimal to Binary (wo Array) - A DIFFERENT APPROACH (the way i do it)

 /* * Title - Decimal to Binary Converter - My Way  *  * Programmer - Aditya Gupta (@Techy15)  *  * */ /*The more general approach is to take remainders after dividing by 2, but this one is by comparison*/ /*Compiled with g++ on Zorin OS (Linux)*/ #include<iostream> using namespace std; long pow(int a, int power){         if(power==0) return 1;         else if(power==1) return a;         else return a*pow(a,power-1);         } int main(){         int dec,bin=0,wtemp1,wtemp2,i=0;         cin>>dec; wtemp1=wtemp2=dec;         while(wtemp1>0){                         while(wtemp1>=pow(2,i)){                                  i++;                         }                 bin+=pow(10,i-1);                 wtemp1-=pow(2,i-1);                 i=0;            }         cout<<bin;         return 0; } ~