UNIT 2 2.3 Variables and Constant Declarations Flashcards

1
Q

These are identifiers which can be assigned a value within a program.
It has 32 valid characters, and these are letters, digits, and underscore

A

Variables

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Syntax:

for variable

A

Data-type ;

/* list of variables separated by commas.*/

Example
int x, y, z;
char a, b ;
double s;
float ave;
char Sname[30];
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

The process of assigning starting values to the variables It is important to remember that
variables are not initialized automatically

A

Variables initialization

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Several Ways to Initialize a Variables:

A
  1. By assigning an assignment statement (=)
    ex:
    x = -1;
    Chl = ‘A’;
  2. By using function scanf
    ex:
    scanf(“%d”, &x);
    scanf(“%lf”, &y) ;
3. By assigning values during declaration:
ex:
int x =3;
char y = ‘x’;
double a, b = 100.00;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Variables that are initialized only at the start of the program. All of these variables are
initialized to zero if no other initializer is specified.

A

Global Variables

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Variables that are initialized each time the function in which they are declared is
entered.

A

Local Variables

How well did you know this?
1
Not at all
2
3
4
5
Perfectly