project oops..final

Upload: arpit-gupta

Post on 05-Apr-2018

218 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/2/2019 Project Oops..Final

    1/35

    Wap to find the sum of two numbers using function.

    #include

    #include

    #include

    #include

    int sum(int x,int y)

    {int s;

    s=x+y;

    return s;

    }

    void main()

    {

    clrscr();

    int a,b,k;

    couta>>b;

    k=sum(a,b);

    cout

  • 8/2/2019 Project Oops..Final

    2/35

    Wap to find simple interest and compound interest.

    #include

    #include

    #include

    #include

    void main()

    {

    clrscr();

    float p,r,t,ci,si,i;

    int a;

    coutp;

    coutr;

    coutt;

    cout

  • 8/2/2019 Project Oops..Final

    3/35

    Wap to demonstrate the working of following loop : While, Do While, For, If-

    Else, Switch.

    #include

    #include

    #include

    void main()

    {

    clrscr();

    int f=1,s=0,a,x,i=1;

    char ch;

    do

    {

    coutx;

    cout

  • 8/2/2019 Project Oops..Final

    4/35

    switch(a)

    {

    case 1:while(i

  • 8/2/2019 Project Oops..Final

    5/35

    }

    while(ch=='y' || ch=='n');

    getch();

    }

  • 8/2/2019 Project Oops..Final

    6/35

    WAP to find greatest of three numbers.

    #include

    #include

    #include

    void main()

    {

    clrscr();

    int a,b,c,s;

    couta>>b>>c;

    if(a>b)

    {

    if(a>c)

    s=a;

    else

    s=c;

    }

    else

    s=b;

    cout

  • 8/2/2019 Project Oops..Final

    7/35

    getch();

    }

  • 8/2/2019 Project Oops..Final

    8/35

    WAP to check whether a number is even or odd.

    #include

    #include

    #include

    void main()

    {

    clrscr();

    int x;

    coutx;

    if(x%2==0)

    cout

  • 8/2/2019 Project Oops..Final

    9/35

  • 8/2/2019 Project Oops..Final

    10/35

    WAP to check whether a year is leap year or not.

    #include

    #include

    #include

    void main()

    {

    clrscr();

    int x;

    coutx;

    if(x%4==0)

    cout

  • 8/2/2019 Project Oops..Final

    11/35

  • 8/2/2019 Project Oops..Final

    12/35

    WAP to add and subtract two matrices.

    #include

    #include

    #include

    void main()

    {

    clrscr();

    int a[10][10],b[10][10],c[10][10],m,n,i,j;

    coutm>>n;

    cout

  • 8/2/2019 Project Oops..Final

    13/35

    cin>>b[i][j];

    cout

  • 8/2/2019 Project Oops..Final

    14/35

    for(i=0;i

  • 8/2/2019 Project Oops..Final

    15/35

  • 8/2/2019 Project Oops..Final

    16/35

    WAP to display elements of an array.

    #include

    #include

    #include

    void main()

    {

    clrscr();

    int a[10][10],m,n,i,j;

    coutm>>n;

    cout

  • 8/2/2019 Project Oops..Final

    17/35

    cout

  • 8/2/2019 Project Oops..Final

    18/35

    WAP to calculate Sum and Average of an array.

    #include

    #include

    #include

    void main()

    {

    clrscr();

    int a[10][10],m,n,i,j,s=0,k=0;

    float l;

    coutm>>n;

    cout

  • 8/2/2019 Project Oops..Final

    19/35

    for(j=0;j

  • 8/2/2019 Project Oops..Final

    20/35

  • 8/2/2019 Project Oops..Final

    21/35

    WAP to sort elements of an array using Bubble sort.

    #include

    #include

    #include

    #include

    void main()

    {

    clrscr();

    int a[100],i,j,k,m;

    coutm;

    cout

  • 8/2/2019 Project Oops..Final

    22/35

    a[i]=a[j];

    a[j]=k;

    }

    }

    }

    for(i=0;i

  • 8/2/2019 Project Oops..Final

    23/35

    WAP to calculate Factorial of a number.

    #include

    #include

    #include

    void main()

    {

    clrscr();

    int i,x,f=1;

    coutx;

    for(i=1;i

  • 8/2/2019 Project Oops..Final

    24/35

  • 8/2/2019 Project Oops..Final

    25/35

    WAP to check whether a given number is Prime or not.

    #include

    #include

    #include

    void main()

    {

    clrscr();

    int i,x,k=0;

    coutx;

    for(i=2;i

  • 8/2/2019 Project Oops..Final

    26/35

  • 8/2/2019 Project Oops..Final

    27/35

    WAP to generate Fibonacci series.

    #include

    #include

    #include

    void main()

    {

    clrscr();

    int i,x,a[100];

    coutx;

    a[0]=0;

    a[1]=1;

    for(i=2;i

  • 8/2/2019 Project Oops..Final

    28/35

  • 8/2/2019 Project Oops..Final

    29/35

    WAP to show function Overloading.

    #include

    #include

    #include

    #include

    void sum(int,int);

    void sum(double,double);

    void sum(char,char);

    main()

    {

    clrscr();

    int a,b;

    double c,d;

    char e,f;

    couta>>b;

    coutc>>d;

    coute>>f;

    sum(a,b);

    sum(c,d);

    sum(e,f);

    getch();

  • 8/2/2019 Project Oops..Final

    30/35

    return 0;

    }

    void sum(int x,int y)

    {

    cout

  • 8/2/2019 Project Oops..Final

    31/35

    WAP to create a class and access member function of a class.

    #include

    #include

    #include

    #include

    class emp

    {

    int eno;

    char name[20],desg[20];

    public: void input();

    void output();

    };

    void main()

    {

    clrscr();

    emp e;

    e.input();

    cout

  • 8/2/2019 Project Oops..Final

    32/35

    cin>>eno;

    cout

  • 8/2/2019 Project Oops..Final

    33/35

    Write a program to convert the temperature in Fahrenheit to Celsius and

    vice-a-verse.

    #include

    #include

    #include

    void main()

    {

    clrscr();

    int f,c,a;

    cout

  • 8/2/2019 Project Oops..Final

    34/35

    cout

  • 8/2/2019 Project Oops..Final

    35/35

    V