RVS PADHMAVATHY COLLEGEC LabOFManual
ENGINEERING
– CS8261 & TECHNOLOGY,
CHENNAI
Computer Lab Manual
Department of Computer Science and
Engineering
C Programming – CS8261
2017-‘18
Compiled by
John T Mesia Dhas M.E., M.B.A., (Ph.D)
Deptartment of Computer Science and Engineering
[RVSCHENNAI]
1
C Lab Manual – CS8261
Program 1:
Display a string using printf() statement.
Aim:
Create a program in C to display your college name and format it using format specifiers.
Source code:
# include<stdio.h>
# include<conio.h>
void main()
clrscr();
printf("\n\n\n\t\tRVS Padmavathy College of Engineering and Technology");
printf("\n\t\t\tDept. of Computer Science & Engineering");
printf("\n\t\t\t\t\tChennai");
getch();
Output:
Program 2:
Declaring and using variables.
Aim:
Create a program in C to declare variables and print it.
Source code:
Deptartment of Computer Science and Engineering
2
C Lab Manual – CS8261
# include <stdio.h>
# include <conio.h>
void main()
{
int a = 10;
float b = 20.5;
char c = 'C', d[] = "RVS Padmavathy";
clrscr();
printf("\n\na = %d\nb = %f\nc = %c\nd = %s\n",a,b,c,d);
getch();
}
Output:
a = 10
b = 20.500000
c=C
d = RVS Padmavathy
Program 3:
Converting data types.
Aim:
Create a C program to convert data types.
Source code:
Output:
Deptartment of Computer Science and Engineering
3
C Lab Manual – CS8261
Program 4:
Arithmetic operations.
Aim:
Create a program in C to perform arithmetic operations.
Source code:
Output:
Deptartment of Computer Science and Engineering
4
C Lab Manual – CS8261
Program 5:
Relational operations
Aim:
Create a program in C to demonstrate relational operations.
Source code:
Output:
Program 6:
Logical operators
Aim:
Create a program to demonstrate logical operators.
Source code:
Deptartment of Computer Science and Engineering
5
C Lab Manual – CS8261
Output:
Program 7:
Bitwise operators.
Aim:
Create a program in C to demonstrate bitwise operators.
Source code:
Deptartment of Computer Science and Engineering
6
C Lab Manual – CS8261
Output:
Program 8:
Increment & Decrement operator
Aim:
Create a program in C to perform increment and decrement operations.
Source code:
Output:
Deptartment of Computer Science and Engineering
7
C Lab Manual – CS8261
Program 9:
Sizeof() function
Aim:
Create a program in C to use sizeof() function.
Source code:
Output:
Program 10:
Accepting characters using getchar() function from keyboard and display it using putchar().
Aim:
Create a program in C to accept characters from key board and display it.
Source code:
Deptartment of Computer Science and Engineering
8
C Lab Manual – CS8261
Output:
Program 11:
Accepting characters using getche() ant getch() then display it using putch().
Aim:
Create a program in C to accept characters using getche() and getch() functions then display it using
putch() function.
Source code:
Deptartment of Computer Science and Engineering
9
C Lab Manual – CS8261
Output:
Program 12:
Count number of variables received by scanf() function.
Aim:
Create a program in C to count number of variables received by scanf() function.
Source code:
Output:
Deptartment of Computer Science and Engineering
10
C Lab Manual – CS8261
Program 13:
Demonstrate gets() and puts() functions.
Aim:
Create a program in C to accept and display captions using gets() and puts() functions.
Source code:
Output:
Program 14:
Demonstrate cgets() and cputs().
Aim:
Create a program in C to accept and display strings using cgets() and cputs() functions.
Deptartment of Computer Science and Engineering
11
C Lab Manual – CS8261
Source code:
Output:
Program 15:
Check equivalence of two numbers using if structure.
Aim:
Create a program in C to check equivalence of two numbers using if structure.
Source code:
Output:
Deptartment of Computer Science and Engineering
12
C Lab Manual – CS8261
Program 16:
Find biggest of two numbers using if – else structure.
Aim:
Create a program in C to find biggest of two numbers using if – else structure.
Source code:
Output:
Program 17:
Find biggest of three numbers using nested if structure.
Aim:
Create a program in C to find biggest of three numbers using nested if structure.
Source code:
Deptartment of Computer Science and Engineering
13
C Lab Manual – CS8261
Output:
Program 18:
Create a report card using if – else – if ladder using the following constraints.
Average Grade Result
<50 Fail Fail
Pass all the subjects and average Second Pass
>=50 and <60
Pass all the subjects and average First Pass
>=60 and <75
Pass all the subjects and average Distinction Pass
>=75 and <90
Pass all the subjects and average Honors Pass
>=90
Aim:
Deptartment of Computer Science and Engineering
14
C Lab Manual – CS8261
Create a program in C to find grade and result using if - else – if structure.
Source code:
Deptartment of Computer Science and Engineering
15
C Lab Manual – CS8261
Output:
Deptartment of Computer Science and Engineering
16
C Lab Manual – CS8261
Program 19:
Demonstrate case structure.
Aim:
Create a program in C to perform basic arithmetic operations using switch case structure.
Source code:
Output:
Deptartment of Computer Science and Engineering
17
C Lab Manual – CS8261
Program 20:
Find the roots of a quadratic equation.
Aim:
Create a program in C to find roots of a quadratic equation.
Source code:
Output:
Deptartment of Computer Science and Engineering
18
C Lab Manual – CS8261
Program 21
Display first n even numbers.
Aim:
Create a program in C to display first n even numbers
Source code:
Output:
Program 22
Display number triangle, nested for loop.
Aim:
Create a program in C to display number triangle.
Source code:
Deptartment of Computer Science and Engineering
19
C Lab Manual – CS8261
Output:
Program 23
Display number pyramid
Aim:
Create a program in C to display number pyramid.
Source code:
Deptartment of Computer Science and Engineering
20
C Lab Manual – CS8261
Output
Program 24
Factorial using while structure.
Aim:
Create a program in C to find factorial of a given number using while structure.
Source code:
Deptartment of Computer Science and Engineering
21
C Lab Manual – CS8261
Output:
Program 25
Sum of digits using do- while
Aim:
Create a program in c to calculate sum of digits of a given number.
Source code:
Deptartment of Computer Science and Engineering
22
C Lab Manual – CS8261
Output:
Program 26
Sum of n numbers using do while- while structure.
Aim:
Create a program in C to add given set of numbers.
Source code:
Output:
Deptartment of Computer Science and Engineering
23
C Lab Manual – CS8261
Program 27
Search prime or not
Aim:
Create a C program to check the given number is prime or not.
Source code:
Output:
Program 28
Find the sum of the following series
Exp(x) = 1 + x/1! + x2/2! + x3/3! + ………. + xn/n!
Deptartment of Computer Science and Engineering
24
C Lab Manual – CS8261
Aim:
Create a program in C to evaluate exponential series.
Source code:
Output:
Program 29
Find the sum of the following series
Aim:
Create a program in C to find the sine value.
Deptartment of Computer Science and Engineering
25
C Lab Manual – CS8261
Source Code:
Output:
Program 30
Find the sum of the following series
Aim:
Create a program in C to find cos value.
Deptartment of Computer Science and Engineering
26
C Lab Manual – CS8261
Source code:
Output:
Program 31
Print the given number in reverse order.
Aim:
Create a program in C to print the given number in reverse order.
Source code:
Deptartment of Computer Science and Engineering
27
C Lab Manual – CS8261
Output:
Program 32
Find sum of the following series.
1 + ½ + 1/3 + ¼ + …….. + 1/n.
Aim:
Create a program in C to find the sum of series.
Source code:
Deptartment of Computer Science and Engineering
28
C Lab Manual – CS8261
Output:
Program 33
Convert octal number into decimal number.
Aim:
Create a program in C to convert octal number into decimal number.
Source code:
Output:
Program 34
Find the length, reverse and Check palindrome of the given string
Aim:
Create a program in C to find length, reverse and check the given string is palindrome or not.
Source code:
Deptartment of Computer Science and Engineering
29
C Lab Manual – CS8261
Output:
Program 35
Count vowels, consonants, words and blank space of a line of string.
Aim:
Create a program in C to count vowels, consonants, words and blank space of a line of string.
Source code:
Deptartment of Computer Science and Engineering
30
C Lab Manual – CS8261
Output:
Program 36
Substring detection and count in a line of text.
Aim:
Create a program in C to check the substring is present in a main string.
Source code:
Deptartment of Computer Science and Engineering
31
C Lab Manual – CS8261
Output:
Deptartment of Computer Science and Engineering
32
C Lab Manual – CS8261
Program 37
Substring removal.
Aim:
Create a program in C to find a substring and remove it from the main string.
Source code:
Deptartment of Computer Science and Engineering
33
C Lab Manual – CS8261
Deptartment of Computer Science and Engineering
34
C Lab Manual – CS8261
Output:
Program 38
NCR using recursion
Aim:
Create a program in C to find NCR value.
Source code:
Deptartment of Computer Science and Engineering
35
C Lab Manual – CS8261
Output:
Program 39
Find GCD of two numbers.
Aim:
Create a program in C to find GCD of two numbers.
Source code:
Deptartment of Computer Science and Engineering
36
C Lab Manual – CS8261
Output:
Program 40
Fibonacci series
Deptartment of Computer Science and Engineering
37
C Lab Manual – CS8261
Aim:
Create a program in C to display Fibonacci series.
Source code:
Output:
Program 41
Perform matrix addition and subtraction
Aim:
Create a program in C to perform matrix addition and subtraction.
Deptartment of Computer Science and Engineering
38
C Lab Manual – CS8261
Source code:
Deptartment of Computer Science and Engineering
39
C Lab Manual – CS8261
Output:
Program 42
Matrix multiplication
Aim:
Create a program in C to do matrix multiplication.
Source code:
Deptartment of Computer Science and Engineering
40
C Lab Manual – CS8261
Deptartment of Computer Science and Engineering
41
C Lab Manual – CS8261
Output:
Program 43
Matrix transpose
Aim:
Create a program in C to transpose a matrix.
Program:
Deptartment of Computer Science and Engineering
42
C Lab Manual – CS8261
Output:
Program 44
Determinant of a matrix
Aim:
Create a program in C to find determinant of a matrix.
Source code:
Output:
Deptartment of Computer Science and Engineering
43
C Lab Manual – CS8261
Program 45
Insertion sort
Aim:
Create a program to do insertion sort
Source code:
Output:
Deptartment of Computer Science and Engineering
44
C Lab Manual – CS8261
Program 46
Bubble sort
Aim:
Create a program in C to do bubble sort.
Source code:
Output:
Deptartment of Computer Science and Engineering
45
C Lab Manual – CS8261
Program 47
Linear search
Aim:
Create a program in C to search a number using linear search method.
Source code:
Output:
Deptartment of Computer Science and Engineering
46
C Lab Manual – CS8261
Program 48
Functions without arguments and without return value
Aim:
Create a program in C to display your college name using function.
Source code:
Output:
Program 49
Functions with arguments and without return type.
Aim:
Create a program in C to add two numbers using function.
Source code:
Deptartment of Computer Science and Engineering
47
C Lab Manual – CS8261
Output:
Program 50
Function without arguments with return value.
Aim:
Create a program in C to multiply two numbers using function.
Source code:
Deptartment of Computer Science and Engineering
48
C Lab Manual – CS8261
Output:
Program 51:
Functions with arguments with return values.
Aim:
Create a program in C to divide two numbers using functions.
Source code:
Output:
Deptartment of Computer Science and Engineering
49
C Lab Manual – CS8261
Program 52
Call by reference.
Aim:
Create a program in C to swap numbers using function.
Source code:
Output:
Enter two numbers : 10 20
Before swap x = 10 y = 20
After swap x = 20 y = 10
Program 53
Recursion – Factorial.
Aim:
Create a program in C to find factorial of a number.
Source code:
Deptartment of Computer Science and Engineering
50
C Lab Manual – CS8261
Output:
Program 54
Evaluate the expression a = b++ + ++b
Aim:
Create a program in C to evaluate the above expression.
Source code:
Deptartment of Computer Science and Engineering
51
C Lab Manual – CS8261
Output:
Program 55
a = 5 <= 8 && 6 != 5
Aim:
Create a program in C to solve the expression a = 5 <= 8 && 6 != 5.
Source code:
Output:
Program 56
Function as an argument
Aim:
Create a program in C to use a function as an argument of another function.
Source code:
Deptartment of Computer Science and Engineering
52
C Lab Manual – CS8261
Output:
Program 57
Function with operators
Aim:
Create a program in C to perform function with operators + and -.
Source code:
Deptartment of Computer Science and Engineering
53
C Lab Manual – CS8261
Output:
Program 58
Strlen()
Aim:
Create a program in C to use strlen().
Source code:
Deptartment of Computer Science and Engineering
54
C Lab Manual – CS8261
Output:
Program 59
Strcpy().
Aim:
Create a program in C for strcpy().
Source code:
Output:
Deptartment of Computer Science and Engineering
55
C Lab Manual – CS8261
Program 60
Strcmp()
Aim:
Create a program in C for comparing two strings.
Source code:
Output:
Deptartment of Computer Science and Engineering
56
C Lab Manual – CS8261
Program 61
Strlwr() & strupr().
Aim:
Create a program in C for strlwr() & strupr().
Source code:
Output:
Program 62
Strcat()
Aim:
Create a program in C for strcat().
Source code:
Deptartment of Computer Science and Engineering
57
C Lab Manual – CS8261
Output:
Program 63
Strrev().
Aim:
Create a program in C for strrev().
Source code:
Output:
Deptartment of Computer Science and Engineering
58
C Lab Manual – CS8261
Program 64
Sample program using pointer.
Aim:
Create a program in C to access pointer variable and its address.
Source code:
Output:
Enter two numbers : 5 10
Value of a =5
Value of b = 10
Sum of a and b : 15
Value of x =5
Deptartment of Computer Science and Engineering
59
C Lab Manual – CS8261
Address of x = 65518
Value of y = 10
Address of y = 65516
Sum of x and y : 15
Program 65
Sum of N numbers using pointers.
Aim:
Create a program in C to sum a set of numbers.
Source code:
Output:
Sum of the array : 55
Program 66
Pointers and string.
Aim:
Create a program in C to print a pointer char variable.
Source code:
Deptartment of Computer Science and Engineering
60
C Lab Manual – CS8261
Output:
Enter your name : John T Mesia Dhas
Given name : John T Mesia Dhas
Life is beautiful
Program 67
Structures.
Aim:
To create a C program for structure.
Source code:
Output:
Deptartment of Computer Science and Engineering
61
C Lab Manual – CS8261
Program 68
Structure with arrays.
Aim:
To create a program in C for Employee details using structure with arrays.
Source code:
Output:
Deptartment of Computer Science and Engineering
62
C Lab Manual – CS8261
Program 69
Structure with pointer.
Aim:
Create a program in C to demonstrate structure with pointer
Source code:
Deptartment of Computer Science and Engineering
63
C Lab Manual – CS8261
Output:
Program 70
Structure with function.
Aim:
Create a program in C to demonstrate structure with function.
Source code:
Deptartment of Computer Science and Engineering
64
C Lab Manual – CS8261
Output:
Program 71
Union
Aim:
Create a program in C to demonstrate union.
Source code:
Deptartment of Computer Science and Engineering
65
C Lab Manual – CS8261
Output:
Program 72
Preprocessor
Aim:
Create a program in C to demonstrate preprocessor.
Source code:
Deptartment of Computer Science and Engineering
66
C Lab Manual – CS8261
Output:
Deptartment of Computer Science and Engineering
67
C Lab Manual – CS8261
Deptartment of Computer Science and Engineering
68
C Lab Manual – CS8261
Deptartment of Computer Science and Engineering
69
C Lab Manual – CS8261
Deptartment of Computer Science and Engineering
70
C Lab Manual – CS8261
Deptartment of Computer Science and Engineering
71
C Lab Manual – CS8261
Deptartment of Computer Science and Engineering
72
C Lab Manual – CS8261
Deptartment of Computer Science and Engineering
73
C Lab Manual – CS8261
Deptartment of Computer Science and Engineering
74
C Lab Manual – CS8261
Deptartment of Computer Science and Engineering
75
C Lab Manual – CS8261
Deptartment of Computer Science and Engineering
76
C Lab Manual – CS8261
Deptartment of Computer Science and Engineering
77
C Lab Manual – CS8261
Deptartment of Computer Science and Engineering
78
C Lab Manual – CS8261
Deptartment of Computer Science and Engineering
79
C Lab Manual – CS8261
Deptartment of Computer Science and Engineering
80
C Lab Manual – CS8261
Deptartment of Computer Science and Engineering
81
C Lab Manual – CS8261
Deptartment of Computer Science and Engineering
82
C Lab Manual – CS8261
Deptartment of Computer Science and Engineering
83
C Lab Manual – CS8261
Deptartment of Computer Science and Engineering
84
C Lab Manual – CS8261
Deptartment of Computer Science and Engineering
85
C Lab Manual – CS8261
Deptartment of Computer Science and Engineering
86
C Lab Manual – CS8261
Deptartment of Computer Science and Engineering
87
C Lab Manual – CS8261
Deptartment of Computer Science and Engineering
88
C Lab Manual – CS8261
Deptartment of Computer Science and Engineering
89
C Lab Manual – CS8261
Deptartment of Computer Science and Engineering
90
C Lab Manual – CS8261
Deptartment of Computer Science and Engineering
91