Showing posts with label 1st semester. Show all posts
Showing posts with label 1st semester. Show all posts

Thursday, 24 January 2013

Lectures

You can get Lectures of 1dt semester by contact us

Tic Tac

// Program create on visual studio consol application.
// Project: create Tic Tac game.
// university: Govt. College university.
// Department of computer science.
// submitted by: Muhammad Ateek.
// Roll number: 03-bscs-2011
// sysmester:  1st


#include <iostream> // directory for input and output
#include <cstdlib>  // directory to generate random numbers.
#include <time.h>   // directory to generate seconds as a seeds of random number
#include <windows.h> // directory for clr screeen. and sounds.
#include <string>    // directory to get string type names of players.
#include <conio.h>

void computer();
int checkWinner();
void drawBoard();

using namespace std;
int option, test, row, col,turn, with, option2 =0;

string player1,player2;
char board[3][3];




int main()
{
    cout << "         //////////////////////////////" << endl;
    cout <<"         ///     TIC TAC TOE        ///" << endl;
    cout<<"         //////////////////////////////" << endl;

    do
    {
      option2 = 0; //so we can play multiple times

      system("Color 3E"); // colour of. main game
      cout<<"\nEnter a menu option:\n";



      cout<<"1. Play Tic Tac Toe\n"; // first line display
      cout<<"2. Game detail\n";

      cout<<"3. Owner detail\n"; // sencond line display.
      cout << "4. Quit";        // quit game
      cin >> option;  // choice to play game or owner detail or quit.
      PlaySound("Sound Effect - African Drums.WAV", NULL, SND_ASYNC);
      // sound play during game.

      if(option==2)
      {
          system("cls");

          cout << "\n Game detail\n"
                    "* Press corresponding number to any choice\n"
                    "* For example  1: for play game\n"
                    "* when enter to the game the box will be\n"
                    "  display in this from\n"
                    "* frist is euals to 0\n"
                    "* second is equals to 1\n"
                    "* third is equals to 2\n"
                    "* same with coloums\n\n"
                    "----------\n"
                    "|00|01|02|\n"
                    "----------\n"
                    "|10|11|12|\n"
                    "----------\n"
                    "|20|21|22|\n"
                    "----------\n"
                    "\n* you have to enter the correct position\n\n";
                    continue;

      }


      if(option==3)
      {             system("cls");

          cout <<"\n Owner detail\nProgram create on visual studio consol application.\n"
                    "Project: create Tic Tac game.\n"
                    "university: Govt. College university.\n"
                    "Department of computer science.\n"
                    "submitted by: Muhammad Ateek.\n"
                    "Roll number: 03-bscs-2011\n"
                    "sysmester:  1st\n";
                     continue;


      }

     if(option==1) // check option if it is play.
     {
      cout << "1. for player VS player\n2. for player VS computer";

     cin >> with; // choice to play with computer or not.

     cout << "1st player = "; // first player name.
     Beep(1000,600); // Beep on enter name of 1st player.
     cin >> player1; // enter name.

    if(with==1) // check if choice to play with another player.
     {
         cout << "\n2nd player = ";
         Beep(1000,600); // Beep on entery second name.
         cin >> player2; //entery of 2nd player.
     }

     system("Color 5E"); // colour after menu and start game.
     drawBoard(); // draw complete frame.
     }




       for(int i = 0; i < 3; i++)
       {
           for(int j = 0; j < 3; j++)
           {
                   board[i][j] = ' ';
           }
       }
      if(option !=4)
      {
        while(option2 != -1)
        {
            if(turn%2 == 0)//if it's even then it's X's turn
            {
                bool condition = true; // bool to check whether the move of player is correct.
                while(condition == true)
                {
                    cout<<"\n\nEnter a move: ";
                    cout << player1; cout << endl; // display name of player1
                    cout<<"Enter the row you wish to make your move on (0,1,2)\n";
                    cin>>row;
                    cout<<"Enter the column you wish to make your move on (0,1,2)\n";
                    cin>>col; system("cls");
                    if(board[row][col] == ' ')
                    {
                        board[row][col] = 'X';
                        turn++;
                        condition = false;
                    }
                    else
                    {
                       cout<<"Invalid move!\n";
                       Beep(500,600);// Beep on display frame or drawboard
                       drawBoard();
                     }
                }
            }
            else if(with==1) // check whether the game is 2 player or computer player.
            {
                if(turn%2 == 1)//if it's even then it's X's turn
              {
                bool condition = true; // bool to check correct position.
                while(condition == true)
                {
                    cout<<"\n\nEnter a move: ";
                    cout << player2; cout << endl; // display of second name.
                    cout<<"Enter the row you wish to make your move on (0,1,2)\n";
                    cin>>row;
                    cout<<"Enter the column you wish to make your move on (0,1,2)\n";
                    cin>>col; system("cls");
                    if(board[row][col] == ' ') // check if space in enter position.
                    {
                        board[row][col] = 'O';
                        turn++;
                        condition = false;
                    }
                    else
                    {
                        cout<<"Invalid move!\n";
                        drawBoard();
                     }
                }
              }
            }
                else if(with==2)
                {
                computer();
                turn++;

                }





            if (checkWinner() == 1) //X wins
            {
                system("cls");
                system("Color 4D"); PlaySound("Sound Effect - Fan Fair 01.WAV", NULL, SND_ASYNC);
                cout<<"Congratulations! "; cout << player1; cout <<" won!\n\n"; with++;
                option2 = -1;
            }
            else if(checkWinner() == 0) //X wins
            {
                system("cls");
                system("Color 4D"); PlaySound("Sound Effect - Fan Fair 01.WAV", NULL, SND_ASYNC);
                cout<<"Congratulations! ";
                if(with==2)
                {
                    cout <<"computer ";
                }
                else
                cout<<player2;
                cout<< " won!\n\n";
                option2 = -1;
            }



            drawBoard();
        }

      }

    }while(option != 4);
      cout<<"\n\n\n\nEnter anything to quit.";
      cin>>test;

}

