Escolar Documentos
Profissional Documentos
Cultura Documentos
1) What is C language?
Ans:
C is a programming language developed at AT & Ts Bell Laboratories of USA in 1972.
The C programming language is a standardized programming language developed in the
early 1970s by Ken Thompson and Dennis Ritchie for use on the UNIX operating
system.
It has since spread to many other operating systems, and is one of the most widely used
programming languages.
2) What is an algorithm?
Ans: An algorithm is a step-by-step method of performing any task.
3) What is a flow chart?
Ans: A flowchart is a type of diagram that represents an algorithm or process, showing
the steps as boxes of various kinds, and their order by connecting these with arrows.
4) What is a C Preprocessor?
Ans: C Preprocessor is a program that processes our source program before it is passed to
the compiler.
5) What is the use of header files as used in C programming?
Ans: Header files are used to have declarations. It is simple to include a single header file
than writing allthe needed functions prototypes.
6) What is the Structure of a C Program?
Ans: Documentation Section, Linking Section, Definition Section, Global declaration
Section, main function, subprogram section.
7) Explain some Header Files?
Ans:
Header
S.No
Description
file
1
stdio.h
conio.h
string.h
stdlib.h
math.h
15) What is a Data Type and List the different Data types?
Ans: C data types are defined as the data storage format that a variable can store a data to
perform a specific operation.
List of Data Types:
1) Basic Data Types: Int, Float, Char, Double, long int
2) Enumeration Data Type: enum
3) Derived Data Type: Pointer, array, structure, union
4) Void Data Type: void
16) What is Integer Data Type?
Ans:
Integer data type allows a variable to store numeric values.
The storage size of int data type is 2 or 4 or 8 byte.
int (2 byte) can store values from -32,768 to +32,767
int (4 byte) can store values from -2,147,483,648 to +2,147,483,647.
S.No
C Data types
storage
Size
Range
char
127 to 127
int
32,767 to 32,767
float
double
long double
10
long int
2,147,483,647 to 2,147,483,647
short int
32,767 to 32,767
0 to 65,535
32,767 to 32,767
10
(2power(63) 1) to 2(power)63 1
11
2,147,483,647 to 2,147,483,647
12
0 to 4,294,967,295
13
Unsigned
long int
2(power)64 1
long
else
long
switch
break
enum
register
typedef
case
extern
return
union
char
float
short
unsigned
const
for
signed
void
continue
goto
sizeof
volatile
default
if
static
while
do
int
struct
_Packed
double
Prepared By: P. HARI SHANKAR
where
<case list>
is a sequence of
case <value>: <statement list>
break;
and optionally one
default: <statement list>
break;
52) What are Iterative or Looping Statements?
Ans: Iterative or Looping statement which executes the statements with in the compound
statement by checking the condition, and performs same set of statements as a iterative
process or as a loop until the condition false.
The Iterative or Looping Statements are: While, do-while, for
53) Write Syntax for WHILE Statement?
Ans: while ( <expression> )
<statement>
54) Write Syntax for DO- WHILE Statement?
Ans: do <statement>
while ( <expression> );
55) Write Syntax for FOR Statement?
Ans: for ( <Initialization>;<Condition>;<Increment/Decrement>)
<statement>
56) What is the difference between for loop and while loop?
Ans: For Loop is used to execute a set of statements in fixed number of times. We use
While loop when the number of iterations to be performed is not known in advance we
use while loop.
57) What are Unconditional Statements?
Ans: goto and labeled statements, break Statement continue Statement.
58) Define goto and labeled Statement, Write syntax for goto and labeled statements?
Ans: The goto statement transfers control to a label. The given label must reside in the
same function and can appear before only one statement in the same function.
Syntax:
goto <label>;
<label>: <Statement>;
S.No.
Storage
Specifier
Storage
place
Initial /
default
value
Scope
Life
auto
CPU
Memory
Garbage
value
local
Global
extern
CPU
memory
Zero
static
CPU
memory
Zero
local
register
Register
memory
Garbage
value
local
Array initialization
Accessing array
Syntax:
data_type
arr_name
[arr_size];
data_type
arr_name
[arr_size]=
(value1, value2, value3,.);
arr_name[index];
age[0];_/*0_is_accessed*/
age[1];_/*1_is_accessed*/
age[2];_/*2_is_accessed*/
char
str[10];
str[0];_/*H is accessed*/
str[1]; /*a is accessed*/
str[2]; /* i is accessed*/
72) What is the syntax for One Dimensional Array, explain declaration, Initialization,
accessing the elements?
Ans: Two dimensional array is nothing but array of array.
syntax : data_type array_name[num_of_rows][num_of_column]
S.no
Array declaration
Array initialization
Accessing array
Syntax:
data_type
arr_name
[num_of_rows][num_of_column];
data_type arr_name[2][2]
=
{{0,0},{0,1},{1,0},{1,1}};
arr_name[index];
Example:
int arr[2][2];
strcmp()
strncmp()
strcmpi()
strcpy()
strncpy()
strlen()
strchr()
Description
Syntax
strrchr()
strstr()
strrstr()
Strrev()
in str1.
last occurrence of given character in a
string is found
Returns pointer to first occurrence of str2
in str1.
Returns pointer to last occurrence of str2
in str1.
reverses the given string
Strrchr(str,charcater);
Strstr(str1,str2);
Strstr(str1,str2);
Strstr(str1);
C
function
aspects
syntax
function
definition
function call
function
declaration
C function
syntax
without
arguments
and
without
return values
void function();
function();
void function()
{statements;}
without
arguments
and
with
return values
int function ( );
// function declaration
function ( );
// function call
int function( )
// function definition
{statements; return a;}
// function declaration
// function call
// function definition
Function
abs ( )
Description
This function returns the absolute value of an integer. The
Prepared By: P. HARI SHANKAR
round.(.)
ceil ( )
sqrt ( )
pow ( )
trunc()