0

Write a C++ program that can take either two integers or two floating point numbers and outputs the smallest number using class, friend functions and function overloading.

5
Contributors
4
Replies
41
Views
3 Years
Discussion Span
Last Post by yazan.quraan.39
0

What have you tried so far? We don't do homeworks for people here. You have to show some efforts and ask about some specific problems that you are having with your own code.

0

I have the code ready... Let me know when you need it so i can post it here for you ok? Read the FAQ's first anyway ok?

-1
/* Writing a simple program for comparing 2 integers */
#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
    int a = 0;
    int b = 0;       /* You can also use double or other types here */
    /* I should note that you must initialize your variables or else you will end up having Access Violation errors */

    cout << "Please enter A then press Enter : ";
    cin >> a;
    cout << "Please enter B then press Enter : ";
    cin >> b;

    /* Comparing a to b and writing the smallest number on output */
    if (a < b) cout << "The smallest number is : " << a;
    else cout << "The smallest number is : " << b;
    return 0;
}

If you study your books well enough , you will have a clue how to convert this to an object-oriented program :-)

Edited by ArashVenus

-5

Q2: Write a C++ program that prompts the user to insert two integers to send them to a function that will return the Greatest Common Division (GCD) )
note: using function

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.