0% found this document useful (0 votes)
25 views9 pages

Unit2 2marks

Uploaded by

mmalarkodi062
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views9 pages

Unit2 2marks

Uploaded by

mmalarkodi062
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Unit – 2

2 Marks:
1. Define problem solving & formulation.
⮚ Problem formulation is an iterative process that involves decomposition of analytic problem `
into appropriate dimensions such as structures, functions, and mission media.
⮚ In problem solving, it is important to understand what the problem & need to read the
problem statement in a number of times.
2. Write any four Escape sequence in c.
Execution character set are always represented by back slash followed by a character is called as
Escape sequence.
\n- new line
\b- Backspace
\0-Null
\v-Vertical tab
3. What are the features of C language?
⮚ C is a general purpose; structure programming language.It is a fast and efficient
⮚ It is a middle level language & Highly portable

4. Define with example integer & floating type of data in C language


⮚ Integer occupies 16 or 32 bits & the size can be limited up to [-32768 to +32767] eg. int
a=10;
⮚ The floating point numbers are generally stored in 32 bit with the six digits of precision. Eg
. float f=32.6;
5. Write a ruler for defining real constant.
⮚ A real constant must have one digit & decimal point.
⮚ It can be either positive or negative.
⮚ No commas or blank space are allowed.
6. Define preprocessor section?
It is used to link system library files, for defining the macros and for defining the conditional
inclusion. E.g.: #include<stdio.h>, #define A 10

7. What are the 4 types of source character set?


a) Alphabetics-A to Z and a to z
b) Decimal digits-0 to 9
c) White space-blank space,new line form feed. d) Special Characters- +,-,*,? Etc
8. Write the rules for naming the identifier.
a) Identifier consist of letters and digits in any order
b) The first character must be a letter/character or may begin with underscore( _ )
c) No space and special symbols are allowed between the identifiers
d) The identifiers cannot be a keyword.
9. Define data types and their types.
Data types is the type of the data, which are going to access within
the program. Types:
a) Primary
b) User defined
c) Derived
d) Empty

10. Define variables and Constants./ Difference between variables and Constants
⮚ A variable is an identifier that is used to represent some specified type of
information within a designed portion of the program.
⮚ The items whose values cannot be changed during the execution of program are called
constants.

11. List rules for defining variables in C

⮚ The first character must be an alphabet or an underscore.


⮚ No commas or black spaces are allowed with in a variable.
⮚ No special symbol or underscore can be used in a variable.
12. How to declare the variables.
Syntax: data_type v1,v2….,vn:
Description: data_type is a type of the data v1,v2,….vn are the list of variables
Example: int code; char sex; float price; char name[10];

13. Difference between local and global variable.


⮚ The variable which defines inside a function block is called local variable.
⮚ The variable which defines outside of a main function is called global variable.

14. Define identifiers?


⮚ Identifiers are names given to various program elements, such as Variables function
and arrays etc. Example: age, name, x, i.

15. Give an example for enumerated data type.


⮚ User defined data type is called as an enumerated data type that is programmer can create
their own data type and define what values the variables of this data types can hold. Eg.
enum color {red ,rose, green};

16. What are the types of user defined variables? Give their syntax.
a) Type Declaration:
Syntax:typedef data_type identifiers;
b) Enumerated data types:
Syntax: enum identifier {value1,value2,……valuen};

17. What is an operator & operand?


⮚ An operator is a symbol that specifies an operation to be performed on operands. E.g.
+,-,*,/ are arithmetic operators. The data items that operators act upon are called
operands. E.g. in a+b, a&b are called operands.
18. What are the types of operator?
a) Arithmetic operator
b) Relational operator
c) Logical operator
d) Assignment operator
e) Increment & decrement operator
f) Conditional operator
g) Bitwise operator
h) Special operator

19. What are the bitwise operator available in C?[JAN 2008]


& -Bitwise AND
| -Bitwise OR
>> -Right shift
<< -Left shift
^ -Bitwise XOR
~ - One’s complement

20. What is the difference between logical AND & Bitwise AND?
Logical AND(&&): Only used in conjunction with two expression, to test more than one condition.
If both condition are true their returns 1. If false then return 0.
Bitwise AND(&): Only used in bitwise manipulation. It is a unary operator.
21. List any four shorthand assignment operator.
+=
-=
*=
/=

22. What is the difference between ‘=’ & ‘==’ operator?


= is an assignment operator & = = is a relational operator.
E.g: while (i=5) is an infinite loop because it is a non zero value and the value of while (i= =5)
is true only when i=5.

23. Convert the following if statement into conditional expression using ternary operator
if(a>b)
big = a;
else big = b;

ANS: big = (a>b)? a : b;


24. Difference between relational & logical expressions.

Relational Expression Logical Expression


1. compares two operands 1. combine the results of two or more
operands
2. use relational operator such as 2. Use logical operators such as
<,>,>=,<=
&&,||,!
3. eg: a>b
3. eg: (a>b) && (b>10)

25. Give syntax for ternary operator


Syntax: condition? exp1:exp2;
Conditional or ternary operator itself checks the condition and executes the statements
depending on the condition.
? act as ternary operator.
It evaluates the condition if true then exp 1 is evaluated. If else then exp2 is
evaluated.
E.g.: main()
{
int a=5,b=3,big; big= (a>b)? a : b; printf(“Big is %d”,big);
}

26. State the meaning of the following keywords in C.


⮚ Auto: It is an automatic variable in which memory space is automatically
allotted for the declared variable.
⮚ Double: It uses 64 bit with 14 digits of precision
⮚ Integer: It occupies 16 or 32 bit and size of the integer is depends upon the
variable.
⮚ Long: It is used to increase the range of values.

27. Give the meaning of following function.


⮚ Floor(d)- Return a value rounded down to the next lower integer.
⮚ Fmod(d1,d2)- Return the remainder of d1/d2.
⮚ Pow(d1,d2)- Return d1 raised to d2 power.
⮚ Ceil(d)- Return a value rounded up to the next higher integer.
28. What are the types of I/O statements available in ‘C’?
There are two types of I/O statements available in ‘C’
a) Formatted I/O statements
b) Unformatted I/O statements

29. Difference between scanf() and gets() function?

sc gets()
anf()
In scanf() when there is a blank was gets() assumes the enter key as end.
typed, the scanf() assumes that it is an
end. gets() gets a new line(\n) terminated string of
characters from the keyboard and replaces the ‘\n’
with ‘\0’
30. Differentiate between getchar and scanf functions for reading strings.[MAY/JUNE2005]

getchar() scanf()
1. A single character can be given to the 1.Input data can be entered in to the
computer using ‘C’ input library function computer using the standard input ‘C’
getchar(). library function called scanf()

2. The function do not require any 2.scanf() function starts with a string
arguments, through a pair of empty argument and may contain additional
parantheses,through a pair of empty arguments.
paranthses, must follow the statement
getchar(). 3. It is formatted I/O statement
3. It is unformatted I/O statement

31. What are the categories of control structures?


1)Sequential structure
Instructions are executed in sequence
2)Selection structure
Sequence of the instructions are determined by using the result of the condition.
3)Encapsulation structure
Other compound structures are included.

32. What is scope of variable & list the two types of scope of variable?
Scope of variable implies the availability of variables with in a program.
Two types: Local variable
Global variable.

33. What is the significance of while statement in C. Give typical format of it.
⮚ It is a repetitive control structure used to execute the statements within the body
until the condition become false. It is also an entry controlled loop statement.
While(condition)
{
-- Body of the loop;---
}
34. Comparision between while & do while statements?
while Do-while
This is the top tested loop This is the bottom tested loop
Condition is 1st tested, if true block is Executed the body once, executes until the
executed until the condition becomes false condition becomes false.
Loop will not be executed if the condition is Al least once the loop is executed when if the
false. condition is false.

35. Write the syntax for loop?[UN Q]


for (initialize counter ; test condition ; increment/decrement)
{
----------
Body of the loop;
-----------
}

36.Compare switch case & nested if.


Switch case
 Tests only constant values
 No cases statement have identical constants in the same switch
 Character constant are automatically converted to integers
Nested loop
 The if can evaluate relational or logical expressions
 Same condition can be repeated any no of items
 Character constants are automatically converted to integers
 Switch() case can be used

37. Define break & continue statement with syntax?


⮚ Break statement is used to terminate the loop. Syntax: Break;
⮚ Continue is used to take the control to the beginning of the loop, by passing
the statements inside the loop which have not yet been executed. Syntax:
Continue;
38. Difference between break & continue?
Break:
1. Break statement takes the control to the outside of the loop
2. It is also used in switch statement
3. Always associated with if condition in loop
Continue:
1. Takes the control to the beginning of the loop.
2. Used only in loop statements
3. Associated with if condition.

UNIT IV(12 MARK Questions)

1. Explain the structure of ‘C’ program and explain with their example.
2. Define c tokens and explain with their types.
3. Explain various data types with examples.
4. What are the various types of operators supported by C? Describe each with a
suitable example.[JAN2006][JAN2005]
5. Differentiate between operator & operand. What are the various types of
operators.[MAY2005]
6. Explain in detail of
a) Formatted I/O statements
b) Unformatted I/O statements
7. Explain the control statements in detail.
8. Write a program to determine whether the given number is odd or even.
9. Explain
i) The while loop ii) Do
while loop
10. Explain i) For loop ii)Nesting of for loops
11. explain in detail about the loop structures in ‘C’?
12. Compare in terms of their functions while & do while loop with an example?
[UN Q]
13. Write a ‘C’ program to find the greatest of given 10
numbers?[UNQ]

You might also like