std:cin and std:cout are the standard console input and output streams, respectively. By default, input is redirected from the console keyboard and output redirected to the console screen. However, both streams can be redirected from the command line. This not only allows input and output to be redirected from disk files but also permits the output of one program to be redirected as input to another, allowing two or more programs to be chained together (assuming the output of one program is in the exact format required as input to the next).
cout<<"______": cin >>__>>__; [example cout<<"enter no."; cin>>a>>b; ]
In the programming language C++, cin is used to input the variable and cout is used to print a certain message or result.
#include<iostream.h> #include<conio.h> void main() { int a,b,c; cout<<"enter the value of a"<<endl; cin>>a; cout<<"enter the value of b"<<endl; cin>>b; cout<<"enter the value of c"<<endl; cin>>c; if(a>b) { if(b>c) { cout<<"the middle number is b:"<<endl; } else { if(a>c) { cout<<"the middle is c:"<<endl; } else { cout<<"the middle number is b:"<<endl; } } if(a<b) { if(b<c) { cout<<"the middle number is b:"<<endl; } else { if(a<c) { cout<<"the middle number is c:"<<endl; } else { cout<<"the middle number is a:"<<endl; } } }
#include<iostream> using namespace std; int gcf(int a, int b) { int t; while(b!=0) { t = b; b = a%b; a = t; } return a; } int main() { int a,b,c,d,e,f,g,h,i,j,k; cout<<"Enter 1st numbers: "; cin>>a; cout<<"Enter 2nd numbers: "; cin>>b; cout<<"Enter 3rd numbers: "; cin>>c; cout<<"Enter 4th numbers: "; cin>>d; cout<<"Enter 5th numbers: "; cin>>e; cout<<"Enter 6th numbers: "; cin>>f; cout<<"Enter 7th numbers: "; cin>>g; cout<<"Enter 8th numbers: "; cin>>h; cout<<"Enter 9th numbers: "; cin>>i; cout<<"Enter 10th numbers: "; cin>>j; k=gcf((((((((gcf(a,b),c),d),e),f),g),h),i),j); cout<<"The GCD of the 10 numbers is: "<<k<<endl; system("pause"); return 0; }
The cin and cout entities (they are not statements) are C++ iostream library objects that allows access to "standard input" and "standard output". In C++, the statement cout > variable; allows reading from standard input to a variable.
I am a student of class 10. I doesn't know C Language but I can tell such a program in C++ Language.... //------------------------------------ #include <iostream.h> #include <conio.h> void main() { int a,b,c,m; clrscr(); cout<<"Enter First Number: "; cin>>a; cout<<"Enter Second Number: "; cin>>b; if (a<b) m=a; if (a>b) m=b; cout<<"Enter Third Number: "; cin>>c; if (c<m) cout<<"The Largest Number is "<<m; else cout<<"The Largest Number is "<<c; getch(); }
#include<iostream.h> void main() { int l,b,h,v; cout<<"Enter length "; cin>>l; cout<<"Enter breadth "; cin>>b; cout<<"Enter Height "; cin>>h; v=l*b*h; cout<<"Volume is "<<v; }
#include<iostream.h> main() { int C,D,E; cout<<"Number at location C="; cin>>C; cout<<"Number at location D="; cin>>D; E=C; C=D; D=E; cout<<"New Number At Location C="<<C<<endl; cout<<"New Number At Location D="<<D<<endl; }
The class cin is an iostream class that abstracts stdin, allowing you to read from the stdin (console input) file. For instance: int age; cout << "How old are you? "; cin >> age; cout << "You said you were " << age " years of age " << endl;
#include<iostream.h> #include<conio.h> void main() { int a, b, c; clrscr(); cout<<"enter the two numbers"; cin>>a; cin>b; c=a+b; cout<<"Addition of two numbers="<<c; getch(); }
#include <iostream> using namespace std; int main() { int x,y; cout<<"please, enter the 1st value : "; cin>>x; cout<<"please, enter the 2nd value : "; cin>>y; cout<<endl; cout<<"the first value is : "<<x<<endl; cout<<"the second value is : "<<y<<endl; return 0; }
cin and cout are not operators, they are objects. cin is console input while cout is console output (explicitly idintified as std::cin and std::cout). In other words they are the C++ standard library stream objects that represent stdin and stdout respectively. The corresponding std::cerr stream represents stderr, the console error stream. std::cerr is typically directed to the screen while std::in and std::cout are also typically directed to the screen but can be redirected via the command line when executing the binary executable.