Computer Programing notes
Computer Programing notes
Characteristics:
Characteristics:
Symbol of Flowcharts:
COMPUTER PROGRAMING QUESTION BANK
Limitation of Flowcharts:
1. If program logic is quite complicated, the flowchart becomes complex.
2. If alterations are required, the flowchart may require re-drawing completely, it becomes
COMPUTER PROGRAMING QUESTION BANK
Time consuming.
Q-6 Draw a flowchart to print ODD numbers between 1 to N. Value of N is to be read from
standard input (keyboard).
1. Easy to learn C is a higher level language normally written in Natural Language. So it can be
easily understand by any programmer.
2. . More efficient more complex and large program can be easily made and run.
3. 3. Faster than any other basic language C does not contain input/output statements. But for
input/output operation, C uses library functions like scanf () and printf (). Other programming
language contains input/output statements. So, C is faster than any other basic language such
as Cobol, Pascal and Fortran.
4. 4. Portable C is developed to solve portability problem in UNIX. Programs are written using C
language is portable. That means C program written on one computer can transfer to other
computer without any modification in program or with little modification required.
5. Procedural oriented programming language Procedural Oriented means Function based
Programming. Large program can be divided into smaller sub programs. These sub programs
are called functions. So C program are written in form of functions. Each function can be easily
understand and managed.
6. Structured/Modular programming language If program is small, then it is easily understand
and managed. But if program is large, then it is hard to understand. So dividing large program
into smaller sub programs make it easy to understand and maintain. These smaller sub
COMPUTER PROGRAMING QUESTION BANK
programs are called module. The process of dividing a program into smaller sub programs is
called modularity. So, C is called modular programming language.
7. It support bit-wise operation C support bit-wise operations such as AND, OR, NOT operation
etc. but these operations are not supported by higher level language. It is supported by lower
level/assembly language. For this reason, C is not considered as fully or true higher level
language. But it is known as Middle level language. It provides features of both higher as well
as lower level language.
Q-8 What is a Data Type and explain three Data Types in details..?
C Language is rich in its data types. Data types are used to indicate which type of value stored in
variable.
C provides different qualifiers like signed, unsigned, short and long. By applying different
qualifier to basic data types, we can change the range of data types as per need.
COMPUTER PROGRAMING QUESTION BANK
Q-9 Write a program to enter two numbers from user and find addition of it.
COMPUTER PROGRAMING QUESTION BANK
The function puts () is used to print a string on screen. It automatically move cursor to the beginning
of next line after printing string. The format is given below.
Q-11 what is header file? Give list of header file used in ‘C’ Program.
The C compiler software is bundled with many pre-compiled header files. These are
called system header files. A well-known example is "stdio.h" – a header file included in
almost every C program.
Each of the system header files contains a number of utility functions. These functions are
often called library functions. For example, printf() and scanf() functions, needed for
performing IO operations, are the library functions available in the "stdio.h" header file.
#include <filename.h>
Here is the table that displays some of the header files in C language −
COMPUTER PROGRAMING QUESTION BANK
Q-13 Find errors in following: (1) Int x; (2) float x=”10”; (3) long char b; (4) #define PI=3.14
(1) Capital letter I is not valid so Int is not data type. Valid statement is int x;
(2) Double “” is not allowed in floating value. Valid statement is float x=10;
(3) Long qualifier is not used with char. Valid statement is char b; (4) = is not allowed in macro
declaration. Valid declaration is #define PI 3.14.
C supports rich set of operators. Operators are used to perform various operations on the data or
operands. There are following types of operators.
1) Arithmetic Operators
These operators are used to perform arithmetic operations on data or operands. These operators
are
For example,
if A=15 and B=4, then results of the arithmetic operations are as follows.
A + B = 19
A – B = 11
A * B = 60
2) Relational Operators
These operators are used to compare two operands so these operators are also called
comparison operators. These operators are,
For example,
A == B => false
3) Logical Operators:
For example, if X=12 and Y=20, then results of following operations are as follows. X>10 &&
Y!=15 => true && true => true.
Here && and || are also called short circuit operators because if results obtained by first
operand then second operand will not be evaluated. For example,
op1 && op2 in this expression, if op1 is false then result is false and op2 is not evaluated. op1 ||
op2 in this expression, if op1 is true the result is true and op2 is not evaluated.
4) Assignment Operators:
These operators are used to assign the value of variable or constant or value of expression
to the variable on left.
Variable = expression;
Advantages of short hand operators are: Variable is not repeated Statement becomes
more concise and faster.
COMPUTER PROGRAMING QUESTION BANK
Q-16 . Write a program to enter total second and separate hours, minutes and seconds
( 60 second= 1 minute and 60 minute=1 hour).
COMPUTER PROGRAMING QUESTION BANK
Q-17 Write a program to swap or interchange two numbers without using third variable.
COMPUTER PROGRAMING QUESTION BANK
C program is a set of statements which are normally executed sequentially in the order in
which they appear. This happens when no options or no repetitions of certain calculations are
required. But sometimes, we have a number of situations where we may have to change the
order of execution of statements based in certain conditions or repeat a group of statements
until certain specified conditions are met. Whenever the program control breaks the
sequential flow of execution of program and jump to another part of code it is called
branching.
There are two types of branching. First one is conditional branching and second one is
unconditional branching.
Branching that depends upon condition it is called conditional branching and branching that
does not depend upon condition it is called unconditional branching
C language provides such decision making capabilities by supporting following statements.
1. If statement
2. If… else statement
3. If… else if… else statement
4. Ladder if…else statement
5. Nested if statement
6. Switch case statement
7. Conditional operator statement
8. Goto statement
goto statement breaks the normal sequential execution of the program. If the label: is before the
statement goto label; then loop will be formed. Such a jump is known as backward jump. On the
other hand, if the label: is placed after the goto label; then some statements will be skipped and
jump is known as a forward jump.
COMPUTER PROGRAMING QUESTION BANK
22
333
COMPUTER PROGRAMING QUESTION BANK
4444
1234
123
12
1
COMPUTER PROGRAMING QUESTION BANK