//1.Take any 3 integer numbers.
Write a program to find out the largest number
among 3 numbers.
#include<iostream>
using namespace std;
int main(){
int a,b,c;
cout<<"input 3 numbers"<<endl;
cin>>a>>b>>c;
if(a>b && a>c){
cout<<a<<" is the largest number";
}
else if(b>c && b>a){
cout<<b<<" is the largest number";
}
else if(c>a && c>b){
cout<<c<<" is the largest number";
}
return 0;
}
/*2.Take any letter input through the keyboard. Write a program to find out whether
it is a vowel or a consonant.
For non-alphabet inputs, the output will be “Not a character”*/
#include<iostream>
using namespace std;
int main(){
char l;
cout<<"Enter a letter "<<endl;
cin>>l;
if(l>='a' && l<='z')
{
if(l=='a' || l=='e'||l=='i'||l=='o'||l=='u')
{
cout<<l<<" is a vowel";
}
else
{
cout<<l<<" is a consonant";
}
}
else if(l>='A' && l<='Z')
{
if(l=='A' || l=='E'||l=='I'||l=='O'||l=='U')
{
cout<<l<<" is a vowel";
}
else
{
cout<<l<<" is a consonant";
}
}
else{
cout<<"invalid charecter";
}
return 0;
}
//3.Take input of age of 4people by the user and determine oldest and youngest
among them.
#include<iostream>
using namespace std;
int main(){
float a1,a2,a3,a4;
cout<<" input the age of 4 people"<<endl;;
cin>>a1>>a2>>a3>>a4;
cout<<endl;
if(a1>a2 && a1>a3 && a1>a4)
cout<<"Person 1 is the oldest and his age is "<<a1<<endl;
if(a2>a1 && a2>a3 && a2>a4)
cout<<"Person 2 is the oldest and his age is "<<a2<<endl;
if(a3>a2 && a3>a1 && a3>a4)
cout<<"Person 3 is the oldest and his age is "<<a3<<endl;
if(a4>a2 && a4>a3 && a4>a1)
cout<<"Person 4 is the oldest and his age is "<<a4<<endl;
if(a1<a2 && a1<a3 && a1<a4)
cout<<"Person 1 is the youngest and his age is "<<a1<<endl;
if(a2<a1 && a2<a3 && a2<a4)
cout<<"Person 2 is the youngest and his age is "<<a2<<endl;
if(a3<a2 && a3<a1 && a3<a4)
cout<<"Person 3 is the youngest and his age is "<<a3<<endl;
if(a4<a2 && a4<a3 && a4<a1)
cout<<"Person 4 is the youngest and his age is "<<a4<<endl;
return 0;
/*4.A company wants to calculate the total sales of its employees.
Write a program that asks the user to input the sales data of different employees,
and then calculates the total sales for each employee and the company.*/
#include<iostream>
using namespace std;
int main(){
int n,tyitem,item,price,tselp,p1,tcsel=0,temp;
cout<<"Enter employee numbers ";
cin>>n;
string a[n];
for(int i=0;i<n;i++){
cout<<"name of employee "<<i+1<<endl;
cin>>a[i];
}
for(int j=0;j<n;j++){
cout<<"input item type for "<<a[j]<<endl;
cin>>tyitem;
for(int k=0;k<tyitem;k++){
cout<<" sold number for item type "<<k+1<<endl;
cin>>item;
cout<<"price of that item"<<endl;
cin>>price;
p1=item*price;
tselp+=p1;
}
cout<<"total sales of "<<a[j]<<" is "<<tselp<<endl<<endl;
temp=tselp;
tselp=0;
tcsel=tcsel+temp;
}
cout<<"Company total sell is "<<tcsel;
}
5.//Develop a program that takes three students CGPAs as inputs using a single
array and finds thelowest CGPA.
#include<iostream>
using namespace std;
int
main ()
{
float a[3];
for (int i = 0; i < 3; i++)
{
cout<<"Enter cgpa of student "<<i+1<<endl;
cin >> a[i];
}
if(a[0]<=4 && a[0]>=0 && a[1]<=4 && a[1]>=0 && a[2]<=4 && a[2]>=0)
{
if (a[0] < a[1] && a[0] < a[2])
cout << a[0] << " is the lowest CGPA";
if (a[1] < a[0] && a[1] < a[2])
cout << a[1] << " is the lowest CGPA";
if (a[2] < a[1] && a[2] < a[0])
cout << a[2] << " is the lowest CGPA";
}
else{
cout<<"invalid CGPA";
}
return 0;