Write a program to get 3 numbers from user for integer variable a, b,and c. if a is not zero, find out whether it is the common divisor of b and c.

Do you know how to code a 'Hello World' C++ program?

Do you know how to get integer user input (using cin) with a prompt for input?

Do you know how to code to test if a is zero ?

Do you know what 7 % 3 is ... in C++ ? ( or... 6 % 3 ? )

Do you that a && b is true only if both a is true and b is true?

Start with a working 'Hello World' shell ... and add / compile / test from there.

When you get into a bind ...afer going back to your lasting working stage ... and trying again from there ...

Show us your last working stage ... and the compiler errors printed out where you can not see what the problem is.

#Include<iostream.h>
#include<conio.h>

void main()
{
clrscr();
cout<<"Hello World!!!";

getch();
}

Look here for some more ideas about getting input ...

Click Here

Do you see the code option ... use that to submit code to preserve the indentation

#include <iostream>

// do NOT use to keep code portable
//#include<conio.h> 

int main() // NOT void main
{
    // clrscr(); // NOT portable code
    std::cout<<"Hello World!!!";
    // getch(); // NOT portable code

    std::cout << "Press 'Enter' to continue ... ";
    std::flush;
    std::cin.get();
    return 0; // if left off, C++ will supply this
}

Now ... code for some input of a, b and c

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.