What is the difference between identifier and keyword? Explain with example.
The difference between identifier and keyword is given below:
(a) Identifiers are names that are given to various program elements, such as variables, functions and arrays.There are certain reserved words called keyword.(b) Both upper and lowercase letters are used in identifiers.(c) Underscore character is used as a letter in identifiers.Underscore character can not used in keywords.(d) Example of Identifier: y12, names, sum_1 etc.Example of Keywords: auto, break, double etc.
What are the main four data types in C?
The main four data types in C are give below:
a) integer quantity (2 bytes)b) single Character (1 bytes)c) floating point number (4 bytes)d) double precision (8 bytes)
What are the difference between integer and floating point data types? Explain with example.
Integer and Floating-point data are variables to be used in a program. Variables are space in a memory where we can store data. Integer (represented by int) and Floating-point data (by float) both represent numbers. They differ only in the type and length of number that they represent. The difference between integer and floating point data types are given below:
(a) An integer constant is an integer valued number.
A floating point constant is a base 10 number.
(b) Integers can be represented in long and short. It differs in the length of the data it stores. Here, int will stores integer number (number that does not have decimals on it) in the range of -2,147,483,648 to 2,147,483,648 in long signed int (by default) or 0 to 4,294,967,295 in long unsigned int. In short signed int from -32,768 to 32,767 and in short unsigned int 0 to 65,535.
While float will stores decimal numbers with the range quite similar to long int.
(c) Decimal point or an exponent is not used in integer constant.
Decimal point or an exponent is used in floating point constant.
What is the memory requirement of long, long long, short int and char data type in gcc/g++?
The memory requirement of long, long long, short int and char data type in gcc/g++ is:
long | 4 byte |
long long | 8 byte |
short int | 2 byte |
Char | 1 byte |
A floating point constant can be written in many different ways in C. Write the value 3.14159265359 in four possible ways.
The value 3.14159265359 in four possible ways is written below:
a) 3.14159265359
b) 0.314159265359e+01
c) 0.314159265359E+01
d) 314.159265359E-02
e) 314.159265359e-02
What are the basic types of constants in C?
There are four basic types of constants in C and they are:
a) integer constants (represent number)
b) floating point constants (represent number)
c) character constants
d) string constants
What are the rules apply to all numeric type constant?
Commas and blank spaces cannot be included within the constant.
The constant can be preceded by minus sign if desired.
The value of a constant cannot exceed specified minimum and maximum bounds. For each type of constant, these bounds will vary from one C compiler to another.
What is integer constant? give some example.
An integer constant is an integer-valued number. Thus it consists of a sequence of digits. Integer constants can be written in three different number system that are give below:
a) decimal (base 10)b) octal (base 8)c) hexadecimal (base 16)
Example: Several valid decimal integer constants are shown below:
0 1 743 5280 32767 9999
Several valid octal integer constants are shown below:
0 01 0743 0777777
Several valid hexadecimal integer constants are shown below:
0x 0x1 0X7FFF 0xabcd
What is escape sequence? Give some example.
Certain nonprinting characters, as well as backslash ( \ ) and the apostrophe( ‘ ), can be expressed in terms of escape sequence. An escape sequence always begins with a backward slash and is followed by one or more special characters.
Example: A line feed(LF), which is referred to as an newline in C, can be represented as \n. Such escape sequence always represent single characters, even though they are written in terms of two or more characters.
What is declaration? What are the characteristics of declaration? Give some example.
A declaration associates a group of variables with a specific data types. All variables must be declared before they can appear in executable statement.
Characteristics of declaration: A declaration consists of a data type, followed by one or more variable names, ending with a semicolon.
Example: A C program contains the following type of declarations.
int a,b,c;float root1,root2;char flag,text[80];
Thus a, b and c declared to be integer variables, root1 and root2 are floating point variables, flag is a char-type variables and text is an 80-element, char-type array.
What is statement? How many statement in C?
A statement causes the computer to carry out some action.
There are three different classes of statements in C and they are:
i. expression statements
ii. compound statements
iii. control statements