Pages

Friday, June 23, 2017

Using char variable in C++ programs.


#include<iostream>
using namespace std;

int main()
{
  char name[20];

  cout<<"Enter your name: ";
  cin>>name;

  cout<<"Your Name is : "<< name;
  return 0;
}

Output of program

Enter your name: Earth
Your Name is : Earth

Note: This program will be able to read only one word as your name.

No comments:

Post a Comment