cds-lab-1-3-lab-manual
cds-lab-1-3-lab-manual
cds-lab-1-3-lab-manual
LIST OF EXPERIMENTS
1. Practice of C programming using statements, expressions, decision making and iterative statements
2. Practice of C programming using Functions and Arrays
3. Implement C programs using Pointers and Structures
4. Implement C programs using Files
5. Development of real time C applications
6. Array implementation of List ADT
7. Array implementation of Stack and Queue ADTs
8. Linked list implementation of List, Stack and Queue ADTs
9. Applications of List, Stack and Queue ADTs
10. 10.Implementation of Binary Trees and operations of Binary Trees
11. Implementation of Binary Search Trees
12. Implementation of searching techniques
13. Implementation of Sorting algorithms : Insertion Sort, Quick Sort, Merge Sort
14. Implementation of Hashing – any two collision techniques
TOTAL: 45 PERIODS
COURSE OUTCOMES:
At the end of the course, the students will be able to:
CO1: Use different constructs of C and develop applications
CO2: Write functions to implement linear and non-linear data structure operations
CO3: Suggest and use the appropriate linear / non-linear data structure operations for a given problem
CO4: Apply hash functions that result in a collision free scenario for data storage and Retrieval
CO5: Implement Sorting and searching algorithms for a given application
PROGRAM
#include <stdio.h>
int main()
{
float radius;
double area, circumference;
printf("\n Enter the radius of the circle : ");
scanf("%f", &radius);
area = 3.14 * radius * radius;
circumference=2*3.14*radius;
printf(" \n Area = %lf", area);
printf(" \n Circumference = %lf", circumference);
return 0;
}
OUTPUT
Enter the radius of the circle : 3
Area = 28.260000
Circumference = 18.840000
PROGRAM
#include <stdio.h>
int main() {
int number1, number2, sum;
printf("Enter two integers: ");
scanf("%d %d", &number1, &number2);
// calculating sum
sum = number1 + number2;
printf("Sum of two numbers: ");
printf("%d + %d = %d", number1, number2, sum);
return 0;
}
OUTPUT
Enter two integers: 4 5
Sum of two numbers: 4 + 5 = 9
Step 5: Avg=sum/3;
Step 6: Display "sum " and "Avg".
Step 7 :End
PROGRAM
#include <stdio.h>
int main()
{
int a,b,c;
float sum;
float avg;
printf("\nEnter First Number : ");
scanf("%d", &a);
printf("\nEnter Second Number : ");
scanf("%d",&b);
printf("\nEnter Third Number : ");
scanf("%d",&c);
sum=a+b+c;
printf("\nsum: %.2f",sum);
avg=sum/3.0;
printf("\nAverage of Three Numbers : %.2f",avg);
return 0;
}
OUTPUT
Enter First Number : 5
Enter Second Number : 7
Enter Third Number : 9
sum: 21.00
Average of Three Numbers : 7.00
RESULT: Thus the C Program to illustrate concept of Statements and Expressions has been executed.
AIM
To write a C Program to illustrate the concept of Decision making and Branching statements.
C supports decision control statements that can alter the flow of a sequence of instructions. These
statements help to jump from one part of the program to another depending on whether a particular
condition is satisfied or not.
(a) if statement,
ALGORITHM
Step 2 : if (N%2==0)
Step 4 : else
Step 6: Exit
PROGRAM
#include <stdio.h>
int main()
int a;
scanf("%d", &a);
if(a%2==0)
else
return 0;
OUTPUT
6 is even
61 is odd
B. IF–ELSE–IF STATEMENT
C Program to check whether a number is negative, positive or zero using if–else–if Statement
ALGORITHM:
5. End.
PROGRAM
#include <stdio.h>
int main()
int num;
scanf("%d", &num);
if(num==0)
else if(num>0)
else
return 0;
OUTPUT:
C. SWITCH–CASE STATEMENT
ALGORITHM
Step 1: Start
Step 2: Declare character type variable ch and Read ch from User
Step 3: // Checking both lower and upper case vowels.
IF (ch == 'a' || ch == 'A' ||
ch == 'e' || ch == 'E' ||
ch == 'i' || ch == 'I' ||
ch == 'o' || ch == 'O' ||
ch == 'u' || ch == 'U' )
Print "Vowel"
ELSE
Print "Consonant"
Step 4: Stop
PROGRAM:
#include <stdio.h>
int main()
char c;
printf("Enter an Alphabet\n");
scanf("%c", &c);
switch(c) {
case 'a':
case 'A':
case 'e':
case 'E':
case 'i':
case 'I':
case 'o':
case 'O':
case 'u':
case 'U': printf("%c is VOWEL", c);
break;
default: printf("%c is CONSONANT", c);
}
return 0;
}
OUTPUT
Enter an Alphabet
e
e is VOWEL
Enter an Alphabet
Z
Z is CONSONANT
RESULT:
Thus the C Program to illustrate the concept of Decision making and Branching statements.
AIM
DESCRIPTION
Iterative statements are used to repeat the execution of a sequence of statements until the specified
expression becomes false. C supports three types of iterative statements also known as looping
while loop
do–while loop
for loop
A.WHILE LOOP
ALGORITHM
Step 1: Start
Print i
Compute i=i+1
Step 5: Stop
PROGRAM
#include <stdio.h>
int main()
int i = 1,n;
scanf("%d",&n);
while(i<=n)
i = i + 1;
return 0;
OUTPUT:
ALGORITHM
Step 1: Start
Sum=sum+i
i=i+1
Step 6 :End
PROGRAM
#include <stdio.h>
int main()
scanf("%d", &n);
while(i<=n)
sum = sum + i;
i = i + 1;
return 0;
OUTPUT
B. DO–WHILE LOOP
ALGORITHM
Step 1: Start
Step 4: DO
Print i
Compute i=i+1
While i<=num
Step 5: Stop
PROGRAM
#include <stdio.h>
int main()
int i = 1;
do
i = i + 1;
while(i<=10);
return 0;
OUTPUT:
1 2 3 4 5 6 7 8 9 10
#include <stdio.h>
int main()
scanf("%d", &n);
do
sum = sum + i;
i = i + 1;
while(i<=n);
avg = (float)sum/n;
return 0;
OUTPUT
C. FOR LOOP
ALGORITHM
Step 1: Start
Step 2: Assign i=1
Step 3: Read a number, num
Step 4: For i<=num
Print i
Compute i=i+1
Step 5: Stop
PROGRAM
#include <stdio.h>
int main()
int i, n;
scanf("%d", &n);
for(i=1;i<=n;i++)
return 0;
OUTPUT:
RESULT: Thus the C Program to illustrate Iteration using Looping Statements was executed.