Pages

Adhexa

Tuesday, August 17, 2010

Getting input – cin

We have already seen what cout does, cin is a similar function except that it reads input from the user instead of writing output. The following is a simple example of how the cin works.

#include <iostream>
using namespace std;
main (){
float area;
int radius;
const float pie = 3.14;
cout<<"Enter the radius of the circle"<<endl;
cin>>radius;
area = pie * radius * radius;
cout<<"Area is "<<area<<endl;
}

No comments:

Post a Comment