Wednesday, February 18, 2015

PROGRAMS

PROGRAM 1. : PRINTING A STRING

#include<iostream>        //include header file

using namespace std;
int main()
{
    cout << "Hi friends, what's up? \n";        //comment
   
    return 0;
}                            //end of example
    

---------------------------------------------------------------
OUTPUT:

Hi friends,what's up?HitLeap - #
---------------------------------------------------------------

 

PROGRAM 2. : AVERAGE OF  TWO  NUMBERS

#include<iostream>

using namespace std; 

int main()

{

    float number1, number2, sum, average;

    cout << "Enter two numbers: ";        //prompt

    cin >> number1;                //read numbers

    cin >> number2;                //from keyboard

    sum = number1 + number2;

    average =  sum/2;

   

    cout << "Sum = " << sum << "\n";

    cout << "Average = " << average << "\n";

    return 0;

}

---------------------------------------------------------------

OUTPUT:

Enter two numbers: 1.2 2.4

sum = 3.6

average = 1.8

---------------------------------------------------------------

 

 

PROGRAM 3. : USE OF CLASS

 

#include<iostream>
using namespace std;
class batsman
{
    char name[40];
    int age;

    public:
        void getdata(void);
        void display(void);
};

void batsman :: getdata(void)
{
    cout << "Enter name: ";
    cin >> name;
    cout << "Enter age";
    cin >> age;
}

void batsman :: display(void)
{
    cout << "\nName: " << name;
    cout << "\nAge: " << age;
}

int main()
{
    batsman  b;
    b.getdata();
    b.display();
   
    return 0;
}

----------------------------------------------------------
OUTPUT:
Enter name: Dhoni
Enter age: 31

Name: Dhoni
Age: 31
----------------------------------------------------------

  

 

 

PROGRAM 4. : SCOPE RESOLUTION OPERATOR

 #include<iostream>
using namespace std;

int m = 30;        //global m

int main()
{
    int m = 40;        //m redeclared,  local to main

    {
        int k = m;
        int m = 50;    //m declared again
                //local to inner block
        cout << "we are in inner block \n";
        cout << "k = " << k << "\n";
        cout << "m = " << m << "\n";
        cout << "::m = " << ::m << "\n";
      }

    cout << "\nWe are in outer block \n";
    cout << "m = " << m << "\n";
    cout << "::m = " << ::m << "\n";

    return 0;
}

-----------------------------------------------------------------
OUTPUT:
We are in inner block
k = 40
m = 50
::m = 30

We are in outer in block
m = 40
::m = 30
----------------------------------------------------------------
 

 

 

 PROGRAM 4. : USE OF NEW  AND DELETE OPERATORS

 

 

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

using namespace std;

void main()
{
    int *arr;
    int size;
  
    cout<<"Enter the size of integer array: ";
    cin>>size;

    cout<<"Creating an array of size "<<size<<"....";
    arr = new int[size];

    cout<<"\nDynamic allocation of memory for array arr is successful. ";
  
    delete arr;
    getch();

}

-----------------------------------------------------------------------------
OUTPUT:
Enter the size of the integer array: 10
Creating an array of size 10....
Dynamic allocation of memeory for array arr is successful
-----------------------------------------------------------------------------

 

 

 

 

Monday, December 22, 2014

MATHS FORMULAE

MATHEMATICAL FORMULAE
CALCULUS
DIFFERENTIAL INTEGRAL
[A]
1. d/dx(c)=0,c=constant  
2. d/dx(x^n+1/n+1)=x^n  
3. d/dx(x)=1
4. d/dx(sqrt(x))=1/(2*sqrt(x))
5. d/dx(1/x)= -1/x^2 


