Find the total number of seconds hours and minutes as input
Subject
Number
SUM OF The TEN NUM = 55
Press any key to continue . . .
In this Post I am discuss how to write a c++ program that finds the total second in the given time, Time will be taken as hours, minutes and seconds. Find the total number of seconds.
In in program declare five variable Hour, Min, TimeinHour, Timeinsec, Totalsecond as datatype is float and hours, minute as input from users and calculate the total number of seconds.
OUTPUT:
Source Program:
Source Program
# include "iostream"
using namespace std;
void main()
{
float Hour, Min, TimeinHour,
Timeinsec, Totalsecond;
cout<<"Hour is = ";
cin>>Hour;
cout<<"The Total Time in
Hour is = ";
TimeinHour=Hour*3600;
cout<<TimeinHour<<endl;
cout<<"The min is =
";
cin>>Min;
cout<<"The Total Time in
Sec is = ";
Timeinsec=Min*60;
cout<<Timeinsec<<endl;
cout<<"The Total second
is = ";
Totalsecond = TimeinHour + Timeinsec;
cout<<Totalsecond<<endl;
}
The output should look like this.
Hour is = 5
The Total Time in Hour is = 18000
The min is = 32
The Total Time in Sec is = 1920
The Total second is = 19920
Press any key to continue . . .
Hour is = 5
The Total Time in Hour is = 18000
The min is = 32
The Total Time in Sec is = 1920
The Total second is = 19920
Press any key to continue . . .
Subject:
In this Post I am discuss how to write a c++ program that understand how the if and else condition work.
Source Program:
Declare one variable as datatype as char and user enter the character range from a-z and program find only two character m,f including in upper and lower case letter.
#include "iostream"
using namespace std;
void main ()
{
char a;
cout<<"Please Enter
Gender :";
cin>>a;
if(a=='m'||a=='M')
{
cout<<"Male"<<endl;
}
else if(a=='f'||a=='F')
{
cout<<"Female"<<endl;
}
else
{
cout<<"Invalid"<<endl;
}
}
Output:
The output should look like this.
Please Enter Gender :m
Male
Press any key to continue . . .
Subject
In this Post I am discuss how to write a c++ program student letter grade is calculated
by following rules user enter there marks and and calculate the grade for the users.
Source Program:
Declare one variable as Marks datatype as int and user enter the marks and program find grade for the user this program is the basic under standing of if and else condition.
#include "iostream"
using namespace std;
void main ()
{
int Marks;
cout<<"Please Enter Marks is:";
cin>>Marks;
if( Marks >= 90 && Marks <=
100 )
{
cout<<"A Grade";
}
else if (
Marks < 90 && Marks >= 80 )
{
cout<<"B Grade";
}
else if( Marks < 80 && Marks
>= 70 )
{
cout<<"C Grade";
}
else if( Marks < 70 && Marks
>= 60 )
{
cout<<"D Grade";
}
else if( Marks < 60 )
{
cout<<"F Grade";
}
else
{
cout<<"Invalid Grade"<<endl;
}
}
Output
The output should look like this.
Please Enter Marks is:99
Declare one variable and datatype is int and calculate the odd number for the program.
#include "iostream"
using namespace std;
void main()
{
int a=0;
cout<<"Number"<<endl;
for ( int i=1 ; i <= 10 ; i++ )
{
a=i+a;
}
cout<<"SUM OF
The TEN NUM = "<<a<<endl;
}
Output:
The output should look like this.
Number
SUM OF The TEN NUM = 55
Press any key to continue . . .