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?
(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";
}
}
Comments
Leave a comment