Dec 9, 2011

Program : To Display user Name by taking input from user

Program : To Display user Name by taking input from user

This Program Use The Concept Of Array, Which You Will Learn Later So Just Leave now if you Don't understand array don't worry we can do it later in details and with better understanding.


Program:-



#include<iostream.h>
#include<conio.h>
int main()
{
cout << "Enter Your Name \n"; // \n for next line cout to display 
char az[20];
/* char is a datatype for  character variable which can store alphabets for declare variable syntax is 
datatype variable_name; variable name cannot be start with Number or any special symbol only _(underscore can be used) and alphabets. In this i declare az[20] this is array which you learn ahead tutorials till now its array that it can store many data of same type. in az[20] i can store 20 character. we know more about array later. */
cin >> az; 
/* Here's Function cin  provided by iostream.h its used to take input from user here we are assign that input to variable az (which can store 20 character max) */

cout << "YOur Name is " << az;
/* This display the value of az that is taken from user and it display back on screen and for display variable. IN double Quote Value we can write anything and to display variable we don't use double quotes we use << variable_name */

getch();
return 0;
 }

ABOVE PROGRAM WITHOUT COMMENTS

#include<iostream.h>
#include<conio.h>
int main()
{
cout << "Enter Your Name \n";
char az[20];
cin >> az;

cout << "YOur Name is " << az;
getch();

return 0;
}





0 comments:

Post a Comment