Tuesday, 27 November 2012

Write a program that will calculate the sum of expension of cosx in Maclaurin Series.


// 1 - x^2/2! + x^4/4! - x^6/6! + - - - - - - - - - - upto so on


#include <iostream>
#include <math.h>  // for power fucntion
using namespace std;
int main()
{
double x_value,fact=1.0,term,sum=0,max_power;
int sign=1;
cout << "Welcome to The WORLD OF C++ PROGRAMING"<<endl;
cout << endl;
cout << "This Program will generate the Maclauren Series of cos(x)."<<endl;
cout << endl;
cout << "Which is cos(x)= 1 - x^2/2! + x^4/4! - x^6/6! +  - - - - - - - "<<endl;
cout << endl;
cout << "Enter the Value or X: ";
cin >> x_value;
cout << "Enter Maximum Power of series: ";
cin >> max_power;
for (int i=0;i<=max_power;i=i+2)
{
fact=1;
for(int j=1;j<=i;j=j+1)
{
fact=fact*j;
}
term=pow(x_value,i)/fact;  // usage of power fucntion
sum=sum+(term*sign);
sign*=-1;
}
cout << "Sum is of Series is: " << sum <<endl;
return 0;
}


Write a program that will calculate the sum of expension of sinx in Maclaurin Series.


// x - x^3/3! + x^5/5! - x^7/7! + - - - - - - - - - - upto so on

#include <math.h> // to perform power fucntion.....
#include <iostream>
using namespace std;
int main()
{
double x_value,fact=1.0,term,sum=0,max_power;
int sign=1;
cout << "Welcome to The WORLD OF C++ PROGRAMING"<<endl;
cout << endl;
cout << "This Program will generate the Maclauren Series of sin(x)."<<endl;
cout << endl;
cout << "Which is sin(x)= x - x^3/3! + x^5/5! - x^7/7! +  - - - - - - - "<<endl;
cout << endl;
cout << "Enter the Value or X: ";
cin >> x_value;
cout << "Enter Maximum Power of series: ";
cin >> max_power;
for (int i=1;i<=max_power;i=i+2)
{
fact=1;
for(int j=1;j<=i;j=j+1)
{
fact=fact*j;
}
term=pow(x_value,i)/fact; // power fucntion
sum=sum+(term*sign);
sign*=-1;
}
cout << "Sum is: " << sum <<endl;
return 0;
}

Keyboard shortcuts for Microsoft Word 2007

Ctrl + A ==> To selects all documents in current file/folder, or select all text in current document

Ctrl + B ==> To make the font Bold

Ctrl + C ==> To Copy text or item to clipboard

Ctrl + D ==> To display Font dialogue box

Ctrl + E ==> To perform Centre Alignment for selected text

Ctrl + F ==> To perform Find & Replace action on text within document

Ctrl + G ==> To display Go To dialogue box to go to a specific location in document

Ctrl + H ==> To display the Find & Replace dialogue box

Ctrl + I ==> to make the selected text Italic

Ctrl + J ==> To make the selected text/document in full Justification

Ctrl + K ==> To create Hyperlink in the document

Ctrl + L ==> To apply Left Alignment on selected text/document

Ctrl + M ==> To perform the Tab action

Ctrl + N ==> To create a New document

Ctrl + O ==> To Open the existing file from local drives

Ctrl + P ==> To display the Print dialogue box

Ctrl + R ==> To apply Right Alignment on selected text/document

Ctrl + S ==> To Save/Save As current file/document

Ctrl + U ==> To Underline the selected text

Ctrl + V ==> To Paste the text/item that was Cut/Copied before

Ctrl + X ==> To Cut the selected text/item

Ctrl + Y ==> To Redo last performed action

Ctrl + Z ==> To Undo last performed action

Ctrl + Enter ==> To insert a Page Break

Ctrl + F1 ==> To quickly hide the toolbar and ribbon bar of current document

Ctrl + F2 ==> To display the Print Preview

Ctrl + F4 ==> To close the active document window only

Ctrl + F6 ==> To make the next document window active

F1 ==> To get Word Help

F2 ==> To move selected text/item to new location

F3 ==> To insert Auto Text entry

F4 ==> To repeat the last action

F5 ==> Another shortcut to Find & Replace dialogue box

F6 ==> To go to next frame or pane quickly

F7 ==> To launch and apply the Spelling & Grammar check

