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.

Edited 2 Years Ago by mike_2000_17: snipped bad link

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.

Edited 2 Years Ago by David W: added letter


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


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

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

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

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

Edited 2 Years Ago by David W: fixed typos

This article has been dead for over six months. Start a new discussion instead.