//print the board to the screen
void drawBoard()
{
     cout<<"\n";
     cout<<"\n-------------\n";
     for(int i = 0; i < 3; i++)
     {
         for(int j = 0; j < 3; j++)
         {
                 cout<<"|"<<board[i][j]<<"|  ";
         }
         cout<<"\n-------------\n";
     }Beep(1000,600);
}

//this method returns a 0 if there's no winner, 1 if X wins, 2 if O wins, 3 if tie
int checkWinner()
{
//check to see if X won


        if(board[0][0] == 'X' && board[0][1] == 'X' && board[0][2] == 'X')
          return 1;
        if(board[1][0] == 'X' && board[1][1] == 'X' && board[1][2] == 'X')
          return 1;
        if(board[2][0] == 'X' && board[2][1] == 'X' && board[2][2] == 'X')
          return 1;

        if(board[0][0] == 'X' && board[1][0] == 'X' && board[2][0] == 'X')
          return 1;
        if(board[0][1] == 'X' && board[1][1] == 'X' && board[2][1] == 'X')
          return 1;
        if(board[0][2] == 'X' && board[1][2] == 'X' && board[2][2] == 'X')
          return 1;

        if(board[0][0] == 'X' && board[1][1] == 'X' && board[2][2] == 'X')
          return 1;
        if(board[2][0] == 'X' && board[1][1] == 'X' && board[0][2] == 'X')
          return 1;
//check to see if O won
        if(board[0][0] == 'O' && board[0][1] == 'O' && board[0][2] == 'O')
          return 0;
        if(board[1][0] == 'O' && board[1][1] == 'O' && board[1][2] == 'O')
          return 0;
        if(board[2][0] == 'O' && board[2][1] == 'O' && board[2][2] == 'O')
          return 0;

        if(board[0][0] == 'O' && board[1][0] == 'O' && board[2][0] == 'O')
          return 0;
        if(board[0][1] == 'O' && board[1][1] == 'O' && board[2][1] == 'O')
          return 0;
        if(board[0][2] == 'O' && board[1][2] == 'O' && board[2][2] == 'O')
          return 0;

        if(board[0][0] == 'O' && board[1][1] == 'O' && board[2][2] == 'O')
          return 0;
        if(board[2][0] == 'O' && board[1][1] == 'O' && board[0][2] == 'O')
          return 0;


}
//computer. generate a random move and see if it's available. if it is, then make it
//if it isn't then generate another random move
void computer()
{
     col = -1;
     row = -1;
     while(col == -1 || row == -1)
     {

        srand( (unsigned)time(NULL) );
        col = rand()%3;
        row = rand()%3;
        if(board[row][col] != ' ')
        {
            col = -1;
            row = -1;
        }
        board[row][col] = 'O';
     }

}

