C Language Long Questions ( 31-35 )

31 Ques : How declare variable in C.

In C Language, it is mandatory to declare and define each and every variable before it can be used. A declaration associates a group of variables with a specific data type. A declaration consists of a data type, followed by one or more variable names, ending with a semicolon. So the general syntax of declaration of variable is:

type var1, var2, var3, ...,;

Here type is one of the data type (int, flaot, or char). var1, var2… are the names of variables, arrays functions separated by commas. e.g.

int a, b, sum;
float area, rad;
char ch;

Here is the first statement a, b and sum are the three variables declared as integer type. The second statement declares variables area and rad of type float. The third statement declares variable ch of type character.

32 Ques : How Declare variable as constant?

In some situations, we require some variables to remain constant during the execution of the program. This is possible using const modifiers that precedes the variable name at the time of declaration statement. Its general syntax is:

const type var = value;

Here const is a modifier which is used for make the value of the variable constant in the execution of the program. type is a variable name. value is constant that will be stored in var.

33 Ques : How Assigning Values to the Variables?

In C, the variable can be initialized i.e. assigned values at the same place where they are declared. e.g.

int sum = 0
float area = 0.0;
char ch = 'A';

This can also be achieved by declaring variables at the beginning of the program and assigning value to variables in the middle of the program also.

int sum;
float area;
char ch;
sum = 0;
area = 0.0;
ch = 'A';

34 Ques : What is the Symbolic Constant in C Language?

A symbolic constant is a name that substitutes a constant value for that name which cannot be changed. The character may represent a numeric constant, a character constant, or a string constant. When the program is compiled, each occurrence of a symbolic constant is replaced by its corresponding character sequence. They are usually defined at the beginning of the program. The symbolic constants may then appear later in the program in place of the numeric constants, character constant etc., that the symbolic constants represents. For Example:

#define PI 3.141539
#define TRUE 1
#define FALSE 0

When the program is preprocessed, all occurrences of the symbolic constant PI are replaced with the replacement text 3.141539.

35 Ques : What is Expression? And Rules for Forming Expression in C Language.

An Expression is any legal combination of symbols that represents a value. Each programming language and application has its own rules for what is legal and illegal. For example, in the C Language x+5 is an expression. Every expression consists of at least one operand and can have one or more operators. Operands are values, whereas operators are symbols that represent particular actions. In the expression,

x + 5
x and 5 are operands, and + is an operator 

Rules for Forming Expression

Rules for formation of an expression,

  1. A signed or unsigned constant or variable is an expression.
  2. An expression connected by an operator to a variable or constant is an expression.
  3. Two expressions connected by an operator is also an expression.
  4. Two operators should not occur in continuation.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top