0% found this document useful (0 votes)
31 views6 pages

Q1: Take Two Number From The User and Display The Greater Number

assigment of code

Uploaded by

Ch Ashan Ahmed
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)
31 views6 pages

Q1: Take Two Number From The User and Display The Greater Number

assigment of code

Uploaded by

Ch Ashan Ahmed
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/ 6

Question :1

Q1: Take two number from the user and display the greater number
#include<iostream>

using namespace std;

int main()

int num1,num2;

cout<<"enter first number :\n";

cin>>num1;

cout<<"enter second num:\n";

cin>>num2;

if(num1>num2)

cout<<"the greater number is:"<<num1;

else

cout<<"the greater number is:"<<num2;

return 0;

RESULT:
Q2: Take a number from the user and tell it that multiple of two or not
#include<iostream>

using namespace std;

int main()

int num;

cout<<"enter a number:";

cin>>num;

if(num%2==0)

cout<<"the number is the multiple of2"<<endl;

else

cout<<"the number is not multiple of 2"<<endl;

return 0;

Result:
Q: 3 Input two number from the user tae the sum and display that sum is
greater then 100 or not
#include<iostream>

using namespace std;

int main()

int num1,num2;

cout<<"enter the first number";

cin>>num1,

cout<<"enter second number";

cin>>num2;

int sum=num1+num2;

if(sum>100)

cout<<"the sum of two number is greater than hundred";

else

cout<<"the sum of two number is less than hundred";

return 0;

RESULT:
Q:4 Input two number from the user , multiply them and tell their
answer is even or odd
#include <iostream>

using namespace std;

int main()

int num1,num2;

cout<<"enter the first number";

cin>>num1,

cout<<"enter second number";

cin>>num2;

int ans=num1*num2;

if(ans%2==0)

cout<<"the anwer is"<<ans<<"which is even";

else

cout<<"the answer is"<<ans<<"which is odd";

return 0;

}
RESULT:

Q:5 Input a number from the user if number is odd make it even ………
your program display message that number is already even
#include <iostream>

using namespace std;

int main()

int num;

cout<<"enter the number to make even";

cin>>num;

if(num%2==0)

cout<<"this number is already even number, enter another number";

else

int result=num+1;

cout<<"the result is"<<result<<"as you can see number has been made even";

return 0;

Result:

You might also like