0

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 by mike_2000_17: snipped bad link

3
Contributors
3
Replies
14
Views
3 Years
Discussion Span
Last Post by David W
0

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 by David W: added letter

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

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

getch();
}
0

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

Edited by David W: fixed typos

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.