COUT is an inbuilt function in c++ language. Cout is used to print something on to the standard output.
stipulative definition is stipulative definition
definition feasible region definition feasible region
the two types of definition are the formal and informal definition.
It is a name, there is no definition.
Definition for pry
the code for the box is: # include <iostream> using namespace std; void main () { cout << "*********\n"; cout << "*\t*\n"; cout << "*\t*\n"; cout << "*\t*\n"; cout << "*\t*\n"; cout << "*\t*\n"; cout << "*\t*\n"; cout << "*\t*\n"; cout << "*********\n"; the code for the oval is: # include <iostream> using namespace std; void main () { cout << " ***\n"; cout <<" * *\n"; cout <<"* *\n"; cout <<"* *\n"; cout <<"* *\n"; cout <<"* *\n"; cout <<"* *\n"; cout <<" * *\n"; cout << " ***\n"; the code for the arrow is: # include <iostream> using namespace std; void main () { cout << " * \n"; cout <<" ***\n"; cout <<"*****\n"; cout <<" * \n"; cout <<" * \n"; cout <<" * \n"; cout <<" * \n"; cout <<" * \n"; the code for the diamond: # include <iostream> using namespace std; void main () { cout << " *\n "; cout <<" * *\n"; cout<<" * *\n"; cout<<" * *\n"; cout<<"* *\n"; cout<<" * *\n"; cout<<" * *\n"; cout <<" * *\n"; cout << " *\n "; }
This is an incomplete sentence, and "cout" is not a word.
// Pointing // Demonstrates using pointers #include <iostream> #include <string> using namespace std; int main() { int* pAPointer; //declare a pointer int* pScore = 0; //declare and initialize a pointer int score = 1000; pScore = &score; //assign pointer pScore address of variable score cout << "Assigning &score to pScore\n"; cout << "&score is: " << &score << "\n"; //address of score variable cout << "pScore is: " << pScore << "\n"; //address stored in pointer cout << "score is: " << score << "\n"; cout << "*pScore is: " << *pScore << "\n\n"; //value pointed to by pointer cout << "Adding 500 to score\n"; score += 500; cout << "score is: " << score << "\n"; cout << "*pScore is: " << *pScore << "\n\n"; cout << "Adding 500 to *pScore\n"; *pScore += 500; cout << "score is: " << score << "\n"; cout << "*pScore is: " << *pScore << "\n\n"; cout << "Assigning &newScore to pScore\n"; int newScore = 5000; pScore = &newScore; cout << "&newScore is: " << &newScore << "\n"; cout << "pScore is: " << pScore << "\n"; cout << "newScore is: " << newScore << "\n"; cout << "*pScore is: " << *pScore << "\n\n"; cout << "Assigning &str to pStr\n"; string str = "score"; string* pStr = &str; //pointer to string object cout << "str is: " << str << "\n"; cout << "*pStr is: " << *pStr << "\n"; cout << "(*pStr).size() is: " << (*pStr).size() << "\n"; cout << "pStr->size() is: " << pStr->size() << "\n"; return 0; }
// Mad-Lib // Creates a story based on user input #include <iostream> #include <string> using namespace std; string askText(string prompt); int askNumber(string prompt); void tellStory(string name, string noun, int number, string bodyPart, string verb); int main() { cout << "Welcome to Mad Lib.\n\n"; cout << "Answer the following questions to help create a new story.\n"; string name = askText("Please enter a name: "); string noun = askText("Please enter a plural noun: "); int number = askNumber("Please enter a number: "); string bodyPart = askText("Please enter a body part: "); string verb = askText("Please enter a verb: "); tellStory(name, noun, number, bodyPart, verb); return 0; } string askText(string prompt) { string text; cout << prompt; cin >> text; return text; } int askNumber(string prompt) { int num; cout << prompt; cin >> num; return num; } void tellStory(string name, string noun, int number, string bodyPart, string verb) { cout << "\nHere's your story:\n"; cout << "The famous explorer "; cout << name; cout << " had nearly given up a life-long quest to find\n"; cout << "The Lost City of "; cout << noun; cout << " when one day, the "; cout << noun; cout << " found the explorer.\n"; cout << "Surrounded by "; cout << number; cout << " " << noun; cout << ", a tear came to "; cout << name << "'s "; cout << bodyPart << ".\n"; cout << "After all this time, the quest was finally over. "; cout << "And then, the "; cout << noun << "\n"; cout << "promptly devoured "; cout << name << ". "; cout << "The moral of the story? Be careful what you "; cout << verb; cout << " for."; }
cin and cout are iostream objects, not keywords.
#include<iostream.h> #include<conio.h> void main() { clrscr(); int marks; cout<<"Enter Marks of Student="; cin>>marks; cout<<"Grade\n"; if(marks>0 && marks<50) cout<<"F"; else if(marks>=50 && marks<55) cout<<"C-"; else if(marks>=55 && marks<60) cout<<"C"; else if(marks>=60 && marks<65) cout<<"c+"; else of(marks>=65 && marks<69) cout<<"B-"; else if(marks>=69 && marks<71) cout<<"B"; else if(marks>=71 && marks<75) cout<<"B+"; else if(marks>=75 && marks<79) cout<<"B"; else if(marks>=79 && marks<84) cout<<"A"; else cout<<"A"; getch(); }
#include<iostream> int main() { std::cout << "Truth table for AND gate\n\n"; std::cout << " |0 1\n"; std::cout << "-+---\n"; for (unsigned a=0; a<2; ++a) { std::cout << a << '|'; for (unsigned b=0; b<2; ++b) { std::cout << (a & b) << ' '; } std::cout << '\n'; } std::cout << std::endl; }
The following example demonstrates all 4 loop structures in C++. #include<iostream> int main() { int i; std::cout<<"For loop...\n"<<std::endl; for(i=0; i<10; ++i) std::cout<<i; std::cout<<'\n'<<std::endl; std::cout<<"While loop...\n"<<std::endl; i=0; while(i<10) std::cout<<i++; std::cout<<'\n'<<std::endl; std::cout<<"Do-while loop...\n"<<std::endl; i=0; do { std::cout<<i; }while( ++i<10 ); std::cout<<'\n'<<std::endl; std::cout<<"Goto loop...\n"<<std::endl; i=0; again: std::cout<<i; if(++i<10) goto again; std::cout<<'\n'<<std::endl; } Output: For loop... 0123456789 While loop... 0123456789 Do-while loop... 0123456789 Goto loop... 0123456789
#include<iostream.h> void main() { cout<<' '<<' '<<"a"<<'\n'; cout<<' '<<"a"<<"b"<<"a"<<'\n'; cout<<'a'<<'b'<<'c'<<'b'<<'a'<<"\n"; }
#include<iostream> #include<conio.h> using namespace std; class conv { int x,b,r,arr[20],ch; public: void get() { cout<<"ENTER THE VALUE TO BE CONVERTED:(IN DECIMAL):"; cin>>x; cout<<"ENTER BASE TO WHICH U WANT TO CONVERT:(UP TO BASE 18):"; cin>>b; } void convert(); }; void conv :: convert() { int i=0,j; cout<<"-----------------CONVERSION PROGRAM------------------------\n"; while(1) { cout<<"-----------------------------------------------------------\n"; cout<<"1.CONVERT FROM DECIMAL TO OTHER\n2.QUIT\n"; cout<<"------------------------------------------------------------\n"; cout<<"ENTER UR CHOICE:"; cin>>ch; switch(ch) { case 1: get(); cout<<"IN BASE "<<b<<":"; while(x>0) { r=x%b; arr[i]=r; x=x/b; i++; } for(j=i-1;j>=0;j--) { if(arr[j]==10) cout<<"A"; else if(arr[j]==11) cout<<"B"; else if(arr[j]==12) cout<<"C"; else if(arr[j]==13) cout<<"D"; else if(arr[j]==14) cout<<"E"; else if(arr[j]==15) cout<<"F"; else if(arr[j]==16) cout<<"G"; else if(arr[j]==17) cout<<"H"; else if(arr[j]==18) cout<<"I"; else cout<<arr[j]; } cout<<"\n"; i=0; break; case 2: exit(0); default: cout<<"WRONG CHOICE\n"; } } } main() { conv obj; obj.convert(); getch(); return 0; }
#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; } } }
// Hero's Inventory 3.0 // Demonstrates iterators #include <iostream> #include <string> #include <vector> using namespace std; int main() { vector<string> inventory; inventory.push_back( "pac man"); inventory.push_back( "frogger"); inventory.push_back( "madden"); vector<string>::iterator myIterator; vector<string>::const_iterator iter; cout << "Your games:\n"; for (iter = inventory.begin(); iter != inventory.end(); ++iter) { cout << *iter << endl; } cout << "\nyou can trade a player for a player."; myIterator = inventory.begin(); *myIterator = "madden player"; cout << "\nYour games:\n"; for (iter = inventory.begin(); iter != inventory.end(); ++iter) { cout << *iter << endl; } cout << "\nThe item name '" << *myIterator << "' has "; cout << (*myIterator).size() << " letters in it.\n"; cout << "\nThe item name '" << *myIterator << "' has "; cout << myIterator->size() << " letters in it.\n"; cout << "\nyou capurted a ghost."; inventory.insert(inventory.begin(), "pac man"); cout << "\nYour games:\n"; for (iter = inventory.begin(); iter != inventory.end(); ++iter) { cout << *iter << endl; } cout << "\nremove game from list."; inventory.erase((inventory.begin() + 2)); cout << "\nYour games:\n"; for (iter = inventory.begin(); iter != inventory.end(); ++iter) { cout << *iter << endl; } cout << "\nyou just got beat in madden."; inventory.erase((inventory.begin() + 2)); cout << "\nYour games:\n"; for (iter = inventory.begin(); iter != inventory.end(); ++iter) { cout << *iter << endl; } return 0; }