Primary If Statement in C++ Decision Making: The if statement is used to execute some code if a condition is true. Syntax: if(condition) { //statements } The condition specifies which expression is to be evaluated. If the condition is true,the statements in curly brackets are executed. If statement: Use relational operators to evaluate conditions. For...
Primary Assignment Operators and Increment Operator of C++ Assignment Operator: The simple assignment operator (=) assigns the right side to left side. C++ provides shorthand operators that have the capability of performing an operation and an assignment at the same time. For example: int x=5; x+=3; //It's mean x=x+3 x-=2; //It'...
Primary Basic Arithmetic of C++ Arithmetic Operators: C++ supports these arithmetic operator. Operator Symbol Form Addition + x+y Subtraction - x-y Multiplication * x*y Division / x/y Modulus % x%y Addition: The addition operator adds its operands together. int x=2+3; cout<<x; Output: 5 Subtraction: The subtraction operator subtracts o...
Primary How to take input by user in C++ User input: To enable the user to to input a value,use cin in combination with the extraction operator (>>). The variable containing the extracted data follows the operator. The following example shows how to accept user input and store it in the num variables. For example: int num;...
Primary Basic programs of C++ Write a program in C++ to print a massage on output screen. #include<iostream> using namespace std; int main() { cout<<"Hello world"; return 0; } Output: Hello world -------------------------------------------------------------------------------- Write a program in C++ to print an integer value. #include<iostream> using namespace...
Primary Variables declaration in C++ Creating a variable reserves a memory location, or a space in memory for storing values. The compiler requires that you provide a data type for each variable you declare. Here some point to remember - * C++ offer a rich assortment of built-in as well as user defined data types. * Integer,...
Primary Comments line in C++ Comments are explanatory statements that you can include in C++ code to explain what the code is doing. The compiler ignores everything that appears in the comment,so none of that information shows in the result. Single-Line Comments: Comments that require lines begin with //. You can place them on the...
Primary How to break a output line in C++ The cout operator does not insert a line break at the end of the output. One way to print two lines is to use the endl manipulator, which will put in a line break. For examle: #include<iostream.h> using namespace std; int main() { cout<<"...
Primary Introduction to C++ C++ is a statically typed,general purpose programming language. C++ was derived C, band is largely based on it. Note: A programming language is said to used static typing when type checking is performed during compile-time as opposed to run time. Standard Libraries Standard C++ has three important components * Core...