We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 14
Mopute}
1. Define Tokens
Ina passage of text individual words and pun
smallest individual units are known as C tokens M2
Keywords, Identifiers, Constants, Strings, specie! 5Y™
2. Give two example of token?
Keywords -int float etc
Identifiers — sum,ang etc
3. Write two examples of keyword?
Int, float, char
4 What is an algorithm?
Any description of the logical sequence of oPé
particular problem in a non programming anguaEe scaled 2180
5. Explain the advantages of flowchart?
ctation marks are called tokens . In Clanguage
1 6 types of tokens
pols and Operators.
erations that must be carried out for solving 2
ith,
+ Easy to make
* Communication becomes effective and understandable
‘Mistakes can be easily understood
* Logics can be easily interpreted
+ Analysis becomes easy
6. Explain the process involved in design and development of a program?
Problem definition, problem analysis, Algorithm development, Coding and Documentation,
Testing and debugging and Maintenance
7. What is an operator?
‘An operator is a symbol that tells the computer to perform certain mathematical or
logical manipulations.
Fg: +>, &&etc.
8. Whats a fundamental data type?
Very basic data type is known as fundamental sta type, Eg: nt, float, char
9, What is derived data type ?
erived datatypes ae defined by the USF Me. Eg arays, pointers, structure eG
10, What are the type modifiers of fundamental datatypes?
Short long,signed.unsigned
11, What is typedef and enum ? 3
Typedef means ‘t 1Ow users to define an i that would represent
‘an existing data type. EB: typedef int units ~ units can be 2 oo
aon means enumerated d0ta1YPE NCCE be ued o declare variables that ca a¥E
‘one of the values enclosed within 1M PTC's known 4s enumeration constants
fe: enum day (Monday, Tuesd@Yi~=S43)
12, Structure of C program?
y that26. What is a unary operator ?
Operator which acts on one operand Ep. igecrement operator m++, m—-
27, tplln character sey? remneeet
‘The characters that can be used numbers and expressions depends upon the
computer on which the prowram sg Mer acters iC a8 BFOUDES into the following
categories Letters, Digits, Special Characters, white sP2CeS
28. What is variable? i
Avariable's a data name that may be ugeg to store 4at@ value in random access memory.
Unlike constants that remain unchanged during the execution of a program , a variable
may take different values at different times during execution. FB: sum, n ete,
29, What is preprocessor statement?
Preprocessor directives such as Wdefine tell the compile to Preprocessor the source code before
compiling.
30. What is HLL ?
High level languages are 3" generation languages which are easier, user friendly and portable
‘and resembles English . Eg: C, C++
31. What isthe use of include statement 2
The include directive tells the C preprocessor to include the contents of the file specified . Eg”
include will include standard input output file to the program.
32. What is source and object program?
Source Program_ -collection of computer instructions written using a human readable
programming language .
biect Program — isthe sequence of statements in machine language and is the output after the
translators or assemblers converts source code
33. What are the different types of errors that may appear in a program?
Logical Errors — caused by programmer entering faulty programs . The error will be in logic of the
program hence result will contain the mistake .
Eg: Not
Putting semicolon at the end of a print statement or using different spelling at declaration and
‘body. 7
‘Semantic Errors — errors caused by improper use of program statements. Eg: Putting semicolon
‘at the end of for statement or not using & symbol in scanf etc.
34, What are the methods to add comment in a program ?
‘Comment in a C program is not an executable statement. It is only used to give information
relevant to the program like Prog '¢, Author, Date etc. There are two ways to give
‘comments in program =
J/ -to give single line comment
P25]. se's nthe a 0 Bive multiple line comment
35. What isa literal ?
Literals are the constant values: mot be modtieg
36. Whats a null character ? ‘
37. What is new line character ?
“\n" is used to jump to the nextDrocess Is done by Counting. The galecton and repetitive structure together known as contro}
structures. =
‘56. What is the use of contr
It is used to control ean ot «3 program. Control flow statements in C are
Branching and Looping statements switch while d0-white fon
‘57. What are the two types of control flow statements in C?
Branchinglselection statements} rons of aerate steps of actions which are to be
selected and executed based upon certain decisions oF conditions.(if and switch )
Looping{iterative statements ). Computer <2” Perform millions of calculations repeatedly.
This structure repeats a set of statemests over and over while a certain condition is met. This
process is done by counting.(while, do. while, fF)
'58, What is unconditional branching ?
When the programmer forces the execution of # program to jump to another part of the
program. Eg: Goto statement inc
‘59. What is looping ?
‘loop statement is a series of steps or sequence of statements executed repeatedly zero or
‘more times satisfying the given condition. (while, do.while, for)
60. Name the different branching statements used in C program ?
‘Simple if, if...else, nested if, else if ladder , switch.
61. Name the different looping statements in C?
While , do..while , for
62. How does if statement works? or
63. What is an if statement?
It's a two way decision making statement where a block of code is executed ifthe specified
condition is true or another block is executed if condition is not true. According to the
complexity there are different forms.
664, Explain the syntax of simple if statement ?
if (tst expression ) :
{ a
True statement block;
2 rho. i
Test expression is evaluated first. fits true the statement block is executed and then
statement x is executed. iFitis false the statement block will be skipped and the execution“if statement 2
65. Draw the flowchart of simple
True
True stat: block
Statement x
65. Explain the syntax of
else statement ?
|
The test expression is evaluated firs, if it is true the true statement block is executed
sotherwise the false statement block's executed . In both the cases the control is transferred
to statement x.
67. Draw a flowchart of if..else statement ?
68, What Is the use of nested it?
When a series of d
ndition nested if is be used.
to be taken based on ion
FOr How does nested if worTest Coneltion deals terete atts test covdtton 2 is NIUE eae
Statement 1s efecued IiTeSUCgeaMR i fale S102 eae ee
1 itselfis false statement 3 is executed All the cases control will Be trensfesred to/statement
x. When nesting if care should be taken to match every if with an else.
). How else if ladder works 2
The conditions are evaluated from the top of the ladder downwards. As soon as true
condition is found the statement associated with itis executed and the control is transferred
to statement x,, skipping the rest of the ladder. When all the n conditions become false then
the final else containing the default statement will be executed.
‘71. What is the use of default statement in else if ladder?
‘When all the n conditions become false then the final else containing the default statement
is executed.
72. Whatis the advantage of switch over elseif ladder?
Aswitch statement is significantly faster than an else..if ladder if there are many decisions
involved. This is due to break statement to jump out of switch as soon as the desired case is
found.
73. What is the use of case labels?
Case labels contain the possible answeFs '" Switch expression, ‘Switch expression is
compared with these labels and block of statement associated with the matching label will
be executed.
74, What is the use of break statement? .
The break command is used to oo, sa loop or switch from any point.
75. What is the purpose of switch ad
For muttipath decision making #88 12°" can be used complesity of such proBrams
increases dramatically when the SUTIN’ skernatives increases, The program becomes
diet 0 read and follow. C352 Baty tay cases LOB Re
Switch whose purpose istoimplement Ri nath decision magn statements.
76. What is the loop statement? *_
in looping, a sequence of statements are €xecuted until some conditions for termination of
the loop are satisfied. A program loop therefore consists of two segments
1) body of the loop
2) control statement
Control statement test certain conditions and then directs the repeated execution of the
statements contained in the body of the loop.
77. What are the different types of loop statements?
While loop, Do..while loop and For loop of which while and for are entry control loop and
do..while are exit control loop.
78. Difference between conditional or control and looping statements
Control statement test certain conditions and then directs the repeated execution of the
looping statements contained in the body of the loop
79, Differentiate entry and exit control loop?
'n entry control loop the control conditions are tested before the start of the loop of the loop
execution. In exit control loop the test is performed at the end of the body of the loop and
therefore the body is executed unconditionally for the fist time.
What is counter controlled loop?
A counter controlled loop is used when the number of iterations to occur is already known.
81. Explain while loop ?
The while is an entry control loop statement. The test condition is evaluated and if the
condition is true, then the body of the loop is executed. After execution of the body the test
condition is once again evaluated and fit is true the body is executed once again. The process.
of repeated execution of the body continues until the test condition finally becomes false and
the control is transferred out of the loop.
82. Explain do..while loop ?
On reaching the do statement, the program proceeds to evaluate the body of the loop first.
‘At the end of the loop the test condition in the while statement is evaluated. f the condition
is true the program continues, o evaluate the body of the loop again. This process continues
‘slong as the condition is true, When the condition becomes false the loop will be terminated
‘and control g0es Out ofthe loop,83. Explain syntax of for loop ?
loop is executed, at the closing
Serertoemactena covey ercarmars 028 09 te
bracket counter is incremented and check with 05¢ ond ages
the test condition is false
84. What is an infinite oop?
Loop that repeats indefinitely and never te
= while {ate0) * can make infinite loop
85. What is the nesting of loops?
‘One loop can be enclosed in another ‘and its calle
completed first before outer loop.
86. What is the use of goto statement ?
“The goto statement is used to branch uncor
led infinite loop. Conditions like
aminates 1s Cal
4 nesting of loops. Then inner loop will be
ainay from one pnt 10 another in the
program.
What is forward and backward jump in goto?
nv tet, i before the statement got label 31000 WPS formed and some statements
‘wil be executed repeatedly. Such ajump is known 3 backward jump. On the other hand if
the bel is placed after the goto label some statements willbe skipped and the jumpis known
2s forward jump.
‘58. Whats the use of break statement ?
inbreats the current flow of execution. An eaiyext rom 91900 9 be accomplished by using
the break statement in the goto statement switch statement . When a break; statement
pe moontered inside 2 loop the lop is immedatey ‘exited and the program continues with
is encoeement immediately following the loop. when the [00PS 2f& nested the break would
only exit from the loop containing it.
?
188, what isthe use of continue statement
‘Continue statement couses 2109p to Be continued with the next iteration after skipping #¥
‘statements in between.
JODULE 3
90. Define Array?
‘group of related data items (homogeneous elements) under a common name:
91. What is stremp()?
any suction to compare nei, °e¥O0 compares two stings wing he ASC
Si nc pats a8 BY ey are equa they ae fab RMS
comer difference between tne HRENO”™SNe characters in the stings:An array having any no of rows and columns and uses 3 or more subscripts to
represent is called multidimensional array,
93. Explain initialization of array ?
Syntax is: data type —array-name [size] = { list of values };
Eg: int number(3] = (23,34,45);
This values will be assigned as number{0}=23;
number{1]=34;
number[2}=45;
‘94, What is string?
Any group of characters defined between double quotation marks isa string constant.
ce" We doe
95. What is character array? Or what is an array of strings?
A string is a sequence of characters that is treated as a single data item. The compiler assigns
2 character string to a character array and automatically supplies a null character ‘\O’ at the
end of the string.
96. Give an example for array of strings ?
Eg: char cityl10}; Size of the array determines the no of characters +1.
97. What is the use of streat() ?
‘Strcat() is used to concatenate (join) two strings together .The null character at the end of first
string will be removed, attach the second string
Streat(string1 string2);
98. List the types of array ?
One dimensional , Two dimensional, Multidimensional
99. Explain declaration and initialization of array?
data type arrayname [size] = (list of values } ;
4100. Write any two string manipulation functions?
strempl) ~ to compare two strings
strcat() ~to concatenate two strings
4101. Write any two library functions ?
sqrt) ~to find the square root of ano
scanfl) ~to read formatted inputs
1102. What is one dimensional array ?
‘An array with any no of rows and only one column and uses only one subscript to represent,
itis called one dimensional array
103. What is two dimensional array ?
{An array having any no of rows and any no of columns and uses two subscripts to represent
then itis called a two dimensional array
+104, What is the purpose of string.h ?
String.h is the header file used to include in program to process string functions,
105. Difference between striwr() and strupper()?
Striwr()- to make the string lowercase
Strupperl) to make the string uppercase |
106. Any two characteristics of array? |
Elements are stored in continuous memory location
10Array elements are always counted from ze/®" _, of the element:
Array elements can be accessed using the p*
107. How to read and display string ?
Using scanfi) and printf) and control string
Eg: char city{20};
Scanf("%s", city); printf("City is %5\n
108. Which characteris stored to terminate st/i"®*
‘NO’ null characteris used to indicate the end "7° sting
109, What is the base address of array?
40) is the base address of array. Foreg: in 2”
2130. What is array index? a
voor or subscript Indleates tHE'BBEfan of he CTT Ty
element where 0 indicates the pt ion spa this 0s called an index.
‘How will you initialize a character array in C?
y are dectarediin eit
city
ay a{10 a0] wil be the fist element.
a
ithin the array. Eg: a{0] is the first
m1
Character arrays may be initialized when the er of the following two
forms.
char city[9] = "NEWYORK"; or char citvl2! “M701, R, KNOY
412. What is user defined function?
Programmer developed functions are calle
113, What is the need/use of user defined function?
if we code any program utilizing only main functi
complex and as a result the task of debugging, ts!
program is divided into functional parts, then each part may Be inde
Combined into a single unt. This is why we need user defined functions.
114, bepain the function prototype, function call and function definition?
Function definition is the description of function
d the user defined functions.
jon the program may become too large and
ting, and maintaining becomes difficult. If 3
pendently coded and later
‘The function header ie. The data tyPe function name and parameter list is called function
prototype. :
Variable name = function name (parameter list) is the function call which calls the function
in main program.
115. Basic structure of function
116. Differentiate actual and formal parameters?
orev Is which
‘Actual parameters are the fonction 1° *valable in the main (calling) program and
are used to pass value 10) Which
ch re present in the called function used to receve
are
‘oming from the calling function.
‘or Explain SY"tax of function definition ~ refer Ans.109
nh* return() statement
Afunetion may or may not send back any value tothe calling function. fit does, itis done through
the return statement . While It is possible to pass to the called function any number of values ,
‘the called function can only return one valve per cal. The return statement can take one of the
following forms
feturn; - does not return any value only the control passed back to calling (main)
program,
OR
return (expression); - returns the value of the expression.
{120 marks question give an introduction What is function and explain with an eg.)
128, Advantage of using user defined functions ?
1. It facilitates top-down modular programming. if a program is divided into functional parts ,
then each part may be independently coded and later combined into a single unit.
2. The length of a source program can be reduced by using functions at appropriate places. This
factor is particularly necessary with microcomputers where memory space is limited.
3. tis easy to locate and isolate a faulty function for further investigations
‘4. Afunction may be used by many other Programs. This means that a C programmer can build
‘on what others have already done, instead of starting all over from scratch.
(110 marks question give an introduction what is function need and explain with an eg.)
MODULE 5
130. What is the use of structures ?
{A structure is @ convenient tool for handling a group of logically related data items. For example it can
be used to represent a set of attributes such as roll-no, student-name and marks.
131. Explain structure definition ? %
‘The general format of a structure definition is as follows:
In defining a structure YOU may note the folowing gyntaX
1. The template isterminated with semicolon a .
2. Each member shouldbe deciareg nyo ty forthe name and type
3. The tagnameis used decar varighies er ide the PFOBT™
4138, How to declare a pointer?
Syntax: datatype *ptr-name;
This tells the compiler three things about the variable pt-name.
The ‘* ‘tells that the variable pt:name is 8 pointer variable
Pr-name needs a memory location
Pr-name points to a variable of type data type.
Eg: int *p; declares the variable p as a pointer variable to an integer data type,
139. What is a null pointer?
Annull pointer has a reversed value that is a null pointer constant for indicating that the
pointer does not point to any valid object or function,
140. . What is the significance of a pointer?
It's an important feature of C because they give you the ability to manipulate the data in the
‘computer's memory. This can reduce the code and improve the performance.
141, What happens when a pointer variable is incremented?
Af pLis an integer pointer with an inital value say 2800, then after *pl++; the value of p will
'be 2804 (not 2801). when we increment a pointer its value is increased by the length of the
data type it points. Here intis a4 byte data type in a 32 bit computer so incremented to 2804.
This length is called the scale factor. The value for which the pointer increments depends on
the length of the data type it holds. This length is called scale factor.
142. Whats the output of the following program?
include
Int main()
{
Int *ptr,
ptr=Ba,
“pire =1;
printt("%6d, %d “, *ptr,a);
return 0;
,
*ptr+= a;
pte = *ptr +1;
Since ptr=8a =
“ptr = *(Ba) = 5;
Therefore *ptr= *ptr +1
*5¢1=6
Outputis 6 5