1jjjkk

Embed Size (px)

Citation preview

  • 8/13/2019 1jjjkk

    1/16

    1.Banking Program

    #include

    #include

    using namespace std;

    class bankaccount {

    public: char name[20];

    long accno;

    int acctype;

    double balance;

    int assign();

    int deposit();

    int withdraw();

    int display();

    };

    int main() {

    bankaccount obj;

    int bankaccount::assign() {

    cout

  • 8/13/2019 1jjjkk

    2/16

    cin>>obj.accno>>obj.acctype;

    balance=0.0;

    }

    int bankaccount::deposit() {

    coutobj.balance;

    }

    int bankaccount::withdraw() {

    cout

  • 8/13/2019 1jjjkk

    3/16

    void main()

    {

    int Number,Temp,b=0;

    cout

  • 8/13/2019 1jjjkk

    4/16

    {

    clrscr();

    long int n,rev=0,m,num;

    coutn;

    num=n;

    while(n>0)

    {

    m=n%10;

    rev=rev*10+m;

    n=n/10;

    }

    cout

  • 8/13/2019 1jjjkk

    5/16

    void main()

    {

    clrscr();

    cout

  • 8/13/2019 1jjjkk

    6/16

    using namespace std;

    class data

    {

    int a,b;

    public:

    int sum;

    void getdata(int a,int b);

    void display();

    };

    void data::display()

    {

    cout

  • 8/13/2019 1jjjkk

    7/16

    6.to check whether a number is strong or not

    #include

    int main(){

    int num,i,f,r,sum=0,temp;

    cout > num;

    temp=num;

    while(num){

    i=1,f=1;

    r=num%10;

    while(i

  • 8/13/2019 1jjjkk

    8/16

    return 0;

    }

    7a)Swap numbers using call by reference

    #includevoid swap(int &iNum1, int &iNum2);void main(){int iVar1, iVar2;coutiVar2;swap(iVar1, iVar2);cout

  • 8/13/2019 1jjjkk

    9/16

    #include

    using namespace std;

    long add(long, long);

    float add(float, float);

    int main()

    {

    long a, b, x;

    float c, d, y;

    cout > a >> b;

    x = add(a, b);

    cout d;

    y = add(c, d);

    cout

  • 8/13/2019 1jjjkk

    10/16

    return 0;

    }

    long add(long x, long y)

    {

    long sum;

    sum = x + y;

    return sum;

    }

    float add(float x, float y)

    {

    float sum;

    sum = x + y;

    return sum;

    }

    9. To swap private member values of class by using friend function

    #include

    #include

    class XYZ;

    class ABC;

    {

  • 8/13/2019 1jjjkk

    11/16

    int a;

    public;

    void setdata(int m)

    {

    a=m;

    }

    Friend void exchange(ABC & X,XYZ &W);

    void display data()

    {

    cout

  • 8/13/2019 1jjjkk

    12/16

    void exchange(ABC & value 1,XYZ & value 2)

    {

    int temp;

    temp=value 1.a;

    value 1.a=value 2.b;

    value 2.b=temp;

    };

    void main()

    {

    ABC m;

    m.setdata(10);

    XYZ n;

    n.setdata(20);

    cout

  • 8/13/2019 1jjjkk

    13/16

    int sold;

    int left;

    static int total;

    public:

    void sold_items()

    {

    cout

  • 8/13/2019 1jjjkk

    14/16

    items.stock_remaining();

    items.display();

    return 0;

    }

    11.write the same program without using static members

    #include

    using namespace std;

    class shop

    {int sold;

    int left;

    int total;

    public:

    void sold_items()

    {

    cout

  • 8/13/2019 1jjjkk

    15/16

    }

    };int main()

    {

    shop items;

    items.sold_items();

    items.stock_remaining();

    items.display();

    return 0;

    }

    12. To check whether a string is palindrome or not

    #include

    #include

    using namespace std;

    int main()

    {

    char str[100];

    cout > str;

    int x = strlen(str)-1;

    for(int i = 0; i

  • 8/13/2019 1jjjkk

    16/16

    }

    else

    {

    cout