Searcher

// finder.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;

int counter = 0;
int main()
{
    string names[5]= {"ali", "ateeq" , "shani", "jani", "azeem"};
    string geter;
    string user;
    cout << "enter name" << endl;
    cin >> user;
   
    for(int j=0; j<=4; j++)
    { geter=names[1];
   
        counter = user.length();
    for(int i=0; i<=user.length(); i++)
    {

           

        if(geter[i]==user[i])
        {
             counter--;
       
          if (counter ==0)
          {cout << geter;}
       
        }
           
           
       
       
   
    }
   
   
   
   
}
    system ("pause");
    return 0;
}

TicTac Toe Game

// Program create on visual studio consol application.
// Project: create Tic Tac game.
// university: Govt. College university.
// Department of computer science.
// submitted by: Muhammad Ateek.
// Roll number: 03-bscs-2011
// sysmester:  1st

#include"stdafx.h"
#include <iostream> // directory for input and output
#include <cstdlib>  // directory to generate random numbers.
#include <time.h>   // directory to generate seconds as a seeds of random number
#include <windows.h> // directory for clr screeen. and sounds.
#include <string>    // directory to get string type names of players.
#include <conio.h>

void computer();
int checkWinner();
void drawBoard();

using namespace std;
int option, test, row, col,turn, with, option2 =0;

string player1,player2;
char board[3][3];




int main()
{
    cout << "         //////////////////////////////" << endl;
    cout <<"         ///     TIC TAC TOE        ///" << endl;
    cout<<"         //////////////////////////////" << endl;

    do
    {
      option2 = 0; //so we can play multiple times

      system("Color 3E"); // colour of. main game
      cout<<"\nEnter a menu option:\n";



      cout<<"1. Play Tic Tac Toe\n"; // first line display
      cout<<"2. Game detail\n";

      cout<<"3. Owner detail\n"; // sencond line display.
      cout << "4. Quit";        // quit game
      cin >> option;  // choice to play game or owner detail or quit.
      PlaySound("Sound Effect - African Drums.WAV", NULL, SND_ASYNC);
      // sound play during game.

      if(option==2)
      {
          system("cls");

          cout << "\n Game detail\n"
                    "* Press corresponding number to any choice\n"
                    "* For example  1: for play game\n"
                    "* when enter to the game the box will be\n"
                    "  display in this from\n"
                    "* frist is euals to 0\n"
                    "* second is equals to 1\n"
                    "* third is equals to 2\n"
                    "* same with coloums\n\n"
                    "----------\n"
                    "|00|01|02|\n"
                    "----------\n"
                    "|10|11|12|\n"
                    "----------\n"
                    "|20|21|22|\n"
                    "----------\n"
                    "\n* you have to enter the correct position\n\n";
                    continue;

      }


      if(option==3)
      {             system("cls");

          cout <<"\n Owner detail\nProgram create on visual studio consol application.\n"
                    "Project: create Tic Tac game.\n"
                    "university: Govt. College university.\n"
                    "Department of computer science.\n"
                    "submitted by: Muhammad Ateek.\n"
                    "Roll number: 03-bscs-2011\n"
                    "sysmester:  1st\n";
                     continue;


      }

     if(option==1) // check option if it is play.
     {
      cout << "1. for player VS player\n2. for player VS computer";

     cin >> with; // choice to play with computer or not.

     cout << "1st player = "; // first player name.
     Beep(1000,600); // Beep on enter name of 1st player.
     cin >> player1; // enter name.

    if(with==1) // check if choice to play with another player.
     {
         cout << "\n2nd player = ";
         Beep(1000,600); // Beep on entery second name.
         cin >> player2; //entery of 2nd player.
     }

     system("Color 5E"); // colour after menu and start game.
     drawBoard(); // draw complete frame.
     }




       for(int i = 0; i < 3; i++)
       {
           for(int j = 0; j < 3; j++)
           {
                   board[i][j] = ' ';
           }
       }
      if(option !=4)
      {
        while(option2 != -1)
        {
            if(turn%2 == 0)//if it's even then it's X's turn
            {
                bool condition = true; // bool to check whether the move of player is correct.
                while(condition == true)
                {
                    cout<<"\n\nEnter a move: ";
                    cout << player1; cout << endl; // display name of player1
                    cout<<"Enter the row you wish to make your move on (0,1,2)\n";
                    cin>>row;
                    cout<<"Enter the column you wish to make your move on (0,1,2)\n";
                    cin>>col; system("cls");
                    if(board[row][col] == ' ')
                    {
                        board[row][col] = 'X';
                        turn++;
                        condition = false;
                    }
                    else
                    {
                       cout<<"Invalid move!\n";
                       Beep(500,600);// Beep on display frame or drawboard
                       drawBoard();
                     }
                }
            }
            else if(with==1) // check whether the game is 2 player or computer player.
            {
                if(turn%2 == 1)//if it's even then it's X's turn
              {
                bool condition = true; // bool to check correct position.
                while(condition == true)
                {
                    cout<<"\n\nEnter a move: ";
                    cout << player2; cout << endl; // display of second name.
                    cout<<"Enter the row you wish to make your move on (0,1,2)\n";
                    cin>>row;
                    cout<<"Enter the column you wish to make your move on (0,1,2)\n";
                    cin>>col; system("cls");
                    if(board[row][col] == ' ') // check if space in enter position.
                    {
                        board[row][col] = 'O';
                        turn++;
                        condition = false;
                    }
                    else
                    {
                        cout<<"Invalid move!\n";
                        drawBoard();
                     }
                }
              }
            }
                else if(with==2)
                {
                computer();
                turn++;

                }





            if (checkWinner() == 1) //X wins
            {
                system("cls");
                system("Color 4D"); PlaySound("Sound Effect - Fan Fair 01.WAV", NULL, SND_ASYNC);
                cout<<"Congratulations! "; cout << player1; cout <<" won!\n\n"; with++;
                option2 = -1;
            }
            else if(checkWinner() == 0) //X wins
            {
                system("cls");
                system("Color 4D"); PlaySound("Sound Effect - Fan Fair 01.WAV", NULL, SND_ASYNC);
                cout<<"Congratulations! ";
                if(with==2)
                {
                    cout <<"computer ";
                }
                else
                cout<<player2;
                cout<< " won!\n\n";
                option2 = -1;
            }



            drawBoard();
        }

      }

    }while(option != 4);
      cout<<"\n\n\n\nEnter anything to quit.";
      cin>>test;

}

