iTech College - Internet Technology, Online Education, E-Learning, Technician Training, Tech Tutorials, Distance Education, Virtual Learning C++ Course: Output and Input Data - www.itechcollege.com C++ Course: Output and Input Data - www.itechcollege.com
Free Courses
HTML
JavaScript
CSS
ASP
PHP
JSP
C++
ASP.NET
SQL
AJAX
FTP
XML

courses > C++ > Output and Input Data

Output and Input Data

C++ uses "cout <<" for output (strings, streams, numbers, objects etc).

C++ use "cin >>" for input. for example:

cin >> name;

So "cin >>" is the opposite of "cout <<".

The following is an example of how to use "cout <<" and "cin >>":

#include <iostream>
using namespace std;
int main(){
  string name;
  cout << "Hello. Whats your name?";
  cin >> name;
  cout << "Hello "<< name;
}

This program uses "cout <<" to ask an user "Whats your name". When the user inputs his name. It reads the name of the user and displays it out.

Comments

Comments are used by programmers to write notes, descriptions within the source code. Comments are ignored by the compiler. When you have one line comment, you can write it with two forward slashes:

//this is my comment

If you have multiple comments, you can write them within "/*" and "*/":

/*
These are my comments
... 
*/

For example, in the above program, we can insert comments as following:

/* 
my first C++ program
"Hello Whats your name?" 
*/

#include <iostream>
using namespace std;
int main(){ //main function
  string name;
  cout << "Hello. Whats your name?";//print out 
  cin >> name; // input
  cout << "Hello "<< name;
}


  Back to Index Page
 Next Page:  

Include a File and Main Function
Output and Input Data
Variables
Arrays
Operators
The If Statement and The Switch Statement
Loops
Function
Read and Write a Text File
Using Database MySQL
Drawing and Graphics


Online Education, Online Training for Your Job, Distance Education, E-learning Programs for Your Career!Online Colleges, Online Universities, E-learning & Distance Education for Your Career! Easy Job Training & Online Courses.


   Email A Friend  
 
Earn Online Degree
for Your Job
I found a job after I earned an online degree!
Online classes for finding a Job. Online College, Online University, Degrees, E-learning school, online certificate Earn your
online degree now!
Online Training
for Good Job
Why I work so hard but earn so little? Why I cannot find a high paying job?
Online training for a Good Jobs. Online Degree, E-learning school, online certificate Go to
online school now!

Copyright ©2024, itechcollege.com. All rights reserved
iTechCollege | About iTech | Contact iTech