What is the pseudocode, variable, and scope of the variable?
Que. What is pseudocode. Give its advantage and disadvantages.
Ans. Pseudocode is detailed yet readable description of what a computer program or algorithm must do , expressed in a formally styled natural language rather then in programming language.
It is used for creating an outline or a rough draft of a program . It summarizes the program’s flow but excludes underlying details.
Advantage of pseudocode:
a. Converting a pseudocode to a programming language is much easier.
b.It is easier to modify the pseudocode of program logic when program modification are necessary.
c.Pseudocode is easier to write because it has only a few rules to follow , allowing a programmer to concentrate on the logic of program.
Disadvantage of pseudocode:
a. A graphic representation of a program logic is not available.
b. Communication problem occurs due to lack of standardization.
c. For a beginner , it is more difficult to follow the logic of pseudocode or write pseudocode as compared to flowchart .
Que. What is variable?
Ans. A variable is a name to given a storage area that our programs can manipulate.
-Each variable in C language has a specific type which determine the size and layout of the variable’s memory ; the range of values that can be stored within the memory; and the set of operation that can be applied to a variable.
-The name of variable can be composed of the letter , digit, and the underscore character.
-It must begin with either a letter or an underscore . Upper and lowercase letter are distinct because C language is case-sensitive.
-A variable in C language must be given a type , which defines what type of data the variable will hold. It can be:
Que. What do you mean by scope of variable?
Ans. Scope determines the region of the program in which a defined object visible , i.e, the part of the program in which we can use the object’s name.
Types of variables:
1.local variable: The scope of local to block in which variable is defined . The life of local variable is till the control remains within the block in which variable is defined .
2. Global variable: The scope of global variable is global i.e., if a variable is declared outside , it is available to all functions that want to use it. The life of global variable remains as long as the programs execution does not come to end.
3.Static variable: The scope of static variable is local to the block in which the variable is defined . The life of static variable i.e., value of the variable persists between different function calls.