Thursday, 7 August 2014

DSPS: divisibility of 3

//============================================================================
// Name        : 3_divisibility.cpp
// Author      : Parashar
// Version     :
// Copyright   : Do not try this at home ;P
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

class divisiblility
{
public:
    int a,c;
public:
    void getdata();
    void process();
};

void divisiblility::getdata()
{
    cout<<"enter a number";
    cin>>a;
}

void divisiblility::process()
{
    c=a%3;
    if(c==0)
    {
        cout<<"the number is divisible by 3"<<endl;
    }
    else
    {
        cout<<"the number is not divisible by 3"<<endl;
    }
}


int main()
{
    char key='y'||'Y';
    cout << "Made by PARASHAR" << endl;
    divisiblility d;

        do{
            d.getdata();
            d.process();


            cout<<"do u wanna continue?"<<endl;
            cout<<"press Y to continue";
            cin>>key;
            }while(key=='y'||key=='Y');
    return 0;
}

No comments:

Post a Comment