CPF Notes - Questions and Answers
--- Page 1 --- 1). Difference :- Algorithm V/S Flowchart. ANS :- Algorithm Flowchart 1. An algorithm
step-by-step solve a problem. 1. A flowchart is a diagram created with different shapes to show flow
of a data. 2. The algorithm is complex to understand. 2. A flowchart is easy to understand. 3. An
algorithm, plain text is used. 3. In flowchart, symbol/shapes are used. , 4. Algorithm is easy to
debug. 4. A flowchart is hard to debug. 5. The algorithm is difficult to create or construct. 5. A
flowchart is simple to create or construct. 2). Write an algorithm to check even and odd number.
Step 1 :- Start the program. Step 2 :- Read/input the number. Step 3 :- if n%2== then The Number is
even Step 4 :- else Sey Number is odd ay: Step 5:- Display the output. ~~ Step 6 :- Stop 3). Draw
and explain symbol of flowchart. ANS :- Here are the five most common shapes used in a flowchart.
* Oval (Terminal symbol) * Rectangle (Process symbol) Arrow (Arrow Symbol) Diamond (Decision
symbol) Poet \ ) | --- Page 2 --- Symbol | Function Represents the or end of a proces: Rectangle
Indicates the flow between steps I@tonel Signifies a poi Diamond en pom requiring a yes/no
Parallelogram | Used fori output operation: 4). Writes importance of Flowchart. ANS - Or The
flowchart is a graphical representation of a program or algorithm. - It displays the step-by-step
solution of process or system. - Flowchart describes the flow of data and control in system using
predefined flowchart symbol. athe flow is a set of logic operations. = cA Flowchart is important tool
for improvement of process. a> Y i. help to identify different elements of process. 2ortance :- ica) 4 2
2 a 1). Communication 2). Effective analysis. \. Proper Documentation. fficient coding maa 5). Write
an algorithm and draw flowchart for calculating simple interest. ANS :- a Algorithm :- Step 1 :- Start
Step 2 :- Read principal amount as p, time as t and rate of interest as r Step 3 :- SI = p*t*r/100 Step
4 :- Display SI oS ep 5 Stop gummy = 1@tonel --- Page 3 --- 6). Explain Features of C language.
1239 ANS:- C is a procedural programming language. It was initially developed by Dennis Ritchie in
the year 1972. It was mainly developed as a system programming language to write an operating
system. The main features of C language include low-level access to memory, a simple set of
keywords, and a clean style, these features make C language suitable for system programming like
Page 1
CPF Notes - Questions and Answers
an operating system or compiler development. 7] Features :- 4). Procedural Language 2). Fast and
Efficient 3). Modularity 4). Statically Type 5). General-Purpose Language 6). Rich set of built-in
Operators 7). Libraries with Rich Functions 8). Middle-Level Language 9). Portability 10). Easy to
Extend 1@tonel 7). Explain general structure of C program. AN: 1. Documentation :- This section
consists of the description of the program, the name of the program, and the creation date and time
of the program. It is specified at the start of the program in the form of comments. Documentation
can be represented as:- Example :- = Pp fEdescription, name of the program, programmer name,
date, time etc. a 2,,Preprocessor Section:- , All the header files of the program will be declared in the
preprocessor section of the program. Header files help us to ) access other's improved code into our
code. A copy of these multiple files is inserted into our program before the process of compilation. It
onel Example:- ~ude<stdio.h> math.h> 3. Definition:- Preprocessors are the programs that process
our source code before the process of compilation. There are multiple steps which are involved in
the writing and execution of the program. Preprocessor directives start with the '#' symbol. The
#define preprocessor is used to create a constant throughout the program. Whenever this name is
encountered by the &mpiter, it is replaced by the actual piece of defined code. Bxample:- I@tOnel
Heiefine tong long Il 4. Global Declaration :- The global declaration section contains global variables,
function declaration, and static variables. Variables and functions which are deciared in this scope
can be used anywhere in the program Example:- intnum --- Page 4 --- Every C program must have a
main function. The main() function of the program is written in this section. Operations like
declaration and execution are performed inside the curly braces of the main prograi The return type
of the main() function can be int as well as void too. oid() main tells the compiler that the program
will not return any value. The int main() tells the compiler that le program will return an integer value.
void main() in any / :- A token in C can be defined as the smallest individual element of the C
programming language thatis meaningful to the compiler. It is the basic component of a C program.
The tokens of C language can be classified into six types based on the functions they are used to
Page 2
CPF Notes - Questions and Answers
perform. The types of C tokens are as follows:- Keywords Identifiers Constants . Strings . Special
Symbols , 6. Operators --- Page 5 --- The constants refer to the variables with fixed values.
Examples of Constants in C:- const int c_var = 20; const int* const ptr = &c_var; C Token Strings
Strings are always enclosed in double quotes. Examples of String: char string[20] = general; char
string [] = general; + Brackets[): . + Parentheses() * Braces{} * Comma (, ) * Colon(:) * Semicolon(;)
1 E ed data types in c. : = 12:52 :- Enumeration (or enum) is a user defined data type in C. It is
mainly used to assign names to integral constants, the names make a program easy to read and
maintain. - It is a user-defined data type that consists of integer values, and it provides meaningful
names. #include<stdio.h> enum week{Mon, Tue, Wed, Thur, Fri, Sat, Sun}; void main() { enum
week day; day = Wed; printf("%d",day); getch();
Page 3