//print the board to the screen
void drawBoard()
{
     cout<<"\n";
     cout<<"\n-------------\n";
     for(int i = 0; i < 3; i++)
     {
         for(int j = 0; j < 3; j++)
         {
                 cout<<"|"<<board[i][j]<<"|  ";
         }
         cout<<"\n-------------\n";
     }Beep(1000,600);
}

//this method returns a 0 if there's no winner, 1 if X wins, 2 if O wins, 3 if tie
int checkWinner()
{
//check to see if X won


        if(board[0][0] == 'X' && board[0][1] == 'X' && board[0][2] == 'X')
          return 1;
        if(board[1][0] == 'X' && board[1][1] == 'X' && board[1][2] == 'X')
          return 1;
        if(board[2][0] == 'X' && board[2][1] == 'X' && board[2][2] == 'X')
          return 1;

        if(board[0][0] == 'X' && board[1][0] == 'X' && board[2][0] == 'X')
          return 1;
        if(board[0][1] == 'X' && board[1][1] == 'X' && board[2][1] == 'X')
          return 1;
        if(board[0][2] == 'X' && board[1][2] == 'X' && board[2][2] == 'X')
          return 1;

        if(board[0][0] == 'X' && board[1][1] == 'X' && board[2][2] == 'X')
          return 1;
        if(board[2][0] == 'X' && board[1][1] == 'X' && board[0][2] == 'X')
          return 1;
//check to see if O won
        if(board[0][0] == 'O' && board[0][1] == 'O' && board[0][2] == 'O')
          return 0;
        if(board[1][0] == 'O' && board[1][1] == 'O' && board[1][2] == 'O')
          return 0;
        if(board[2][0] == 'O' && board[2][1] == 'O' && board[2][2] == 'O')
          return 0;

        if(board[0][0] == 'O' && board[1][0] == 'O' && board[2][0] == 'O')
          return 0;
        if(board[0][1] == 'O' && board[1][1] == 'O' && board[2][1] == 'O')
          return 0;
        if(board[0][2] == 'O' && board[1][2] == 'O' && board[2][2] == 'O')
          return 0;

        if(board[0][0] == 'O' && board[1][1] == 'O' && board[2][2] == 'O')
          return 0;
        if(board[2][0] == 'O' && board[1][1] == 'O' && board[0][2] == 'O')
          return 0;


}
//computer. generate a random move and see if it's available. if it is, then make it
//if it isn't then generate another random move
void computer()
{
     col = -1;
     row = -1;
     while(col == -1 || row == -1)
     {

        srand( (unsigned)time(NULL) );
        col = rand()%3;
        row = rand()%3;
        if(board[row][col] != ' ')
        {
            col = -1;
            row = -1;
        }
        board[row][col] = 'O';
     }

}