F8 ==> To extend the current selection in both sides

F9 ==> To update the selected fields

F10 ==> To activate menu bar

F11 ==> To go to the next field

F12 ==> another shortcut to Save As a file/document

Shift + F1 ==> To open context sensitive help

Shift + F2 ==> To copy text/item to the new location quickly

Shift + F3 ==> To change the case of selected text

Shift + F4 ==> Another shortcut to perform Find and Go To action

Shift + F5 ==> To move to previous revision

Shift + F6 ==> To go to previous frame or pane

Shift + F7 ==> To launch Thesaurus

Shift + F8 ==> To shrink the current selection of text

Shift + F9 ==> To switch between a field code and its result

Shift + F10 ==> To display shortcut menu (similar to right-click)

Shift + F11 ==> To go to previous field

Shift + F12 ==> To Save document

Friday, 23 November 2012

Code to calculate the sum of series 1/2!+2/3!+3/4!+4/5!+5/6!+ - - - - - -



#include <iostream>
using namespace std;
int main()
{
double fact,term,sum=0;
int length;
cout << "This program will disply the sum of following series... \n"<<endl;
cout << "1/2!+2/3!+3/4!+4/5!+5/6!+ - - - - - - \n"<<endl;
cout << "Enter Length of the series: ";
cin >> length;
for (int i=1;i<=length;i++)
{
fact=1;
for (int j=1;j<=i+1;j++)
{
fact=fact*j;
}
term=i/fact;
sum=sum+term;
}
cout << "Sum is: "<< sum << endl;
cout <<endl;

return 0;
}

Sum of series 1/1!+2/2!+3/3!+4/4!+5/5! + - - - - - - -


Write a program to calculate the sum of the following series:
1/1!+2/2!+3/3!+4/4!+5/5!+6/6!+ - - - - - - -




#include <iostream>
using namespace std;
int main()
{
 double fact,term,sum=0;
 int length;
 cout << "This program will disply the sum of following series... \n"<<endl;
 cout << "1/1!+2/2!+3/3!+4/4!+5/5!+ - - - - - - \n"<<endl;
 cout << "Enter Length of the series: ";
 cin >> length;
 for (int i=1;i<=length;i++)
 {
  fact=1;
  for (int j=1;j<=i;j++)
  {
   fact=fact*j;
  }
  term=i/fact;
  sum=sum+term;
 }
  cout << "Sum is: "<< sum << endl;
  cout <<endl;

 return 0;
}

}



Pattern print With Nested for loop


Write a program that will display the following pattern using nested for loop
1
12
123
1234
12345

#include <iostream>
using namespace std;
int main()
{
for (int i=1;i<=5;i++)
{
     for (int j=1;j<=i;j++)
     cout << j;
cout <<endl;
}
return 0;
}

Pattern with Nested For Loop


Write a program that will display the following patter using nested for loop....
1
22
333
4444
55555
  
#include <iostream>
using namespace std;
int main()
{
for (int i=1;i<=5;i++)
{ for (int j=1;j<=i;j++)
cout << i;
cout <<endl;
}
return 0;
}

Tuesday, 20 November 2012

How to Generate a Fibonacci series in C++ Programming?


#include <iostream>
using namespace std;
int main()
{
int i, a=0,b=1,c, num;
cout << "Enter Number for how many times generate Series: ";
cin >>num;
cout << "Fibonaci Series is: \n";
for(i=0;i<num;i++)
{
c=a+b;
a=b;
   b=c;
cout << "\t" <<c<<endl;
}
return 0;
}

Square root upto given Number.


#include <iostream>
//#include <math.h>
using namespace std;
int main()
{
int num;
cout << "Enter Number upto which u want to take square: ";
cin >> num;
for (int q=1;q<=num;q++)

cout << "Square of " << q << " is " << q*q <<endl;

return 0;
}

Saturday, 17 November 2012

Pattern Print Code with Nested For Loop

        *
      **
    ***
  ****
*****



#include <iostream>
#include <math.h>
using namespace std;
int main()
{
for (int i=1;i<=5;i++)
{
for(int j=1;j<=5-i;j++)
cout <<" ";
for (int k=1;k<=i;k++)
cout <<"*";
cout<<endl;
}
return 0;
}

Pattern Print Code


*****
****
***
**
*

