The cin and cout objects are iostream objects somewhat equivalent to stdin and stdout.
The equivalent of printf ("Hello World\n"); is cout << "Hello World" << endl;
The equivalent of scanf ("%d", &i); is cin >> i;
cin and cout are iostream objects, not keywords.
#include<iostream.h> class student { char name[10]; int rollno; public: void get() { cout<<"enter student's name"<<endl; cin>>name; cout<<"enter student's rollno"<<endl; cin>>rollno; } void disp() { cout<<"Name of the student is : "<<name<<endl; cout<<"Rollno is : "<<rollno<<endl; } }; class marks:public student { char subjectname[15]; int subcode,intmarks,extmarks; public: void get() { student::get(); cout<<"enter subject name"; cin>>subjectname; cout<<"enter subject code"; cin>>subcode; cout<<"enter Internal marks"; cin>>intmarks; cout<<"enter External marks"; cin>>extmarks; } void disp() { student::disp(); cout<<"Subject name is : "<<subjectname<<endl; cout<<"Subject code is : "<<subcode<<endl; cout<<"Internal marks : "<<intmarks<<endl; cout<<"External marks : "<<extmarks<<endl; } }; void main() { marks m; m.get(); m.disp(); }
{char a;...cout > a;cout
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.
#include using std::cin;using std::cout;using std::endl;int main(){double firstNumber(0);cout firstNumber;double secondNumber(0);cout secondNumber;cout
cin and cout are iostream objects, not keywords.
cin and cout are synonymous with stdin and stdout, implementing console input and output respectively.
cout<<"______": cin >>__>>__; [example cout<<"enter no."; cin>>a>>b; ]
#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; }
#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> 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; }
In C++: #include <iostream> using namespace std; int main() { int x, y; char func; cout << "Enter a number: "; cin >> x; cout << "Choose Function: "; cin >> func; cout << "Enter another number: "; cin >> y; switch(func) { case '+': cout << x + y << endl; break; case '-': cout << x - y << endl; break; case '*': cout << x * y << endl; break; case '/': cout << x / y << endl; break; default: cout << "Invalid Function!" << endl; break; } char wait; cin >> wait; return 0; }
#include<iostream.h> class student { char name[10]; int rollno; public: void get() { cout<<"enter student's name"<<endl; cin>>name; cout<<"enter student's rollno"<<endl; cin>>rollno; } void disp() { cout<<"Name of the student is : "<<name<<endl; cout<<"Rollno is : "<<rollno<<endl; } }; class marks:public student { char subjectname[15]; int subcode,intmarks,extmarks; public: void get() { student::get(); cout<<"enter subject name"; cin>>subjectname; cout<<"enter subject code"; cin>>subcode; cout<<"enter Internal marks"; cin>>intmarks; cout<<"enter External marks"; cin>>extmarks; } void disp() { student::disp(); cout<<"Subject name is : "<<subjectname<<endl; cout<<"Subject code is : "<<subcode<<endl; cout<<"Internal marks : "<<intmarks<<endl; cout<<"External marks : "<<extmarks<<endl; } }; void main() { marks m; m.get(); m.disp(); }
#include #include #include class student { int roll; char name[25]; char add [25]; char *city; public: student() { coutname; cout>sub3; } void output() { putdata(); cout
#include #include #include class student { int roll; char name[25]; char add [25]; char *city; public: student() { coutname; cout>sub3; } void output() { putdata(); cout
{char a;...cout > a;cout
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.