Sorting

#include <iostream>

using namespace std;

int main()
{

    int temp;
    int mango[5];
    for(int k=0; k<5;k++)
    {
    cin >> mango[k];
    }



    for(int j=0;j<5-i;j++)

      {
           if(mango[j]<mango[j+1])
           {
           temp = mango[j];
           mango[j]=mango[j+1];
           mango[j+1]=temp;

           }

     }



    for (int k=0;k<5;k++)
    {

    cout << mango[k] << "  ";
    }

   cin.get();
    return 0;
}

recursive factorial

#include <iostream>

using namespace std;
int factorial(int);
int main()
{
    int number=5;
 int fact;
 fact = factorial(number);
 cout << fact;


    cin.get();
    return 0;
}

int factorial(int number)
{
    if(number<=1)
    {

        return 1;
    }

    else

    return number+factorial(number-1);
}

recursive exponents

#include <iostream>

using namespace std;

int power (int, int);

int main ()

{
    int base, exp, result;

    //obtain integer from user
    cout<<"Enter the base value: ";
    cin >>base;
    cout<<"Enter the exponent value: ";
    cin>>exp;

    result = power(base, exp);

    cout<<"The result is: "<< result << endl;

    return 0;
}


// recursive definition
int power (int base, int exp)
{
    // base case
    if (exp==1)
        return base * 1;

    // recursive step
    else if (exp >-1)
        exp--;

        return base * (power(base,exp));


}

Power

// Find the power of any number

// programmer: M.Ateek
// class:      BSCS
// symester:   1st
// Roll #      03


#include <iostream>
using namespace std;
int main()
{
int number,power,count,i;

cout << "Enter Number: "; cin >> number;
cout << "Enter the power: "; cin >> power;

count = 1;
for (i=1; i <=power; i++)
count = count*number;

cout << count << endl;

cin.get();
return 0;
}

passing array from function as parameter

#include <iostream>

using namespace std;

int modified_array1(int [], int);
int main()
{
    int array1[6];

cout << "enter number to sort out\n";

    for(int i=0; i<6; i++)
    {
        cin >> array1[i];
    }

    modified_array1(array1, 5);

   cout << "Sorted numbers are ";
    for(int j=0; j<5; j++)
    {
        cout << array1[j]<< " ";
    }

cin.get();
return 0;
}



int modified_array1(int array_of_function[], int size)
{

int temp;
   for(int i=0; i<5; i++)
    {
    for(int j=0;j<5-i;j++)

      {
           if(array_of_function[j]<array_of_function[j+1])
           {
           temp = array_of_function[j];
           array_of_function[j] = array_of_function[j+1];
           array_of_function[j+1]=temp;

           }

     }

    }

}


Palindrom

// palidrom.cpp : Defines the entry point for the console application.
//



#include <iostream>
#include <conio.h>
#include <string.h>
using namespace std;
int main()
{

 char strn[80];
int i,j,flag=0,len;
cout<<"Enter the string:";
cin.getline(strn,80);

len=strlen(strn);
cout << endl << len;
for(i=0,j=len-1;i<=(len/2);++i,--j)
{
    cout << i <<"=i" << endl << " " << j << "= j" << endl;

if(strn[i]==strn[j])
flag=1;
else if (strn[i]!=strn[j])
{
    flag=0;
break;
}

}

if(flag)
cout<<"Palindrome";

else cout<<"Not a palindrome";

getch();
}

