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...
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...
Comments
Post a Comment