Display Users Details
This program takes two times as input and displays the total time after adding both the entered times.
Example: Program to add two times
#include <iostream>
using namespace std;
#define MAX_LENGTH 100
int main()
{
char name[MAX_LENGTH]={0};
int age;
cout<<"Enter name of the person: ";
cin.getline(name,MAX_LENGTH);
cout<<"Enter age: ";
cin>>age;
cout<<"Name: "<<name<<endl;
cout<<"Age: "<<age<<endl;
return 0; }
Output
Enter name of the person: NoidaTut
Enter age: 25
Name: NoidaTut
Age: 25
#define MAX_LENGTH 100
This Macro is using to define maximum number of character to declare character array and to read maximum number of character through cin.getline().
cin.getline(name,MAX_LENGTH)
This is a library method of cin object (istream class), which is using to read maximum of MAX_LENGTH (100) characters from the keyboard with spaces.
Leave Comment