Skip to main content

How to take input in C++


Hello azumavengers and welcome to my blog. Today we will talk about taking input in C++.

How to take input in C++

There are different ways of taking input for the variables or objects. 

Usually programs take input from keyboard or from files on disks or from data base. Right now filing and data base is not our concern so we will discuss about the input given using keyboard.

For taking input from user we use extraction operators ">>". The reserved word used for taking input in cin. Actually cout and cin are the variable instances of the classes declared in iostream. cout is the variable of type ostream and cin is the variable of type istream.

Let's see an example

#include<iostream>
using namespace std;
void main()
{
 int var1 = 0;//integer 
 cout << "Enter an integer = ";//displays Enter an integer = 
 cin >> var1;//waits for user to enter value 
 system("pause");
}

Here cin>>var1 will stop the program and wait for the user to enter a legal value. 

Don't forget to share your views, follow the blog and subscribe to it. Also share

your views below.

Comments

Popular posts from this blog

Theory of Automata Assignment #2 Part #2 Regular Expression # 6 The set of strings over {a,b} that contain at least two a's or exactly two b's. (a+b)*(a)(b*)a(a+b)*+a*b(a*)b(a*) Regular Expression # 7 The set of strings over {a,b} that contain even length but not multiple of 3 (aa*)(aaa^) Regular Expression # 8 The language over {a,b}contains exactly one double letter.   (ε + b)(ab) ∗aa(ba) ∗(ε + b) + (ε + a)(ba) ∗ bb(ab) ∗(ε + a)

TA ASSIGNMENT 1 PART 3

Theory of Automata Assignment #1 Part #3 Recursive Definition #11: Language of Expressions having at least one operator defined on  Σ ={+,-,*,/,a,b}  Step 1#- a+b ,a*b,a/b and a-b are in L Step 2#- If x is in L then x+x,x-x,x*x,x/x is also in L Step 3#- No words except generated above can be considered as member of Language. Recursive Definition #12: Language of string starting and ending on different alphabet defined on  Σ ={a,b} Step 1#- ab and ba are in L Step 2#- If x is in L then axb,and bxa are also in  Σ*.   Step 3#- No words except generated above can be considered as member of Language. Recursive Definition #13: Language of even numbers Step 1#- 0 and 2 are in L Step 2#- If x is in L then x+2 and x-2 is also in L .   Step 3#- No words except generated above can be considered as member of Language. Recursive Definition #14: Language of negative integers d...

Insta, Twitter and Facebook Desktop To Mobile Version

Hello azumavengers and welcome to my blog. Today we are going to talk about some insta, twiter and fb tricks. Web Api's Tricks Facebook, Insta and twitter Desktop To Mobile Version By Codezila  Like our Facebook page, its link is given below Codzila Facebook Page