Menu for add subtract multiplication

#include <iostream>
#include <iomanip>

using namespace std;

int main()

{   int num1,num2;

    char option;


        cout << "enter your 1st number = ";
           cin >> num1;


        cout << "enter your 2nd number = ";
           cin >> num2;

cout << " What you want to do? \n";

cout << "a: ADD \n" << "b: SUB\n" << "c: MUL\n" << "d: DIV\n";
cout << "Type number of any option Example a,b,c,d\n";


cin >> option;


if ( option=='a')
{

    cout << "The addition is = ";
    cout << num1+num2;
}

else if (option == 'b')
{
    cout << "The subtraction is = " << num1-num2;


}

else if (option == 'c')
{
    cout << "The Multiplication is = " << num1*num2;
}


else if(option == 'd')
{
    cout << "The Division is = " << showpoint << num1/num2;
}

 else

{
    cout << "please type valid options\n";
}
cin.get();


   return 0;
}

Grade Programming

//Program:    This program distribute your Grade with respect to marks.
//Programmer: Muhammad Ateek. Roll#03
//Date:       10/29/2011.

#include <iostream>
#include <limits>

using namespace std;

int main()
{
    cout << "Enter your obtained marks \n";

// Declrations
    int marks;
    cin >> marks;
    cout << "your abtained marks are = ";
    cout << marks << endl;

//Statments
    if(marks<40)                           //If statments.
    {
        cout << "Sorry you have been fail";
    }

    else if (marks>=40,marks<=49)
    {
        cout << "you have been passes and your grade is C";

    }

    else if(marks>=50,marks<=59)
    {
        cout << "You have been passed and you grade is B";
    }

    else if(marks>=60,marks<=69)
    {
        cout << "You have been passed and your grade is B+";
    }

    else if(marks>=70,marks<=79)
    {
        cout << "you have been passed and your grade is A";
    }

    else if (marks>=80,marks<=100)
    {
        cout << "you have been passed and your grade is A+";
    }

else
{
    cout <<"ERROR\n";
    cout << "please enter your obtained marks out of 100";
}
    cin.ignore(numeric_limits<streamsize>::max(), '\n');  // program screen stop.
    cin.get();
    return 0;                                             // Ending
}

fibonacci series

#include <iostream>

using namespace std;
int fibonacci(int);
int main()
{

    for(int number=0; number<=10; number++)

    cout << fibonacci(number)<< " ";
    return 0;
}

int fibonacci(int number)
{

    if(number<=1)
    {


       return number;
    }

    else
    return fibonacci(number-1) + fibonacci(number-2);

}

fabonaci series till 10

//fib series till  10.

#include <iostream>

using namespace std;

int main()
{


    int a,b,c;
    a=0;
    b=1;
    int i;

    cout << a<< "\t" << b <<"\t" << a+b<< "\t";

            for(i=1; i<= 10;i++)
    {c=a+b;
        if(c<10)
        {cout << c << "\t";
        }
        a=b;
        b=c;
    }



    cin.get();
    return 0;
}

fib series 1st 10

//fib series till  10.

#include <iostream>

using namespace std;

int main()
{


    int a,b,c;
    a=0;
    b=1;
    int i;

    cout << a<< "\t" << b <<"\t" << a+b<< "\t";

            for(i=1; i<= 7;i++)
    {c=a+b;

        cout << c << "\t";

        a=b;
        b=c;
}



    cin.get();
    return 0;
}

do while calculator manu

#include <iostream>
#include <string>

using namespace std;

int main()
{char opt;
    int num1,num2;


    char option;
    do
    {





        cout << "enter your 1st number = ";
           cin >> num1;


        cout << "enter your 2nd number = ";
           cin >> num2;

cout << " What you want to do? \n";

cout << "a: ADD \n" << "b: SUB\n" << "c: MUL\n" << "d: DIV\n";
cout << "Type number of any option Example a,b,c,d\n";


cin >> option;


if ( option=='a')
{

    cout << "The addition is = ";
    cout << num1+num2;
}

else if (option == 'b')
{
    cout << "The subtraction is = " << num1-num2;


}

else if (option == 'c')
{
    cout << "The Multiplication is = " << num1*num2;
}


else if(option == 'd')
{
    cout << "The Division is = " << showpoint << num1/num2;
}

 else

{
    cout << "please type valid options\n";

}
cout << "\nif you want continou press 'Y' or 'N' for no ";
cin >> opt;
    }




    while(opt=='y'|| opt == 'Y');


    cin.get();


   return 0;

}

