String Input form User in C++

String input in C++ programming is used to take string input from the user, scanf() is one of the commonly used function to take string input from the user.

Program Printing String Value

Program

#include<iostream.h>
#include<conio.h>
#include<string> //including Library for Working with String.
void main()
{
 string str; //'str' used for String value.
 str = "Bilal Khan Afridi"; //assigning value to 'str'.
 cout<<"The Name is: "<<str<<endl; //and printing.
getch();
}
Output
The Name is: Bilal Khan Afridi

Program User Enter String Value Printing

Program

#include<iostream.h>
#include<conio.h>
#include<string> //including Library for Working with String.
void main()
{
 string str; //'str' used for String value.
 cout<<"Please Enter Ur Name: ";
 cin>>str; //user Enter value storing in 'str'.
  cout<<"The Name is: "<<str<<endl; //and printing.
getch();
}
Output
Please Enter Ur Name: Bilal
The Name is: Bilal

Program Using Math Library for Power

Program

#include<iostream.h>
#include<conio.h>
#include<math.h> //Including Library for Maths.
void main()
{
int a;
a = pow(3, 2); //assigning 3 Power 2 to 'a'.
cout<<"3 Power 2 is: "<<a; //and printing.
getch();
}
Output
3 Power 2 is: 9