write a program in c++ that input 2 times from the user and display the sum of times plz master of c++ help me?
write a program in c++ that input 2 times from the user and display the sum of times plz master of c++ help me?
#include<iostream>
using namespace std;
main()
{
int num1,num2;
cout<<"Enter first number.\n";
cin>>num1;
cout<<"Enter second number.\n";
cin>>num2;
cout<<"There sum is = "<<num1+num2;
return 0;
}
waha yar kia program kar ke diya hai ***************
Last edited by M-Qasim; 27th December 2013 at 06:53 PM. Reason: Don't Use Offensive Language, Last Warning Otherwise You will get Infraction
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int tym1_h,tym1_m,tym2_h,tym2_m,hours,mins;
strt:
system("cls");
cout<<"\n\t** Time Calculator **\n"<<endl;
cout<<"Enter Starting Time ( Hours<space>Minutes ): ";
cin>>tym1_h>>tym1_m;
if(tym1_h>12)
{ cout<<"\n\nHours should b/w 1 to 12.\n"<<endl;
system("pause");
goto strt;
}
cout<<"Enter Ending Time ( Hours<space>Minutes ): ";
cin>>tym2_h>>tym2_m;
if(tym2_h>12)
{ cout<<"\n\nHours should b/w 1 to 12.\n"<<endl;
system("pause");
goto strt;
}
hours=tym1_h+tym2_h;
mins=tym1_m+tym2_m;
if(mins>60)
{
hours++;
mins=mins-60;
}
cout<<"\n\n\t Total Time: "<<hours<<" Hours "<<mins<<" Minutes";
return 0;
}
i think this is OK.. hain na.?
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int tym1_h,tym1_m,tym2_h,tym2_m,hours,mins;
strt:
system("cls");
cout<<"\n\t** Time Calculator **\n"<<endl;
cout<<"Enter Starting Time ( Hours<space>Minutes ): ";
cin>>tym1_h>>tym1_m;
if(tym1_h>12)
{ cout<<"\n\nHours should b/w 1 to 12.\n"<<endl;
system("pause");
goto strt;
}
cout<<"Enter Ending Time ( Hours<space>Minutes ): ";
cin>>tym2_h>>tym2_m;
if(tym2_h>12)
{ cout<<"\n\nHours should b/w 1 to 12.\n"<<endl;
system("pause");
goto strt;
}
hours=tym1_h+tym2_h;
mins=tym1_m+tym2_m;
if(mins>60)
{
hours++;
mins=mins-60;
}
cout<<"\n\n\t Total Time: "<<hours<<" Hours "<<mins<<" Minutes";
return 0;
}
i think this is Ok.. hain na.?
Moved From C++ to AAE
Bookmarks