How to write a program of dynamic value of a global variable using an equation for adding two variables?
How to use the dynamic value of a global variable?
What is the global variable in the program?
Global variable
The global variable is a type of variable that is declared over the body of the program and declared after the data type. The global variable takes the value for input in all over the program.
How to use the dynamic value of a global variable?
Why is the variable value dynamic in global variables?
The dynamic value continuously changes when you compile or run the program again and again. It cannot take the previous value of the variable you decided or entered first. The value you are using at a time is temporary value during output screen of the program such as “a=34” and “b=45” are the value using at a time and calculated by the according to the equation which is given in the program or you had declared in the program is printed in the “c=79” variable.
Image reference of the program of dynamic value of variable using an equation for adding two variables are shown above
In the program you see the two header files “<stdio.h>” and “<conio.h>” can be used for standard input/output and console input/output respectively. In the comment section in the image are mentioned above.
Then after declaring the header files there is void main () used for bulk value return from the variable.
In the next line you can see the curly braces which are also “braces” in the program. Here you can see there is an open curly brace for opening the main body of the program.
In the next line you can see that clrscr() was used in the program to clear the screen of output of the program. It clears the previous output result from the screen when you again run the program.
Then declare the data type integer with variable a, b, c. Then store the values in “a” and “b” and declare the equation to calculate the variable values. In the next line print the value in “c” from the sum of the value of two variables “a” and “b” and get the character to the output screen using “getch()”.
Output image reference of the program of dynamic variable values using equation of adding two variables
Here is the output image of the program. You can see the statements which you have declared in the program and enter their values of “a” and “b” and output has come from calculation by the equation printed in the “c” variable in the program.
No comments:
Post a Comment