Posts

Image
Hello Everyone!Now we will discuss about the switch statement. It is a kind of Selective Flow statement that tests the equality of a variable or expression with a list of Values,also called cases ,and execute the cases which satisfies the condition till there is a break or end of switch statement.There can also be a default case which executes when no other case matches with the variable.For example:- int main() { int n; cout<<"Enter Your Marks in C++ out of 10="; cin>>n; switch(n) {  case 10:cout<<"Grade=O";break;  case 9:cout<<"Grade=A+";break;  case 8:cout<<"Grade=A";break;  case 7:cout<<"Grade=B+";break;  case 6:cout<<"Grade=B";break;  case 5:cout<<"Grade=C";break;  case 4:cout<<"Grade=D";break;  case 3:  case 2:  case 1:cout<<"Grade=F";break; default:cout<<"Absent"; } return 0; } In the above...
Image
Hello Everyone.Sorry for a Long Delay. By the way,Now we are going to discuss about Flow of control(of a program). Flow of Control is a way in which a program is compiled and executed.It can be a bunch of statements Within braces ending with a semicolon or it can be selective or repetitive. Sequential Flow is as mentioned above a bunch of statements ending with semicolon within braces.For Example:- int main() { statement1; statement2; return 0; } Selective Flow includes if-else and switch statements which verifies a condition/text expression in order to execute the statements enclosed under it.The usage of if-else and switch statements is Shown in the Example.Example:- int main() { int a,b,c; cin>>a>>b; cout<<"\n1.Maximum\n2.Minimum\nEnter your Choice="; cin>>c; switch(c)//verify Condition { case 1:if(a>b)//text expression-Condition               cout<<a;     ...
Hello everyone.Now we will discuss the relational operators. Relational Operators are generally used to define a test expression or a test condition.These are > , < , >= , <= , == , != . Note that == operator is used to check equality whereas = operator is used for assignment.There are also logical operators such as !,&& and || to negate a condition or to combine two conditions. A comma operators is used to combine several expressions together which get executed from left to right.It works as a punctuator. Ternery Operator/Conditional Operator-It is the replacement of simple Conditional operator.Its Syntax is as follows:- (condition)?True:False; Now coming to the Datatype conversions.These are of two types:- 1.Implicit 2.Explicit Implicit-In Implicit type conversion the compiler converts one data type to another automatically and it actually converts all the data upto the type of largest operand available in the expression & that is why implicit...
Hi! Today we will discuss Data type modifiers and Unary operators. Data type Modifiers- There are basically 4 datatype modifiers in C++-Signed,Unsigned,lond and short. As the name suggests, it modifies the basic datatypes and change their meaning to fit them in various situations precisely.All data types can be modified using datatype modifiers except void.For eg- unsigned int a;(It can store of positive integer which are not in range with normal integer datatype). The opposite is the function of signed int. Now long and short datatype modifiers change the amount of memory space given to a particular variable of that data type. for eg- long int will be given 4 bytes space in memory whereas int is of 2 bytes(in turbo c++). We can use these datatypes to make our program more precise which you will experience with time. There are Unary operators like -,++,-- in c++; ++ or -- operators are used to increment or decrement the value stored in a variable by one.These can be used be...
Image
Today we are going to discuss how to declare variables, what are cin,cout functions and we will also write a simple program to add two numbers and display it. The Syntax of declaring a variable is as follows- datatype vaiable name ; here,datatype can be int , float , char ,double ,  bool or void.(A variable of Bool datatype can store two possible values i.e. true or false,0 or 1,etc.).A variable name can be anything following the identifier's rules (discussed in previous posts).Every variable is associated with 2 values , r value and l value. r value is the datavalue and l value is the memory address of the variable. Example of variable declaration- float a; , int b; , etc. The variable declaration can be cascaded as follows if two or more variables have same datatypes. float a,b,c; Now,Coming towards the cin(console input) and cout(console output) operations. As the name suggests, cin (object of a class ifstream of iostream.h) and cout (object of a class ofstream o...