Inputs and Outputs C++

Inputs and Outputs Using C++

In this blog I will be giving a brief explanation on the diverse ways to carry out inputs and outputs using C++.  There are output functions such as "printf" as well as an output object like "cout" and there are input objects such as "cin" and input functions such as "scanf". The input allows for variable values to be assigned using input from the user using a keyboard and the output allows for information from the code to be displayed onto a screen.

Inputs into the code is normally stored in variables, variables are memory containers used to store values across several types such as Strings which store text, Integers which store whole numbers, Doubles which store decimal numbers with a lot of digits, Floats which store fewer decimal numbers and Longs which store sixty-four-bit integers. The type of the variable is normally declared before the name of the variable.



Outputs

Printf:

Printf is a formatting type of function that is used to print out into the standard output.

cout: 

Cout also prints out into the standard output, Cout means character output, "<<" shows the direction in which the data is moving. So, in this case the data is moving right which means it's going to the output screen and printing out the text in between the quotations. Std is for standard which together with cout means standard output.


Inputs

Cin 

Cin means character input; it is used to collect input value. The character input gets stored into the variable and moves into the console.


Scanf

Scanf is a function used to read variables from the user's input.



Live Code Example:







Comments

Popular posts from this blog

How to Open a C++ Project on VS22 and get started

How To Write to File on C++

How To Use Arrays in C++