I will write a sample program to show you:
#include
using namespace std; //This is what lets you use cin & cout
int main()
{
cout<<"Hi"; //always remember to use insertion operators (<< & >>) and quotes ("") AND ALWAYS TERMINATE YOUR LINE WITH SEMICOLON (;)
}
Hope that helped
cout<<"______": cin >>__>>__; [example cout<<"enter no."; cin>>a>>b; ]
#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 argc,char *argv[]){ int num1,num2; cout << "Enter the first number" << endl; cin >> num1; cout << "Enter the second number" << endl; cin >> num2; cout << "(" << num1 << " " << num2 << " )\n"; return 0; }
#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; }
#include#includemain(){clrscr();coutb;cout
cin and cout are iostream objects, not keywords.
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;
The most basic input/output operations can be performed with std::cin for input and std::cout for output. For example: #include<iostream> int main (void) { int n; std::cout << "Enter a number: "; std::cin >> n; std::cout << "The value " << n << " was entered!\n"; }
#include<iostream> int main() { double a, b; std::cout << "Enter a number: "; std::cin >> a; std::cout << "Enter another number: "; std::cin >> b; std::cout << "Sum: " << a + b << std::endl; std::cout << "Average: " << (a + b) / 2 << std::endl; }
{char a;...cout > a;cout
#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> using namespace std; int main() { int x; cout << "Enter a number: "; cin >> x; if(x % 2 == 0) { cout << x << " is even" << endl; } else { cout << x << " is odd" << endl; } char wait; cin >> wait; return 0; }