Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Syllabus
BCA103T – Problem Solving Techniques using C
www.gkmvkalyan.blogspot.in
BCA103T – Problem Solving Techniques using C Page 2 of 33
PART – A
1) Write a C Program to find the roots of the given quadratic equation using if-else if statement.
2) Write a menu driven C program using switch-case to find: (a) Sum of the digits of number
(b) Factorial of N.
3) Write a C program to find cos (x) using series cos(x) = 1 – x2/2! + x4/4! -………xn/n! ]
4) Write a Program to find whether a given number is prime number are not
5) Write a C program to arrange the given set of numbers in ascending and descending order.
6) Write a C program to find product of two N x M matrices.
7) Write a C program to calculate NCR= N!/ R! * (N-R)! Using function.
8) Write a C program to display Fibonacci series using recursive function.
9) Write a C program to concatenate two strings using pointers.
10) Write a C program to copy content of one file to another file.
PART – B
During practical examination the External and Internal examiners may prepare exam question
paper related to theory syllabus apart from Part-A. (A minimum of 10 Programs has to be
prepared).
Note :
a) The candidate has to write both the programs One from Part-A and other from Part-B and
execute one program as of External examiner choice.
b) A minimum of 10 Programs has to be done in Part-B and has to be maintained in the
Practical Record.
c) Scheme of Evaluation is as follows:
Writing two programs - 10 Marks
Execution of one program - 10 Marks
Formatting the Output - 05 Marks
Viva - 05 Marks
Record - 05 Marks
Total - 35 Marks
www.gkmvkalyan.blogspot.in
BCA103T – Problem Solving Techniques using C Page 3 of 33
Unit-I
Introduction to Programming Concepts
A computer is defined as follows:
System Software
System software is the software that communicates directly with the computer.
It provides the interface between user and the computer.
This software can be divided into 3 main categories.
Operating System (OS)
Utilities
Language Translators
Applications Software
www.gkmvkalyan.blogspot.in
BCA103T – Problem Solving Techniques using C Page 4 of 33
Language Translators
Assembler
An assembler is a program that translates the mnemonic codes used in
assembly language into the bit patterns that represent machine operations.
Assembly language has a one-to-one equivalence with machine code, each
assembly statement can be converted into a single machine operation.
Compiler
A compiler turns the source code that you write in a high-level language into
object code (machine code) that can be executed by the computer.
The compiler is a more complex beast than the assembler. It may require
several machine operations to represent a single high-level language
statement. As a result, compiling may well be a lengthy process with very large
programs.
Interpreter
Interpreters translate the source code at run-time. The interpreter translates
statements one-at-a-time as the program is executed.
Interpreters are often used to execute high-level language programs whilst
they are being developed since this can be quicker than compiling the entire
www.gkmvkalyan.blogspot.in
BCA103T – Problem Solving Techniques using C Page 5 of 33
www.gkmvkalyan.blogspot.in
BCA103T – Problem Solving Techniques using C Page 6 of 33
Modular Programming
Modular programming is the process of subdividing a computer program into
separate sub-programs.
Structured Programming
A technique for organizing and coding computer programs in which a hierarchy of
modules is used, each having a single entry and a single exit point, and in which
control is passed downward through the structure without unconditional branches to
higher levels of the structure.
Three types of control flow are used: Sequence, Selection, and Iteration.
www.gkmvkalyan.blogspot.in
BCA103T – Problem Solving Techniques using C Page 7 of 33
Step1: start
Step3: S=A+B+C
Step4: Output S
Step5:Stop
www.gkmvkalyan.blogspot.in
BCA103T – Problem Solving Techniques using C Page 8 of 33
Flowcharts are usually drawn using some standard symbols as shown below.
Denotes decision(or
Decision branch) to be made.
Denotes a process to be
carried out.
Processing
Ex addition, subtraction,
division ….
Used to invoke a
subroutine program or
Predefined Process
an interrupt program.
www.gkmvkalyan.blogspot.in
BCA103T – Problem Solving Techniques using C Page 9 of 33
www.gkmvkalyan.blogspot.in
BCA103T – Problem Solving Techniques using C Page 10 of 33
www.gkmvkalyan.blogspot.in
BCA103T – Problem Solving Techniques using C Page 11 of 33
Overview of C Language
“C” is a structured programming language developed by Dennis Ritchie in 1972
at Bell Laboratories. C language was developed with UNIX operating system, so
it is strongly associated with UNIX, which is one of the most popular network
operating system in use today.
www.gkmvkalyan.blogspot.in
BCA103T – Problem Solving Techniques using C Page 12 of 33
C language is very popular language among all the languages. The structure of
a C program is a protocol (rules) to the programmer, while writing a C
program. The general basic structure of C program is shown in the figure
below.
Program Code
/* Our first simple C basic program */
#include <stdio.h>
void main()
{
int A=5, B=10, C;
C=A+B;
printf(“The Value of C is %d”,C);
getch();
}
www.gkmvkalyan.blogspot.in
BCA103T – Problem Solving Techniques using C Page 13 of 33
Step2: After writing the program save it(press f2 to save your program)
www.gkmvkalyan.blogspot.in
BCA103T – Problem Solving Techniques using C Page 14 of 33
In the above we can see the file name has GKSir.C , .C is the extension of C
programming, so whenever you save the program, save it with extension .C
Step4: To run the program, after free of errors. Click on Run or Press Ctrl+f9
www.gkmvkalyan.blogspot.in
BCA103T – Problem Solving Techniques using C Page 15 of 33
Step5: Output
www.gkmvkalyan.blogspot.in
BCA103T – Problem Solving Techniques using C Page 16 of 33
Character Set : The characters that can be used to form words and
expressions depends upon the computer to which the program is run.
www.gkmvkalyan.blogspot.in
BCA103T – Problem Solving Techniques using C Page 17 of 33
Variables: A Variable is a name give to memory location where the actual data
is stored.
To indicate the memory location, each variable should be given a unique name
called identifier.
Constants: Constants are the terms that can't be changed during the
execution of a program.
Different types of C constants
Constant Type of value stored
Integer Constant Constant which stores integer value.
Floating Constant Constant which stores float value.
www.gkmvkalyan.blogspot.in
BCA103T – Problem Solving Techniques using C Page 18 of 33
String Constant: These are the sequence of character within double quote.
Example: “GKMV”, “India”, “4”
Escape Sequences
In C language there are some characters that are not treated as the same.
These character combinations that give different results such as a new line, a
tab space, or a backspace, are known as escape sequences.
Escape sequences in C language start with a backslash (\) and followed by a
character.
www.gkmvkalyan.blogspot.in
BCA103T – Problem Solving Techniques using C Page 19 of 33
Data types
In C data types are defined as the data storage format that a variable can store
a data to perform a specific operation.
Variable(data) should be declared before it can be used in program. Data types
are the keywords, which are used for assigning a type to a variable.
C language is rich of data types.
www.gkmvkalyan.blogspot.in
BCA103T – Problem Solving Techniques using C Page 20 of 33
Variable Declaration in C
A variable declaration provides assurance to the compiler that there is one
variable existing with the given type and name so that compiler proceed for
further compilation. A variable declaration has its meaning at the time of
compilation only, compiler needs actual variable declaration at the time of
linking of the program.
A variable declaration has the form:
type variable_list;
Here type must be a valid C data type. The variable_list may consist of one or
more identifier names separated by commas.
Some of the valid declaration are shown below.
int a, b;
char ch;
float sum, average;
www.gkmvkalyan.blogspot.in
BCA103T – Problem Solving Techniques using C Page 21 of 33
www.gkmvkalyan.blogspot.in
BCA103T – Problem Solving Techniques using C Page 22 of 33
a)Arithmetic operators
www.gkmvkalyan.blogspot.in
BCA103T – Problem Solving Techniques using C Page 23 of 33
b) Relational operators
www.gkmvkalyan.blogspot.in
BCA103T – Problem Solving Techniques using C Page 24 of 33
c) Logical operators
d) Assignment operators
The most common assignment operator is =. This operator assigns the value in
right side to the left side.
www.gkmvkalyan.blogspot.in
BCA103T – Problem Solving Techniques using C Page 25 of 33
operand
Modulus AND assignment operator, It A %= B
%= takes modulus using two operands is equivalent to
www.gkmvkalyan.blogspot.in
BCA103T – Problem Solving Techniques using C Page 26 of 33
Example for ==
A==B
It checks whether the value of A and B are equal or not.
Consider A=5 and B=8;
A==B
It checks whether the value of A and B are equal or not.
The increment and decrement operators can be each be utilized two different
ways, depending on whether the operator is written before or after the
operand. If the operator precedes the operator(eg:++i) then it is called as pre-
increment operator. If the operator follows the operands(eg: i++) then it is
known as post-increment operator.
www.gkmvkalyan.blogspot.in
BCA103T – Problem Solving Techniques using C Page 27 of 33
Examples:
a=10; b=20;
x=++a;
y=b++;
Here x=++a statement is equivalent to following two statement in sequence.
a=a+1;
x=a;
So the value of x and a will be 11.
y=b++ is equivalent to
y=b;
b=b+1;
so the value of y=20 and b=21.
Thus, pre-increment operator first increments the value of the operand and
then returns the value (the incremented one).
post-increment operator first returns the value and then increments the value
of the operand.
www.gkmvkalyan.blogspot.in
BCA103T – Problem Solving Techniques using C Page 28 of 33
Consider an example.
a=10, b=20;
b=a++;
a=++b;
printf(“a=%d\n b=%d”,a,b);
The output will be generated as shown below
a=11
b=11
www.gkmvkalyan.blogspot.in
BCA103T – Problem Solving Techniques using C Page 29 of 33
Example:
x=10, y=15,
BIG=(x>y)? x:y;
printf(“Largest of two number= %d \n”, BIG);
the output is:
Largest of two number = 15
g) Bitwise Operators
Bitwise operator works on bits and performs bit-by-bit operation. The truth
tables for &, |, and ^ are as follows:
0 0 0 0 0
0 1 0 1 1
1 1 1 1 0
1 0 0 1 1
Assume if A = 60; and B = 13; now in binary format they will be as follows:
A = 0011 1100
B = 0000 1101
-----------------
www.gkmvkalyan.blogspot.in
BCA103T – Problem Solving Techniques using C Page 30 of 33
Binary AND Operator copies a bit to the (A & B) will give 12, which
&
result if it exists in both operands. is 0000 1100
Binary XOR Operator copies the bit if it is (A ^ B) will give 49, which
^
set in one operand but not both. is 0011 0001
www.gkmvkalyan.blogspot.in
BCA103T – Problem Solving Techniques using C Page 31 of 33
h) sizeof() operators
The sizeof() operator returns the size of its operand in bytes. The sizeof()
operator always precedes its operand. The operand may be an expression or it
may be a cast.
Example:
Suppose i is an integer variable and c is a character type variable then
printf(“Size of integer : %d”,sizeof(i));
printf(“Size of character : %c”,sizeof(c));
It is a unary operator which is used in finding the size of data type, constant,
arrays, structure etc.
i) Comma operators
Comma operators are used to link related expressions together.
For example:
int a,c=5,d;
www.gkmvkalyan.blogspot.in
BCA103T – Problem Solving Techniques using C Page 32 of 33
www.gkmvkalyan.blogspot.in
BCA103T – Problem Solving Techniques using C Page 33 of 33
www.gkmvkalyan.blogspot.in