Directory


#include "stdafx.h"
#include <iostream>
#include <windows.h>
#include<string>


COORD coord={0,0}; // function to set the cursor point
         void gotoxy(int x,int y)
       {
             coord.X=x;
             coord.Y=y;
             SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),coord);
       }


using namespace std;



int main()
{  int check=0;
    int x=0;
    int y=0;
    string enter;
    string dir[6][5]={{"Country","Capital","Religion","Language","Land Area"},
                      {"pakistan","islamabad","islam","urdu","709,696 km"},
                        {"indea","newDelhi","hindu","hindi","3,287,590 sq km"},
                        {"afghanistan","kabul","islam","pashti","647,500 sq km"},
                        {"china","beijing","daoist","chinese","9,596,960 sq km"},
                        {"america","washington","protestant","english","9,631,420 sq km"}};
cout << "Type anyone thing to get information regarding any country\nNAME, Capital, Religion, language or country area\n";
cin >> enter;

for(int i=1; i<6; i++)
for(int j=0; j<5; j++)
{
  if(dir[i][j]==enter)
  { check=1;
      for(int i=0; i<5;i++)
        {

gotoxy(x,4);
                cout << dir[0][i]; if(x>0){gotoxy(x-5,4);cout <<"|";}
x=x+15;

                if(i==4)
                {
                    cout << endl;
                }

       }

    for(int k=0; k<5; k++)
    {

gotoxy(y,6);
        cout << dir[i][k] ; if(y>0){gotoxy(y-5,6);cout <<"|" << endl;}
        y=y+15;


   }

   }
}

if(check==0)
{cout << "Your search by keywords " <<enter << "is not registered.\nNOTE: All spells should be correct and in small Letters";
}




     cin.get();
     system("pause");

    return 0;
}

diamond

#include <iostream>
#include <iomanip>

using namespace std;

int main()
{
int n = 7;
int m = 1;
int x = 6;


for (int i = 0; i < 3; i++)
{

    cout << setw(x);
  x--;


    for (int j = 0; j < m; j++)

     cout << "*";
        cout << endl;

        m=m+2;
        }



        for (int i = 0; i < 4; i++)
{

    cout << setw(x);
  x++;


    for (int j = 0; j < n; j++)

     cout << "*";
        cout << endl;

        n=n-2;
        }


cin.get();
return 0;
}

check of prime

#include <iostream>

using namespace std;

int main()
{
    int num;
    bool prime;
    cin >> num;

    for (int i=2;i <=num-1;i++)
    {
      num%i;
      if(num%i==0)
      {
          cout << "not prime";

      break;
      }
      else if(num%i==1)
      {
          cout << "prime";
          break;
      }




     }








cin.get();
    return 0;
}

celcius function

#include <iostream>
using namespace std;
int main()

{
    cout << "C to F\n";
    for (int celcius=0; celcius<=100; celcius++)
    {
        cout << celcius << "=  "<<  (celcius * 1.8) + 32 << endl;
    }

    char option;
    float degrees;

    cout << "Press 1 or 2 to convert From :" << endl;

    cout << "[1] Celsius to Fahrenheit" << endl;

    cout << "[2] Fahrenheit to Celsius" << endl;



    cin >> option;



    if (option == '1')

    {

        cout << "Please enter the number of Celsius Degrees:" << endl;

        cin >> degrees;

        float fahren = (degrees * 1.8) + 32;

        cout << degrees << " degrees Celsius is " << fahren << " degrees Fahrenheit" << endl;

    }

    else

    {

        cout << "Fahrenheit to Celsius" << endl;

        cin >> degrees;

        float celsius = (degrees - 32) / 1.8;

        cout << degrees << "degrees Fahrenheit is " << celsius << "degrees Celsius" << endl;

    }



    return 1;

}

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Enterprise Project Management