#include <iostream>
#include <math.h>
using namespace std;
int main()
{
for (int i=5;i>=1;i--)
{
for(int j=1;j<=5-i;j++)
cout <<" ";
for (int k=1;k<=i;k++)
cout <<"*";
cout<<endl;
}
return 0;
}

Pattern Print code


*******
******
*****
****
***
**
*


#include <iostream>
#include <math.h>
using namespace std;
int main()
{
for (int i=7;i>=1;i--)
{
for(int j=1;j<=i;j++)
cout <<"*";
cout<<endl;
}
return 0;
}

Pattern Print Code with Nested For loop


Write a program that will print the following code,
*
**
***
****
*****


#include <iostream>
#include <math.h>
using namespace std;
int main()
{
for (int i=1;i<=5;i++)
{
for(int j=1;j<=i;j++)
cout <<"*";
cout<<endl;
}
return 0;
}

Pattern Print Code with Nested For Loop


Write a program that will print the following pattern.
* * * * *
* * * * *

* * * * *
* * * * *

* * * * *



#include <iostream>
#include <math.h>
using namespace std;
int main()
{
for (int i=1;i<=5;i++)
{
for(int j=1;j<=5;j++)
cout <<" * ";
cout<<endl;
}
return 0;
}

What is Nested For Loop? Describe Flow Diagram and give an example?

Nested Loop:

           The loop within a loop is called Nested loop. In nested loops the inner loop is executed completely with each change in the value of counter variable of outer loop. The nesting can be done upto any level. The increase in level of nesting increases the complexity of nested loop.

Flow Diagram:


Example:

#include <iostream>
#include <math.h>
using namespace std;
int main()
{
for (int i=1;i<=3;i++)
{
for(int j=1;j<=3;j++)
cout << i <<"\t"<<j<<endl;
}
        return 0;
}

Reverse the value of Entered Number


write a program that reverse the value of given number like 12345 and program should output 54321
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
int num,rev=0;
cout << "Enter an Integer: ";
cin >>num;
/*cout << "Enter The value of N: ";
cin >>n_value;*/
for (int i=num;i!=0;i=i/10)
{
rev=10*rev+i%10;
}
cout << "Entered Number is : " << num <<endl;
cout << "Reverse is: " << rev <<endl;
return 0;
}

Sum of Series

write a program that will calculate the sum of series:   x+x2+x3+...............+xn
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
int n_value,x_value,sum=0;
cout << "Enter The value of X: ";
cin >>x_value;
cout << "Enter The value of N: ";
cin >>n_value;
for (int i=1;i<=n_value;i++)
{
sum=sum + pow(x_value,i);
}
cout << "Sum is: " << sum <<endl;
return 0;
}

Sum of Squares of Integers

//Write a program to calculate the sum of squares of integers 1 to n. where n is the value entered by user. i.e(sum=12+22+32+42+52................n2).

#include <iostream>
using namespace std;
int main()
{
int num,sum=0;
cout << "Enter The value of n: ";
cin >>num;
for (int i=1;i<=num;i++)
{
sum=sum+(i*i);
}
cout << "Sum is: " << sum <<endl;
return 0;
}

Friday, 16 November 2012

Prime or Composite With "bool" data type using NOT operator.


//3rd logic with NOT Logical Operator and bool Data Type.
#include <iostream>
#include <process.h>
using namespace std;
int main()
{
int n;
bool check=false;
cout << "Enter Any +ve Integer: ";
cin >> n;
if (n < 0)
{
cout << "STOP !!!! Plz Enter Correct Number Value."<<endl;
exit(1);
}
for (int j=2;j<=n/2;j++)
{
if (n%j==0)
{
check=true;
break;
}
}
if (check!=true)
cout << n << " is a Prime Number.\n";
else
cout << n << " is a Composite Number.\n";
return 0;
}

Prime or Composite........


// 2nd Logic To check prime or composite
#include <iostream>
#include <process.h>
using namespace std;
int main()
{
int n,counter=0;
cout << "Enter Any +ve Integer: ";
cin >> n;
if (n < 0)
{
cout << "STOP !!!! Plz Enter Correct Number Value."<<endl;
exit(1);
}
for (int j=2;j<=n/2;j++)
{
if (n%j==0)
{
counter++;
break;
}
}
if (counter==0 && n!=0)
cout << n << " is a Prime Number.\n";
else
cout << n << " is a Composite Number.\n";
return 0;
}