Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Ramapuram, Chennai.
Department of Computer Applications
UCA15102- Programming in C
Question Bank
Unit I
Part A 2 Marks
1. Define: Constants. Mention its types
The value assigned for the variable is called constant. It cannot change at
runtime. Ex: float pi = 3.14;
Numeric Constant – Integer Constant, Real Constant
Character Constant – Character Constant, String Constant
2. Define: Variables.
The memory location of the value is called variable. It can change at
runtime. Ex: int a;
3. Define: Keywords.
There are certain reserved words in C is called keywords, they have
standard, predefined meaning in C programming language. These keywords can
be used only for their intended purpose; they cannot be used as programmer
defined identifiers.
4. What is character set?
A set of symbols, digits and alphabets are called character set. By this
character set only, programmer can create a program. Ex: digits: 0 to 9, alphabets:
a – z (both lowercase and uppercase) and special symbols (&, $, #, @, etc).
5. What is symbolic constant?
A symbolic constant is a name that substitutes for a sequence of characters. The
character may represent a numeric, a character or a string constant.
Ex: # define TRUE 1
6. Write the I/O functions in C.
The scanf( ) and printf( ) are the basic I/O functions in C. The getchar(),
putchar(), gets(), and puts() are also the I/O functions.
7. What is an identifier?
1
Identifiers are names that are given to various program elements, such as
variables, functions and arrays. It consists of letters and digits, identifier
must start with alphabet. Special symbols are not allowed except
underscore( _ ).
8. Write the rules to define an identifier.
Identifiers must begin with letter.
It should not be a keyword.
Special symbols not allowed except underscore ( _ ).
9. What are the data types available in C?
int – integer quantity (2 bytes, it varies from one compiler to another)
float – floating point number (4 bytes)
double – double precision floating point number ( 8 bytes)
char – single character ( 1 byte)
Note: There is no special data type for string. The char type is used to
define a string.
10. List the rule for naming a variable in C.
2
13. How to declare a variable as constant.
3
A operator operates two operands is called Binary operator. Ex: a+b;
21. What are operators available in C.
Arithmetic operators ( +, -, *, /, % )
Relational operators ( <, <=, >, >=, ==, !=)
Logical operators ( &&, ||, !)
Assignment operators ( =, +=, -=, etc)
Bitwise operators ( &, | )
Special operator (conditional operator or Ternary operators) ? and :
22. Describe library functions.
The predefined functions or built-in functions are called library functions. It is
also called intrinsic functions. These functions are carried out various commonly
used operations or calculations.
23. What is the difference between ‘=’ and ‘==’ operator?
Where = is an assignment operator and == is a relational operator.
Example:
while (i=5) is an infinite loop because it is a non zero value and while (i==5) is
true only when i=5.
24. What is meant by Enumerated data type.
Enumerated data is a user defined data type in C language. Enumerated data type
variables can only assume values which have been previously declared.
Example :
enum month { jan = 1, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec };
25. What is type casting?
Type casting is the process of converting the value of an expression to a particular
data type.
Example:
int x,y;
c = (float) x/y; where a and y are defined as integers. Then the result of x/y is
converted into float.
26. What do you meant by conditional or ternary operator?
4
28. What are the types of I/O statements available in ‘C’?
There are two types of I/O statements available in ‘C’.
Formatted I/O Statements
Unit II
Part A 2 Marks
1. Define Looping in C .
5
A loop statement allows us to execute a statement or group of statements
multiple times and following is the general from of a loop statement in most of
the programming languages:
If While
(ii) If the condition is true, it executes (ii) Executes the statements within the
6
some statements. while block if the condition is true.
(iii) If the condition is false then it stops (iii) If the condition is false the control is
the execution the statements. transferred to the next statement of the loop.
7
else if(Condition2)
{
/* Control will come inside only when the above condition2 is true*/
}
else if(Condition3)
{
/* Control will come inside only when the above condition3 is true*/
}
else
{
/* Control will come inside only when the above condition is true*/
}
9. What is the use of goto statement?
The goto statement is used to alter the normal sequence of program execution by
transferring control to some other part of the program. Syntax: goto label;
10. Compare Break and Continue statements
Break Continue
This statement is used to terminate This statement is used to bypass the
loops or to exit from a switch. remainder of the current pass through a
loop. The loop does not terminate when
a continue statement is encountered.
It can be used within a for, while, do- It can be used within a for, while, do-
while or switch statement. while loop statements.
Syntax: break; Syntax: continue;
8
3. Discuss about conditional statements with example.
4. With suitable program, explain about switch case.