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

Program 1.1

The program accepts three integer inputs from the user and prints the largest of the three numbers using only if statements. It first assigns the first input to a variable max. It then checks if the second input is greater than max, and if so assigns the second input to max. It repeats this process to check if the third input is greater than max and assigns it if it is larger. It then prints the largest number.

Uploaded by

Aadil
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)
28 views1 page

Program 1.1

The program accepts three integer inputs from the user and prints the largest of the three numbers using only if statements. It first assigns the first input to a variable max. It then checks if the second input is greater than max, and if so assigns the second input to max. It repeats this process to check if the third input is greater than max and assigns it if it is larger. It then prints the largest number.

Uploaded by

Aadil
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

Program 1.

1
Write a program to accept integers and print the largest of the three. Make use of only if statement.

#include<iostream.h>

int main()

int x,y,z,max;

cout<<”Enter three number:”;

cin>>x>>y>>z;

max=x;

if(y>max)

max=y;

if(z>max)

max=z;

cout<<”\n”<<”the largest of”<<x<<”,”

<<y<<”and”<<z<<”is”<<max;

return 0;

Enter three number :- 6 8 10

The largest of 6 ,8 and 10 is 10

You might also like