You are on page 1of 8

Software Development Tutorial(BCS-IT)

WEEK-1,2,3,4,5
Algorithm:
In mathematics, computing, and related subjects, an algorithm is an effective method for
solving a problem using a finite sequence of instructions. Algorithms are used for
calculation, data processing, and many other fields.

Time Complexity:
The amount of time required for running an algorithm.

Space Complexity:
The amount of space required in RAM for running an algorithm.

Write a Program to detect Odd and Even Numbers(An Algorithm):

#include<stdio.h>
#include<conio.h>
Void main()
{
Int x;
Clrscr();
Printf(“Enter a value for x”);
Scanf(“%d”,&x);
if(x%2==0)
Printf(“number is Even”);
Else
Printf(“number is ODD”);
Getch();
}

Best, worst and average case complexity

The best, worst and average case complexity refer to three different ways of measuring
the time complexity (or any other complexity measure) of different inputs of the same
size. Since some inputs of size n may be faster to solve than others, we define the
following complexities:

• Best-case complexity: This is the complexity of solving the problem for the best
input of size n.
• Worst-case complexity: This is the complexity of solving the problem for the
worst input of size n.
• Average-case complexity: This is the complexity of solving the problem on an
average.
Programming:
Set of instruction to solve a problem is programming.Programming is a main tool to
develop software.

Compiler:
Transfer source code into machine code and machine code to source code.

Turbo C/C++ is the compiler helps to develop correct programming language.

Data Types:
There are 4 basic data types in programming:
Integer data: when we declare int data types then inside RAM 2 bytes space will be
allocated.
Float data: When we declare float data types then inside RAM 4 bytes space will be
allocated.
Character data: when we declare char data types then inside RAM 1 bytes space will be
allocated.
Double data: when we declare double data types then inside RAM 8 bytes space will be
allocated.

Variable:
Variable is a value that can be changed.When we declare variable a memory space is
created in the main memory(RAM).
Declaration:
Data type variable name;
Example: int a;
In this case a 2 bytes memory space is created and the name of the space is a.
Structure of C Programming:
Structured Programming is a software design technique that increases the extent to
which software is composed from separate parts, called modules.

Characteristics:

1.It is a high Level Language


2.It is a case sensitive Language
3.Modular Programming

Steps of Structured Programming:

1.Header Files
2.Variable Declaration
3.Input statement
4.Assignment Statement
5.Output statement

Example:

Write a Program to calculate area of a circle:

#include<stdio.h> Header Files


#include<conio.h>
Void main()
{
Float area,radius; Variable Declaration
Clrscr();
Printf(“Enter a value of radius”);
Scanf(“%d”,&radius); Input statement
Area=3.14*radius*radius: Assignment Statement
Printf(“area is %f”,area); Output statement
Getch();
}

Write a Program to add,subtract,multiply,divide 2 numbers:

#include<stdio.h>
#include<conio.h>
Void main()
{
Int a,b,c;
Clrscr();
Printf(“enter value of a”);
Scanf(“%d”,&a);
Printf(“enter value of b”);
Scanf(“%d”,&b);
C=a+b;
Printf(“output is %d”,c)
Getch();
}

Looping:
It means repetition of a process until the condition is not satisfied.

Structure of For Loop:


For (initialization; condition; increment/decrement)

Write a Program to display n numbers in increment order.


#include<stdio.h>
#include<conio.h>
Void main()
{
Int n,i;
Printf(“enter a value of n?”)
Scanf(“%d”,&n);
For (i=0; i<n; i++)
Printf(“\n the numbers are %d”,n)
Getch();
}

Write a Program to display n numbers in decrement order.


#include<stdio.h>
#include<conio.h>
Void main()
{
Int n,i;
Printf(“enter a value of n?”)
Scanf(“%d”,&n);
For (i=n; i>=0; i--)
Printf(“\n the numbers are %d”,n)
Getch();
}

Branching:
Branching is based on if else statement.
If (Condition)
Statement 1;
Else
Statement 2;

