Search

C++ Basic Input/Output

#include<iostream> - contains all the functions including cout, cin, endl.

Let’s see all one by one by the help of a program


“cout” – used for print something/ anything

  • #include<iostream>

  • using namespace std;

  • int main()

  • {

  • cout<<”Something”<<”Anything”;

  • }



Output –


SomethingAnything


Looking Bad ! Right

Okay !

Conversation Begins ….

“cout” to “endl” – please make me look better.

“endl” to “cout” – okay ! I will but you have to use my keyword “endl”

“cout” – okay dear !


Let’s see what “endl” is going to do with this program…..

“endl” – used to generate next line during the program

  • #include<iostream>

  • using namespace std;

  • int main()

  • {

  • cout<<”Something”<<endl<<”Anything”;

  • }



Output –


Something

Anything



“cin” – used to take input from user – dynamic input

Suppose A have single crush, So he is going to use fix value – constant & our B having multiple crushes. So, he is going to be variable !

Sounds Interesting !!!

Let’s See How

A – “No need of cin” – constant value

  • #include<iostream>

  • using namespace std;

  • int main()

  • {

  • int a=9;

  • cout<<a;

  • }


Output –


9


Now B – who wants to change each time – requires “cin”

  • #include<iostream>

  • using namespace std;

  • int main()

  • {

  • int a;

  • cin>>a;

  • cout<<a;

  • }



Output –


0 //userinput

0 //output


Move to Next Page

---------------------------------------------------------------------------------------------------------------------

Previous Page Next Page



Any Doubt ? Feel free to write a comment

Download C++ Projects

Join us on LinkedIn – Great Place of Networking

Follow us on More Together – Facebook for regular updates

Mandatory to join Telegram group for regular job updates

Mandatory to join whatsapp group for regular job updates


Other C++ Topics



For Other Tutorials – Click Here


3 views0 comments

Related Posts

See All

Number to Character Conversion in C++

Program to implement Number to Character Conversion in C++ Firstly see what we are going to do ? Like this 0 - zero 1 – one 2 – two 3 – three 4 – four 5 – five 6 – six 7 – seven 8 – eight 9 – nine How

Factorial of a number in C++

In this tutorial we are going to see how to find a factorial of number using C++ program Firstly let’s see a example to understand it better n! = n + (n-1) + (n-2) ! n>=1 3! = 3 *2*1 = 6 Program to fi

Fibonacci Triangle in C++

Program to implement Fibonacci Triangle in C++ #include <iostream> using namespace std; int main() { int a=0,b=1,i,c,n,j; cout<<"Enter the limit: "; cin>>n; for(i=1; i<=n; i++) { a=0; b=1; cout<<b<<"\

Info © Copyright 2020-21 Fresher Side. All rights reserved. Contact us