Answer to Question #185732 in C++ for khay

Question #185732

a) Write a program to check whether a number input by user is even number. If true, multiply that number with 10 and display it. Determine what type of selection is it?


b) Write program to input one character. Check whether a character is equal with ‘N’. If yes, then user need to input two number. Calculate the summation of two numbers. Otherwise, user need to display “success”. Determine what type of selection is it?


1
Expert's answer
2021-04-27T07:16:04-0400


(a)

#include<iostream>

using namespace std;
int main()
{
    int n,n1;
    cout<<"Enter a number ";
    cin>>n;
    if(n%2==0)
    {
        n1=n*10;
        cout<<n1;
    }
}

(b)

#include<iostream>
using namespace std;
int main()
{
    char ch;
    cout<<"Enter a character ";
    cin>>ch;
    if(ch=='N')
    {
        int n1,n2,n3;
        cout<<"\nEnter two numbers ";
        cin>>n1>>n2;
        n3=n1+n2;
        cout<<"Sum of numbers = "<<n3;
    }
    else
    {
        cout<<"Success";
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS