C++ | Modify variable and replace its values | Lecture 2

Variable:

Variable is certain type of variable which is liable to vary and change for specific purpose and according to its range.

Types of Variable:

Modify Variable And Replace Its Value:

In Lecture 2 you will learn about variable modification and replacement.
Once you define a variable you can easily use that for print out your data. as
mynumber = 55;  
cout << "My Number is = " << mynumber << endl;  
If you are thinking about
endl
endl (End Line), It is used to break the line.
As you know, why do we use
system("pause");
So we can stop our function anywhere and anytime. 
If you define a variable and show its value.
Again you replace another value to this same variable and again show its value. So, now its value will be changed because you have replaced its value. C++ or any other language always prefer to latest value.
You can also use addition, multiply or any mathematics rules for variables but you need to see its type.
Variable type is very important to describe. Variable is defined according to its range.

 /*  
  Name: Replace variable and modify value  
  Copyright: QWC.Me  
  Author: Samee Ullah Feroz  
  Date: 26/01/14 23:31  
  Description: Replace variable and modify value  
 */  
 #include <iostream>  
 int main()  
   {  
    using namespace std;  
    int mynumber; //we daclare mynumber is as variable and its type is integer.  
      mynumber = 55;  
      cout << "My Number is = ";  
      cout << mynumber << endl << "Please enter to show new value\n";  
      system("pause");  
      //replace variable  
      mynumber = 32;  
      cout << "My Number is = ";  
      cout << mynumber << endl << "Please enter to check addition of both values\n";  
      system("pause");  
      //again replace with arthmatics values.  
      mynumber = 32 + 55;  
      cout << "My Numbers addition is = ";  
      cout << mynumber << endl;  
    system("pause");  
    return 0;  
   }  
You can ask me any question regarding this lecture to Wizpert.

Download Free Perfect Uninstaller

Post a Comment

Give your reviews about this blog. Leave your comments. What do you think about this post?

Comments Guidelines:

1) I love to read comments, but please avoid spam.

2) Like this blog, share your insights, and spread the word.

3) You can use basic HTML/xHTML tags.

4) All comments are DoFollow—please use the section professionally.

5) Kindly mention your name or brand below your comment.

6) Constructive suggestions for improvement are always welcome.


Thanks for visiting Samee Articles.

========================================

Best Regards,

Samee U. Feroz

 
Copyright © 2011-2026. Samee Articles - All Rights Reserved
Proudly powered by Blogger