I created a program that will find the biggest number when give 3 different numbers. But when I want to change the program to find the biggest number when you enter 4 integer number I continue to run into problems. I can get it to find the biggest number when you in put 3 numbers but when I try to do four it wont let me. Please help.

#include <iostream>
using namespace std;

int findbiggest(int, int, int);

int main()
    int x, y, z;
    cout << "Please input three integers "<< endl;
    cout<<"The biggest number is "<<findbiggest(x, y, z);
    return 0;

int findbiggest(int a, int b, int c)
    int bigger=0;
    if (a>b) bigger=a;
    else bigger=b;
    if (c>bigger) bigger=c;
    cout<<"The biggest number is "<<bigger<<endl;
    return bigger;
5 Years
Discussion Span
Last Post by Ancient Dragon

The code will read in three numbers:
If you type in four numbers, the code doesn't change. It works the same. If you want to be able to enter four numbers, change the code to accept four numbers.


You might want to change the code so that you can enter as many numbers as you want. You don't want to have to change the code every time you want to enter more numbers, or do you?? Maybe you do, but I wouldn't. You can do that by using a while or do loop and ask for the numbers one at a time. Have the loop stop when you enter a specific number, such as -1.

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.