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

Using 'ls' command as a replacement of 'find'

Advantage over find - Actually not probably in terms of speed, but... only point of this is that it's an observation, but... you can do like 'search only in' */*/*Programs* , /*/*Programs*/* , this may compensate the extra time took by using two commands 1. To search in current folder only (1 level... only this folder, no subfolder)     Type... ls | grep Search_Term 2. To search in current folder only (till level 2... this folder + subfolder)     Type... ls * | grep Search_Term #ls and ls * are NOT same! 3. To search in current folder only (till level 3... this folder + subfolder + subfolder)     Type... ls */* | grep Search_Term 4. To search in current folder only (till level 4... this folder + subfolder + subfolder + subfolder)     Type... ls */*/* | grep Search_Term ... and so on... FORMULA - To search till 'n' level (considering current folder as 1)... go till (n-1) stars If wanting to search whole disk... better type star...

LudO - The Game

/* Programmer - Aditya Gupta (Techy15) Language - C++ Program - LudO - The Game */ /* PLANS- Add functionality for name of player */ //IMP NOTE - See all notes, written in this form "//NOTE..." //NOTE- Mark 'R','G','B','Y' for gotis, ignore doubling for now //NOTE- Settings will have options: change default game play order(ie RBYG), change/give names to each colour //NOTE- Add code in case of attacks //NOTE- Add stops, and ways to show them distinct from others {may require graphics.h} #include<iostream> /* #include<fstream>    To be used in case save & resume to be used*/ #include<cstdio> #include<cstdlib> using namespace std; //Changes on 16th Oct //Show gotis as R1, R2... and ask user to enter string R1 or whatever // // Place within appropriate block ...     short diethrow(){     int fl=1; //holds 0 if decnum is 0     while(fl==0) { char *temp;     ...

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: l...