0% found this document useful (0 votes)
15 views1 page

Program 1

The document provides a C++ program that prompts the user to enter three numbers and determines the largest among them. It includes both C-style and C++-style input/output methods. The program uses conditional statements to compare the numbers and print the largest one.

Uploaded by

Girish BG
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views1 page

Program 1

The document provides a C++ program that prompts the user to enter three numbers and determines the largest among them. It includes both C-style and C++-style input/output methods. The program uses conditional statements to compare the numbers and print the largest one.

Uploaded by

Girish BG
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

1.

Develop a C++ program to find the largest of three numbers

#include <stdio.h>
#include <iostream.h>

int main() { using namespace std;

int a, b, c;
int main() {

printf("Enter the number 1: "); int a, b, c;

scanf("%d", &a);
cout << "Enter number 1: ";

printf("Enter the number 2: "); cin >> a;

scanf("%d", &b);
cout << "Enter number 2: ";

printf("Enter the number 3: "); cin >> b;

scanf("%d", &c);
cout << "Enter number 3: ";

if ((a > b) && (a > c)) { cin >> c;

printf("a is greater: %d\n", a);

} if ((a > b) && (a > c)) {

else if ((b > a) && (b > c)) { cout << "a is greater: " << a
<< endl;
printf("b is greater: %d\n", b);
}
}
else if ((b > a) && (b > c)) {
else {
cout << "b is greater: " << b
printf("c is greater: %d\n", c); << endl;
} }

else {
return 0; cout << "c is greater: " << c
} << endl;

return 0;

You might also like