Computer Notes ICS Part 2 Chapter 9
Elements of C Short Questions
Q 1. What is an identifier?
Ans. In a program the names that are used to represent variables, constants,
types, functions and labels are called identifiers. We can use any number of
characters as identifiers but the first 31 are significant to C compiler.
Q 2. What is user defined identifier?
Ans. User defined identifiers are the names assigned by the programmer to
functions, data types, variables etc. in a program. For example, age, r no can
be user defined identifier in a program.
Q 3. What is standard identifier?
Ans. The
identifier that have a special meaning in C language are called standard
identifiers. These identifiers can be redefined. But this is not recommended.
If we redefine a standard identifier in a program C compiler cannot use it for
its original purpose. For example, printf and scanf are standard identifiers.
Q 4. What is a keyword?
Ans. The words that have predefined meanings and purpose in C language are
called keywords of C language. These are also called reserved words. The
purpose of keywords is predefined. They cannot be used for any other purpose in
C language programs. All keywords are written in lower case. Keywords cannot be
used as identifiers. In C language 32 words are defined as keywords.
Q 5. What is a variable?
Ans. Computer programs are developed to solve different problems. In these
problems, different types of data is used as input. Programs process data and
generate output. The data given as input is stored in the main memory for
processing. After processing the results are also stored in main memory. Main
memory is a collection of bytes. These bytes are also called memory locations.
So " The named memory locations used to store input data and result,
during the execution of the program is called variable".
Q 6. What is a constant?
Ans. The quantity whose value cannot be changed during the execution of the
program is called constant. Constants can be declared like variable. To declare
a constant 'const' keyword is used. For example,
·
const int x = 10;
Q 7. What is meant by variable declaration?
Ans. Specifying variable name and the type of data it can contain is called
variable declaration. C is a strongly typed language. In C language, a variable
must be declared before it is used to store data. If we use a variable without
declaration compiler will generate an error at compile time.
Q 8. What is variable initialization?
Ans. Storing a value in variable at declaration time, is called
initialization. When we declare a variable, some memory is allocated to it, per
its type. This memory already contains some data. This meaningless is called
garbage. If we use variable without assigning a value, the result will not be
correct. We should initialize a variable before using it.
Q 9. What is meant by typed language?
Ans. Specifying variable name and the type of data it can contain is called
variable declaration. C is a strongly typed language. In C language, a variable
must be declared before it is used to store data. If we use a variable without
declaration compiler will generate an error at compile time.
Q 10. What are different types of constants?
Ans. The quantity whose value cannot be changed during the execution of
program is called a constant. Constant can be declared like variable. To
declare a constant 'const' keyword is used. There are two types of constants in
C language.
·
Numeric constants
·
Character constants
Q 11. What is meant by data type?
Ans. Computer programs are used to solve different types of problems with
computer. Computer program take data as input, process it and produce results
in the form of output. Computer program can process different types of data.
Data type is defined as the set of values and a set of operations allowed on
those values. It also tells us about the memory required to store that data.
Q 12. What is meant by standard data type?
Ans. Data
types that are defined as the part of the language are called standard data
types. For example, int, char, etc. are standard data type in C language.
Q 13. What is meant by user defined data
type?
Ans. In addition to standard data types user can define its own data type.
These data types are known as user defined data types. Standard data types can
be used in all C language program but user defined data type can only be used
in a program in which it is defined.
Q 14. Which data types can be used to store
integer data?
Ans. Data
types for Integers
·
int
·
short int
·
long int
·
unsigned int
·
unsigned long int
Q 15. Which data types can be used to store
floating-point data?
Ans. Data types for Real Numbers
·
float
·
double
·
long double
Q 16. What is cancellation error?
Ans. Cancellation
error occurs when an arithmetic operation is performed between very large and a
very small floating point number. Due to this error computer produces
unexpected results. If a large number and a small number are added the large
number may cancel out the small number. For example, if we add 1872.0 and
0.0000000005747 the result may be 1872.00000.
Q 17. What is meant by underflow?
Ans. When a value is stored in a variable that is less than its minimum
range, that value cannot be stored in it properly. An error occurs. This error is
called underflow error. For example, if we store a number less than -32768 in
an int type variable an underflow error will occur.
Q 18. What is meant by overflow?
Ans. When a value is stored in a variable that is greater than its maximum
range, that value cannot be stored in it properly. An error occurs. This error
is called overflow error. For example, if we store a number greater than 32767
in an int type variable an underflow error will occur.
Q 19. What is character data type?
Ans. To store a character data type chat is used. char type variable use one
byte in memory. Character values are enclosed in single quotes in C language
for example '?', 'a'. When we store a character in char type variable, ASCII
value of that character is stored in it. ASCII stands for American Standard
Code for Information Interchange. In this code, each character is assigned a
unique numeric value that value is called ASCII code for that character.
Q 20. How are characters stored?
Ans. When we store a character in char type variable, ASCII value of that
character is stored in it. ASCII stands for American Standard Code for
Information Interchange. In this code, each character is assigned a unique
numeric value that value is called ASCII code for that character. For example,
ASCII code of 'A' is 65 and 'B' is 66. As char type variable contain numeric
ASCII code, arithmetic operation can be performed on them.
Q 21. What is an operator?
Ans. In computer programs, we perform different types of operations on data.
Operators are symbols that are used to perform different operation on data.
There are different types of operators in C language. For example, + symbol is
used to add two numeric values written on both sides.
Q 22. What are different types of operators?
Ans. Different types of operator available in C language are
·
Arithmetic operator
·
Relational operator
·
Logical operator
·
Increment and Decrement operator
·
Assignment operator
Q 23. What is an arithmetic operator?
Ans. The operator that are used to perform arithmetic operation on numeric
data are called arithmetic operators. These operations can operate on numeric
variable or constants.
Q 24. What is an assignment operator?
Ans. The symbol = is called assignment operator. It is used to store a value
of a result of an expression in a variable.
Q 25. What is an assignment statement?
Ans. A
C language statement in which assignment operator is used is called assignment
statement. The general form of an assignment statement is
·
variable = expression.
It is used to assign a value or result of an
expression to a variable. The name of variable is always written on the left
side of assignment operator. The value or expression is always written on the
right side of assignment operator.
Q 26. What is compound assignment?
Ans. An
assignment statement that is used to assign one value to more than one variable
is called compound statement. The assignment operator = is used more than once
in this statement. For example,
·
A = B = 10;
In above statement a value 10 is assigned to both
variables A and B.
Q 27. What is compound assignment operator?
Ans. A combination of assignment operator with arithmetic operator is called
compound assignment operator. These are also used to perform arithmetic
operations. For example, +=. -=, *=, /=, %= are compound assignment operator.
Q 28. What is increment operator?
Ans. A
double plus (++) sign is called increment operator. It is a unary operator. It
is used to add 1 to the current value of a variable. It cannot be used with a
constant or an expression. It can be used before or after the variable. For
example,
x++ and ++x are valid but 14++ is not valid.
Q 29. What is decrement operator?
Ans. A double minus (--) sign is called decrement operator. It is a unary
operator. It is used to subtract one from the current value of a variable. It
cannot be used with a constant or an expression. It can be used before or after
the variable name. For example,
x-- and --x are valid but 14-- is not valid.
Q 30. What is relational expression?
Ans. A
combination of relational operators and operands is called relational
expression. The operands
may be constants or variables. Operands should
be of same type. After evaluation, a relational expression generates True or
False.
Q 31. What are logical operators?
Ans. The symbols used in compound expression are called logical operators.
AND, OR and NOT are logical operators available in C language.
Q 32. What is logical expression?
Ans. A combination of relational expression and logical operators is called a
logical expression. It is used for calculation. Its evaluation gives a single
numeric value.
Q 33. What is AND operator?
Ans. If
the relational expression on both sides of AND generates true, the final result
is true. It is represented by && symbol.
Q 34. What is OR operator?
Ans. If any of the relational expression on both sides of OR generates true,
the result is true. It is represented by || symbol.
Q 35. What is NOT operator?
Ans. It
is used to convert true to false and false to true. It is represented by ! symbol.
Q 36. What is meant by operator precedence?
Ans. The
order in which different types of operators in an expression are evaluated is
called order of precedence of operator. It is also called hierarchy of
operator’s different types of operators has different precedence level. The
operators having high precedence are evaluated first.
Q 37. What is an expression?
Ans. A combination of operators and operands is called expression. Expression
are used to calculate the values of formulas. The evaluation of an expression
gives a single value. The operands of an expression may be constants or
variable. For example, a + b, a + 5, and 5 + 6 are all expressions.
Q 38. What are comments?
Ans. In
C language program the lines written between /* and */ are considered as
comments. The compiler ignores these lines. These are used to add remarks in
the program.
Comments are also used to explain the logic of
the program. Comments are used to increase the readability of the program.
Comments can be added anywhere in the program.
Q 39. What is a single line comment?
Ans. In
C language program the lines written between /* and */ are considered as
comments. The compiler ignores these lines. These are non-executable
statements. These are used to add remarks in the program. If a comment consists
of one line it is called single line comment. Single line comment can be made
using // it has no ending it consists of only one line.
Q 40. What is multi line comment?
Ans. In
C language program the lines written between /* and */ are considered as
comments. The compiler ignores these lines. These are non-executable
statements. These are used to add remarks in the program. If a comment consists
of more than one line, then it is called multi line comment.
Q 41. What is prefix increment?
Ans. If
increment operator is written before the variable name, then it is called
prefix increment operator. For example, ++x. In this case of prefix
increment the value of variable is incremented by one and then it is used.
Q 42. What is postfix increment?
Ans. If increment operator is written after the variable name, then it is
called postfix increment operator. For example, x++. In this case of
postfix increment first the value of variable is used then incremented by 1.
Q 43. What is prefix decrement?
Ans. If decrement operator is written before the variable name then it is
called prefix decrement operator. For example --x. In this case of prefix
decrement first the value of variable is decremented by one and
then it is used.
Q 44. What is postfix decrement?
Ans. If decrement operator is written after the variable name then
it is called postfix decrement operator. For example x--. In
this case of postfix decrement first the value of variable is used
then decremented by 1.