In this case if the condition is true then statement 1 is true otherwise statement 2 will be
true.

Example:
#include<stdio.h>
#include<conio.h>
Void main()
{
Int x;
Clrscr();
Printf(“Enter a value for x”);
Scanf(“%d”,&x);
For(x%2==0)
Printf(“number is Even”);
Else
Printf(“number is ODD”);
Getch();
}

Data Structure:

In computer science, a data structure is a particular way of storing and organizing data
in a computer so that it can be used efficiently. Different kinds of data structures are
suited to different kinds of applications, and some are highly specialized to specific tasks.

Operation of Data Structures:

Traversing
Accessing each record exactly once so that certain items in the record may be processed.
(This accessing or processing is sometimes called 'visiting" the records.)
Searching

Finding the location of the record with a given key value, or finding the locations of all
records, which satisfy one or more conditions.

Inserting
Adding new records to the structure.

Deleting
Removing a record from the structure.

Sorting:

Sorting is one of the most important operations performed by computers. In the days of
magnetic tape storage before modern data-bases, it was almost certainly the most
common operation performed by computers as most "database" updating was done by
sorting transactions and merging them with a master file. It's still important for
presentation of data extracted from databases: most people prefer to get reports sorted
into some relevant order before wading through pages of data!

Merging:

Combining of two different tables in to one table is called merging.

Types of Data structures:

Stack:
In computer science, a stack is a last in, first out (LIFO) abstract data type and data
structure. A stack can have any abstract data type as an element, but is characterized by
only two fundamental operations: push and pop.

Queue:
This makes the queue a First-In-First-Out (FIFO) data structure. In a FIFO data structure,
the first element added to the queue will be the first one to be removed. This is equivalent
to the requirement that whenever an element is added, all elements that were added
before have to be removed before the new element can be invoked. A queue is an
example of a linear data structure.

Linked List:

In computer science, a linked list is a data structure that consists of a sequence of data
records such that in each record there is a field that contains a reference (i.e., a link) to the
next record in the sequence.

A linked list whose nodes contain two fields: an integer value and a link to the next node

Linked lists are among the simplest and most common data structures, and are used to
implement many important abstract data structures, such as stacks, queues, hash tables,
symbolic expressions, skip lists, and many more.

Array:

In computer science, an array data structure or simply array is a data structure


consisting of a collection of elements (values or variables), each identified by one or
more integer indices, stored so that the address of each element can be computed from its
index

Tree:

In computer science, a tree is a widely-used data structure that emulates a hierarchical


tree structure with a set of linked nodes.

Mathematically, it is not a tree, but an arborescence: an acyclic connected graph where


each node has zero or more children nodes and at most one parent node. Furthermore, the
children of each node have a specific order.
A simple unordered tree; in this diagram, the node labeled 7 has two children, labeled 2
and 6, and one parent, labeled 2. The root node, at the top, has no parent.

Graph:

A "graph" in this context refers to a collection of vertices or 'nodes' and a collection of


edges that connect pairs of vertices.

Functions:

There are 2 types of Functions in C.


i)Built in Function:
These functions have predefined meanings to the compiler.

Example: printf(); scanf(); getch(); clrscr();

Userdefine in Functions:
These functions are generated by user according to there needs.
Syntax:

Return data type function name (parameter)


{
Statement
}

Example: int sum_of_all(int x)


{

}
Function prototype:
It describe every thing about the function.

Example:
int sum_of_all( );

Function Definition:
It is same as function prototype but without semicolon symbol(;)
Example:
int sum_of_all( )
{

Function Calling:
It is same as function prototype but includes value as a prototype.
Example:
X= int sum_of_all( 10 );

Write a Program to calculate the sum of n numbers .

#include<stdio.h>
#include<conio.h>
Void main()
{
Int n,sum,i;
Clrscr();
Printf(“Enter a value for n”);
Scanf(“%d”,&n);
Sum=0;
For(i=0; i<n;i++)
Sum=sum+i;
Printf(“sum of n numbers are %d”,sum)
Getch();
}

You might also like