Skip to main content

Posts

Showing posts from February 13, 2018

C++: Program to calculate and display area of a circle

C++: Program to calculate and display area of a circle #include <iostream> using namespace std; int main() {     float radius;     float area;     cout << "enter radius:";     cin >> radius;     area = radius * radius * 3.14;     cout << "area of the circle of is:" << area;     return 0; } Result -

C++ : squaring number in C++ script

C++ : squaring number in C++ script #include <iostream> #include <stdlib.h> using namespace std; int main() {   ("cls");    //For clearscreen funtion for Turbo C++ version clscr() also work     int var, sqrs;     cout << "enter varible:";     cin >> var;     sqrs = var * var;     cout << "\n" << "The square is :" << sqrs; return 0; } Result - https://code.sololearn.com/c45mw9pXGOUs/#cpp Use this script from here

C++ : Cascading of I/O Operators

C++ : Cascading of I/O Operators  Successive occurrence of operators (">>" or "<<" respectively) can be concatenated    example 1 - cout << "The sum of 2 + 5 = " << 2 +5 \n"; example 2 - cout >> "The result of 8 - 2 is" << 8 -2; example 3 - cout << "the sum of" <<  value1 << "and" << "is" << value 1 + value2 << "\n"; example 4 - Similarly successive occurrences of input operator (>>) can also be concatenated as follows :  cout << " Enter two numbers :"; cin >> value1 >> value2; Demo - ( squaring numbers) #include <iostream> using namespace std; int main() {     int var, sqrs; cout << "enter number:\n"; cin >> var; sqrs = var * var; cout << "\nanswers\n" << sqrs << endl; } Result - Without Cascading - ...