Q. What is statement? How many types of statements in C ?
Ans. :- A statement
is a command given to computer to perform specific operation. A program is the
set of statements.
There are
six types of statements in C, Given Below :-
1. Labeled Statements :- A statement can be preceded by a label. There are 3 types of label in
C.
Followed by Colon (:) this label is the target of goto statement.
case & default Statements use with switch.
2. Compound Statements :- Compound statement is a set of multiple statements into a single
statement, declared within { } .
3. Expression Statements :- A statement consist of an optional expression followed by a semicolon
(;). If the expression is present ,
the statement may have a value, if no expression is present , the statement is often
called the null statement, puts()
function calls expressions.
4. Selection Statements :- When we have to choose any one statement among more statements then
selection statements are use. There are 3 ways to use select statements.
I.
If() statement
II.
If() else
statements
III.
Switch-case statements
5. Iteration Statements :- When we need to repeat the statement again and again then we have to
use iteration statements. There are three types of iteration statements.
I.
For()
II.
While()
III.
Do-while()
6. Jump Statements.
There are four types of jump statements.
I.
goto
II.
break
III.
continue
IV.
return
Q. Define the data types there size, range in C.
Ans :- Data type defines the type of value we are going to store in variable. Data type is also use in function declaration and definition which decide the type of value return by function when function execute. We always have to decide the data type before declaring the variable and function. A data type specify the ‘type of value’ and ‘size of memory’ taken by variable. Each data type has a fix size and range.
Ans :- Data type defines the type of value we are going to store in variable. Data type is also use in function declaration and definition which decide the type of value return by function when function execute. We always have to decide the data type before declaring the variable and function. A data type specify the ‘type of value’ and ‘size of memory’ taken by variable. Each data type has a fix size and range.
In C we can classified
the data types in 4 categories:-
1. Basic Types :- These are basic types
data type e.g. int , float,char double
2. Enumerated Type :- These are also
arithmetic types and they are used to define variables that can only assign
certain discrete integer values used in the program. e.g. enum
3. Void Type:- it is null type data
type, it indicate that no value is available.
4. Derived Type:- Derived types data types includes (a) Array
(b)Pointer (c) Structure (d) Union (e)Function Types.
The table given below show you the data type
name, size and range.
Data Type
|
Size
|
Range
|
Format specifier
|
Char
|
1 byte
|
-128 to 127
|
%c
|
Unsigned char
|
1 byte
|
0 to 255
|
%c
|
Signed char
|
1 byte
|
-128 to 127
|
%c
|
Int
|
2 bytes
|
-32768 to 32767
|
%d
|
Unsigned int
|
2 bytes
|
0 to 65535
|
%u
|
Signed int
|
2 bytes
|
-32768 to 32767
|
%d
|
Signed short int
|
2 bytes
|
-32768 to 32767
|
%hi
|
Short int
|
2 bytes
|
-32768 to 32767
|
%hi
|
Unsigned short int
|
2 bytes
|
0 to 65535
|
%hu
|
Long int
|
4 bytes
|
-2147483648 to 2147483647
|
%li
|
Unsigned Long long int
|
4 bytes
|
0 to 4294967295
|
%llu
|
Float
|
4 bytes
|
1.2E-38 to 3.4E+38
|
%f
|
Double
|
8 bytes
|
2.3E-308 to 1.7E+308
|
%lf
|
Long double
|
10 bytes
|
3.4E-4932 to 1.1E+4932
|
%Lf
|
There are
five data type modifier in c.
1. Short
2. Long
3. Signed
4. Unsigned
5. Long long
Q. Explain the data type modifiers in C.
Ans:- C provide the data modifier facility to programmer to build there program
as per the requirement. C give us 5 data type modifier to modify data types
list is given below:-
1. Signed :- By default all data types
in C is ‘signed’. A signed variable can store both ‘-ve’ and ‘+ve’ values. For e.g. if we want to store temperature.
2. Unsigned :- unsigned data types only
store the ‘+ve’ values. If we required to store only positive values then
unsigned is best choice to store more data range in less memory. For e.g. if we
want to store salary
3. Long :- if we want to increase the
store capacity of a variable then we use the ‘long ‘. For e.g. if want to
calculate annual turnover .
4. Short :- it work opposite of ‘long’ . if we want to
store the small value in variable then programmer use the ‘short’ modifier. For
e.g. if want to store age of employee then we can use e.g. short int age;
5. Long long :- if we want to increase
the storage capacity and range of variable then we can use long long modifier. E.g.
long long int turnover
Q. Explain the Operators in C.
Ans :- Operator is a symbol use for to perform some specific (mathematical or logical) operation on to operands (Variables) for e.g.
Q. Explain the Operators in C.
Ans :- Operator is a symbol use for to perform some specific (mathematical or logical) operation on to operands (Variables) for e.g.
C=a+b;
Operator :- =,+
Operands :- c,a,b
Types of
operators in C is given below:-
Operator Name
|
Operator Symbol
|
Arithmetical Operators
|
+,-,/,*,%
|
Relational Operators
|
==,!=,>,<,>=,<=
|
Logical Operators
|
&&,||,!
|
Bitwise Operators
|
&,|,^,~,<<,>>
|
Assignment Operators
|
=
|
Conditional Operator
|
?:
|
Assignment Operator
|
=
|
Special Operator
|
Sizeof(), ,&,*
|
Increment Operator
|
++
|
Decrement Operator
|
--
|
superb sir ji
ReplyDelete