Professional Documents
Culture Documents
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.
#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();
}
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.
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.Header Files
2.Variable Declaration
3.Input statement
4.Assignment Statement
5.Output statement
Example:
#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.
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.
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:
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:
Tree:
Graph:
Functions:
Userdefine in Functions:
These functions are generated by user according to there needs.
Syntax:
}
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 );
#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();
}