Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

Task 1

int age;
cin>>age;
if(age%2 == 0){
cout<<"Number is EVEN \n";
}
else{
cout<<"Number is ODD \n";
}

Task 2
// For 24 hrs
int Thour,Tmin,Tsec;
// For 12 Hour
int thour,tmin,tsec;
string AMPAM;

cout <<"Enter Hours \n";


cin>>Thour;
cout <<"Enter minutes \n";
cin>>Tmin;
cout <<"Enter Seconds \n";
cin>>Tsec;
if (!(Thour > 24) && !(Tmin > 60) && !(Tsec >60)){
tmin =Tmin;
tsec =Tsec;
if(Thour<=12){
thour = Thour;
AMPAM = "AM";
if(Thour ==12){AMPAM ="PM";}
cout<<" Time in 12 hour format is: "<<thour<<" : "<<tmin<<" :
"<<tsec<<" "<<AMPAM<<endl;
}else{
thour = Thour -12;
AMPAM = "PM";
cout<<" Time in 12 hour format is: "<<thour<<" : "<<tmin<<" :
"<<tsec<<" "<<AMPAM<<endl;
}

}else{
cout<<"Enter correct values";
}

main();

Task 3

int sec,mins,hrs,SEC;
cout<<"Enter Seconds \n";
cin>> sec;
hrs =sec/3600;
mins = (sec%3600)/60;
SEC =((sec%3600)%60);
cout<<sec<<" Seconds is equal to "<<hrs<<" Hours "<<mins<<" minutes"<<"and
"<<SEC<<" seconds"<<endl;

main();

Task 4
float angle,SumOfAngles;
cout <<"Enter angle1 \n";
cin>>angle;
SumOfAngles =angle;
cout <<"Enter angle2 \n";
cin>>angle;
SumOfAngles += angle;
cout <<"Enter angle3 \n";
cin>>angle;
SumOfAngles += angle;

if (SumOfAngles == 180){
cout<<"It is a valid Triangle";
}else{
cout<<"NOT a valid Triangle";}

You might also like