C++ basic Input & Output

One of the most common functions of programming is input and output.  Within C++ input and output occur in streams.  Streams are also known as sequences of bytes.  If the given bytes originate from a keyboard or a disk drive and flow to the main memory, this is categorized as an input operation. Output is categorized as the flow of bytes from the main memory to a screen or monitor. ```c++ #iclude <iostream> using namespace std; int main(){ int a = 67; int b = 67; int c = a+b; } ``` Run the program below in order to accurately see the cout statement at work. The output for the above program should be the correct value of c, with the given statement. Two important things to note in this program include the insert operator, << and the end1. The end1 is used to add a new line to the end of the given string line. The << can be used multiple times, as we can see above. ## using cin The use of cin allows the user to input information into a given variable. This object belongs to the istream family, which is attached to the input device which is generally a device similar to a keyboard.  The extraction operator is the opposite of the insertion operator.  It is simply >>, which will be seen in the program example below. ```c++ #include <iostream> usung namespace std; int main(){ char petname[40]; cout <<"Please enter the name of your pet: "; cin >>petname; cout <<"Your name is: " <<petname <<endl; cout << "Please enter your full name: "; cin >>yourname; cout <<"Your name is: "<<yourname<<endl; } ``` Upon running the program, you will be prompted to enter in your pet’s name.  It will then be printed.  You will then be prompted to enter your name and it will be printed as well. to help me bring you more content like this, if you like it leave your comment here.

All comments