1. int{(0)dx}=c
2. int {(x^n)dx}= x^n+1/n+1 + c (n != -1)
3. int{(1)dx}=x+c
4. int{(1/(2*sqrt(x))dx}=sqrt(x)+c
5. int{(1/x^2)dx}= -1/x +c


[B]
1. d/dx(sinx) = cosx
2. d/dx(cosx) = -sinx
3. d/dx(tanx) = secx^2
4. d/dx(cotx) = -cosecx^2
5. d/dx(secx) = secx*tanx
6. d/dx(cosecx) = -cosecx*cotx


1. int{(cosx)dx} = sinx + c
2. int{(sinx)dx} = -cosx + c
3. int{(secx^2)dx} = tanx + c
4. int{(cosecx^2)dx} = -cotx + c
5. int{(secx*tanx)dx} = secx + c
6. int{(cosecx*cotx)dx} = -cosecx + c


[c]
1. d/dx(sinx^-1)= 1/(sqrt(1-(x^2)))
2. d/dx(cosx^-1)= -1/(sqrt(1-(x^2)))
3. d/dx(tanx^-1)= 1/(1+(x^2))
4. d/dx(cotx^-1)= -1/(1+(x^2))
5. d/dx(secx^-1)= 1/(x(sqrt((x^2)-1)))
6. d/dx(cosecx^-1)= -1/(x(sqrt((x^2)-1)))


1. int{(1/(sqrt(1-(x^2))))dx}= sinx^-1 + c
2. int{(1/(sqrt(1-(x^2))))dx}= -cosx^-1 + c
3. int{(1/(1+(x^2)))dx}= tanx^-1 + c
4. int{(1/(1+(x^2)))dx}= -cotx^-1 + c
5. int{(1/(x(sqrt((x^2)-1))))dx}= secx^-1 + c
6. int{(1/(x(sqrt((x^2)-1))))dx}= -cosecx^-1 + c
[D]
1. d/dx(e^x)= e^x
2. d/dx(a^x)= a^x*loga
3. d/dx(logx)= 1/x
4. d/dx(a^kx)= a^kx*k*loga
5. d/dx(e^(ax+b))= a*e^(ax+b)
6. d/dx(log(ax+b))= a/(ax+b)
7. d/dx((ax+b)^n+1)= a*(n+1)*(ax+b)^n


1. int{(e^x)dx}= e^x + c
2. int{(a^x)dx}= a^x/loga + c
3. int{(1/x)dx}= logx + c
4. int{(a^kx)dx}= a^kx/(k*loga) + c
5. int{(e^(ax+b))dx}= e^(ax+b)/a + c
6. int{(1/(ax+b))dx}= log(ax+b)/a + c
7. int{(ax+b)^n}= (ax+b)^n+1/(a*(n+1)) + c
[E]
1. d/dx(sin(ax+b))= a*cos(ax+b)
2. d/dx(sin(ax-b))= a*cos(ax-b)
3. d/dx(cos(ax+b))= -a*sin(ax+b)
4. d/dx(cos(ax-b))= -a*sin(ax-b)
5. d/dx(tan(ax+b))= a*sec(ax+b)^2
6. d/dx(tan(ax-b))= a*sec(ax-b)^2
7. d/dx(cot(ax+b))= -a*cosec(ax+b)^2
8. d/dx(cot(ax-b))= -a*cosec(ax+b)^2


1. int{(cos(ax+b))dx}= sin(ax+b)/a + c
2. int{(cos(ax-b))dx}= sin(ax-b)/a + c
3. int{(sin(ax+b))dx}= -cos(ax+b)/a + c
4. int{(sin(ax-b))dx}= -cos(ax-b)/a + c
5. int{(sec(ax+b)^2)dx}= tan(ax+b)/a + c
6. int{(sec(ax-b)^2)dx}= tan(ax-b)/a + c
7. int{(cosec(ax+b)^2)dx}= -cot(ax+b)/a + c
8. int{(cosec(ax-b)^2)dx}= -cot(ax-b)/a + c


[F]
1. d/dx[(1/a)*tan(x/a)^-1]= 1/(x^2 + a^2)
2. d/dx[(sin(x/a)^-1)]= 1/(sqrt(a^2 - x^2))
3. d/dx[log(x+(sqrt(x^2 + a^2)))]= 1/(sqrt(x^2 + a^2))
4. d/dx[log(x*sqrt(x^2 - a^2))]= 1/(sqrt(x^2 - a^2))
5. d/dx[(1/2a)*(log(x-a/x+a)]= 1/(x^2 - a^2)
6. d/dx[(1/2a)*(log(a+x/a-x)]= 1/(a^2 - x^2)
7. d/dx[(1/a)*sec(x/a)^-1]= 1/(x*sqrt(x^2 - a^2))


1. int{(1/(x^2 + a^2))dx}= (1/a)*tan(x/a)^-1 + c
2. int{(1/(sqrt (a^2 - x^2)))dx}= sin(x/a)^-1 + c
3. int{(1/(sqrt(x^2 + a^2)))dx}= log(x+sqrt(x^2 + a^2)) + c
4. int{(1/(sqrt(x^2 - a^2)))dx}= log(x+sqrt(x^2 - a^2)) + c
5. int{(1/(x^2 - a^2))dx}= (1/2a)*log(x-a/x+a) + c
6. int{(1/(a^2 - x^2))dx}= (1/2a)*log(a+x/a-x) + c
7. int{(1/(x*sqrt(x^2 - a^2)))dx}= (1/a)*sec(x/a)^-1
[G]
1. int{(secx)dx}= log(secx + tanx) + c
2. int{(cotx)dx}= log(sinx) +c
3. int{(cosecx)dx}= log(cosecx - cotx) + c
4. int{(tanx)dx}= log(secx) + c
[H]
1. d/dx(u.v)= u*(dv/dx) + v*(du/dx)
2. d/dx(u/v) = (v*(du/dx) - u*(dv/dx))/v^2
3. Integration by part:
int{(u*v)dx}= u(int{(v)dx} - int[du/dx(int{(v)dx})]dx
NOTE: To solve integration by part remember the word "LIATE" processing from L to E gradually.
where L = for Logarithmoc function; I = for Inverse trignometric function;
A = for Algebraic function; T = for Trignometric function;
E = for exponential function
SPECIAL DERIVATIVES
CHAIN RULE: If 'f' is function of 'u' and 'u' is function of 'x' then
dy/dx = (dy/du)*(du/dx) or dy/dx = (dy/du)/(dx/du)
NOTE: (i) Differential co-efficent of those trignometrical ratios which begin with 'Co' are negative
(ii) Never forget to multiply by differential co-efficient of 'u'.