0% found this document useful (0 votes)
29 views35 pages

C Programming Final Record - Bca - 5

The document contains details about a practical record for C programming subject of a student studying in Siri PSG Arts and Science College for Women. It includes contents, staff signatures and 10 practical programs done by the student on topics like calculating sum, average and standard deviation of numbers, finding prime numbers, binary conversion, matrix multiplication using functions, binomial coefficient and others.

Uploaded by

Kannan Thenmozhi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views35 pages

C Programming Final Record - Bca - 5

The document contains details about a practical record for C programming subject of a student studying in Siri PSG Arts and Science College for Women. It includes contents, staff signatures and 10 practical programs done by the student on topics like calculating sum, average and standard deviation of numbers, finding prime numbers, binary conversion, matrix multiplication using functions, binomial coefficient and others.

Uploaded by

Kannan Thenmozhi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 35

SIRI PSG ARTS AND SCIENCE COLLEGE FOR WOMEN

(Affiliated To Periyar University, Salem - 11)


TIRUCHENGODE ROAD, SANKARI-
637301

DEPARTMENT OF COMPUTER APPLICATION


Bachelor of Computer Application

PRACTICAL RECORD

C-PROGRAMMING

PAPER CODE:

21UCAP01

NAME: _

REG.NO:

FIRST YEAR (I- SEMESTER)

(2021-2022)
SIRI PSG ARTS AND SCIENCE COLLEGE FOR WOMEN
(Affiliated To Periyar University, Salem - 11)
TIRUCHENGODE ROAD, SANKARI-637301

CERTIFICATE

Certified that this is a bonafide record of practical work done by the candidate
Miss/ Mrs. in the computer laboratory during the year
2021 - 2022, Siri PSG Arts and Science College for Women, Sankari.

Staff- in Charge Head of the Department

Submitted for the university practical Examination held on

Internal Examiner External Examiner


CONTENTS

STAFF
S.NO DATE TITLE PAGE NO
SIGNATURE
CALCULATE THE SUM, AVERAGE
01
AND STANDARD DEVIATION
PRIME NUMBERS UP TO A GIVEN
02
NUMBER
DECIMAL NUMBER INTO BINARY
03
CONVERSION
MULTIPLY TWO MATRICES USING
04
FUNCTIONS
BINOMIAL CO-EFFICIENT USING
05
FUNCTIONS
WHETHER A GIVEN WORD IS A
06
PALINDROME OR NOT
BINARY SEARCH TO FIND NAME
07
IN ALIST OF NAMES
ARRANGE NUMBERS IN
08
ASCENDING ORDER
STUDENTS MARK SHEET USING
09
AN ARRAY OF STRUCTURES
COUNT OF ALPHABETS, SPECIAL
10 CHARACTERS AND WORDS INA
LINE OF TEXT USING FILE
EX.NO:1
CALCULATE THE SUM, AVERAGE AND
DATE: STANDARD DEVIATION

AIM:
To write a C program to find Sum, Average and Standard deviation from a given set of numbers.

ALGORITHM:

STEP 1: Start the Program.

STEP 2: Declare the required variables.

STEP 3: Calculate sum, average and standard deviation using formulas.

STEP 4: Display the values.

STEP 5: Stop the Program.


CODING:

#include <stdio.h>
#include<math.h>
#define MAXSIZE 10
void main()
{
float
X[MAXSIZE]; int
i,n;
float avg,var,std,sum=0,sum1=0;
clrscr();
printf(“\n\n\t\t SUM AVERAGE AND STANDARD DEVIATION”);
printf(“\n\n\t\t
***************************”);
printf(“\n\n Enter tha value of n:”);
scanf(“%d”,&n);
printf(“\n\n Enter %d real number\n”,n);
for(i=0;i<n;i++)
{
scanf(“%f”,&X[i]);
}
for(i=0;i<n;i++)
{
sum=sum+X[i];
}
avg=sum/(float)n;
for(i=0;i<n;i++)
{
sum1=sum1+pow((X[i]-avg),2);
}
var=sum1/(float)n;
std=sqrt(var);
printf(“Sum of all elemnts=%2f\n”,sum);
printf(“Average of all elemnts=%2f\n”,avg);
printf(“Standard deviation=%2f\n”,std);
getch();
}
OUTPUT:

SUM AVERAGE AND STANDRD DEVIATION


*******************************************

*********** Enter the value of n: 4

Enter 4 real number


2.3
4.5
3.4
2.6
Sum of all elements=11.180000
Average of all elements=0.725000
Standard deviation=0.851469

RESULT:
Thus the program has been executed successfully and output is verified.
EX.NO: 2
PRIME NUMBERS UP TO A GIVEN NUMBER
DATE:

AIM:
To write a C program to find the prime number from a given list of numbers.

ALGORITHM:

STEP 1: Start the Program.

STEP 2: Declare the required

variables. STEP 3: Get the value of n.

STEP 4: Divide the number i%j=0.

STEP 5: If fact=0 print the number is prime otherwise print the result as not prime.

STEP 6: Print the result.

STEP 7: Stop the Process.


CODING:

#include<stdio.h>
void main()
{
int n,i,fact,j;
clrscr();
printf(“Enter the Number”);
scanf(“%d”,&n);
printf(“Prime Numbers are:\n”);
for(i=1;i<=n;i++)
{
fact=0;
for(j=1;j<=n;j++)
{
if(i%j==0)
fact++;
}
if(fact==2)
printf(“%d”,i)
;
}
getch()
OUTPUT:

Enter the Number 50

Prime Numbers are: 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47

RESULT:

Thus the program has been executed successfully and output is verified.
EX.NO: 3
DECIMAL NUMBER, INTO BINARY CONVERSION
DATE:

AIM:
To write a C program to convert decimal to binary numbers using while statement.

ALGORITHM:

STEP 1: Start the Program.

STEP 2: Declare all the required variables.

STEP 3: Get the value of decimal number between 0 to 100.

STEP 4: Use the statement ‘binary number[i++]=quotient %2’ to store the remaining value as

binary number.

STEP 5: Print the result.

STEP 6: Stop the Process.


CODING:

#include<stdio.h>
#include<conio.h>
void main()
{
long int decimal number,remainder,quotient; int
binary Number[100],i=1,j;
clrscr();
printf(“\t\t\t TO CONVERT DECIMAL TO BINARY\n”);
printf(“\t\t\t
*********************************************”);
printf(“\n Enter any decimal number:\n”);
scanf(“%1d”,&decimal number);
quotient=decimal number;
while(quotient!=0)
{
binaryNumber[i++]=quotient % 2;
quotient = quotient / 2;
}
printf(“\nEquivalent binary value of decimal number %d:”,decimalnumber);

for(i-1;j>0;j--)
printf(“%d”,binaryNumber[j]);
getch();
}
OUTPUT:

TO CONVERT DECIMAL TO BINARY


***********************************

Enter any decimal number: 50

Equivalent binary value of decimal number 50: 110010

RESULT:

Thus the program has been executed successfully and output is verified.
EX.NO: 4
MULTIPLY TWO MATRICES USING FUNCTIONS
DATE:

AIM:

To write a C program to multiply two matrices using functions.

ALGORITHM:

STEP 1: Start the program.

STEP 2: Declare all the required variables.

STEP 3: Get the values of first matrix and second matrix.

STEP 4: Multiply the values of first matrix and second

matrix. STEP 5: Print the result for the matrix

multiplications.

STEP 6: Stop the process.


CODING:

#include<stdio.h>
#include<conio.h>
void read_arr(int a[10][10],int row,int col)
{
int i,j;
clrscr();
for(i=1;i<=row;i++)
{
for(j=1;j<=col;j++)
{
printf(“Enter Element %d %d : “,i,j);
scanf(“%d”,&a[i][j]);
}
}
}
void mul_arr(int m1[10][10],int m2[10][10],int m3[10[10],int row,int col)
{
int i,j,k;
for(i=1;i<=row;i++)
{
for(j=1;j<=col;j++)
{
for(k=1;k<=row;k++)
{
m3[i][j]=m3[i][j]+(m1[i][k]*m2[k][j]);
}
}
}
}
void print_arr(int m[10][10],int row,int col)
{
int i,j;
for(i=1;i<=row;i++)
{
for(j=1;j<=col;j++)
{
printf(“%d”,m[i][j]);
}
printf(“\n”);
}
void main()
{
int m1[10][10],m2[10][10],m3[10][10],row,col;
clrscr();
printf(“Enter number of rows :”);
scanf(“%d”,&row);
printf(“Enter number of columns :”);
scanf(“%d”,&col);
read_arr(m1,row,col);
read_arr(m2,row,col);
mul_arr(m1,m2,m3,row,col);
printf_arr(m3,row,col);
getch();
}
OUTPUT:

ENTER NUMBER OF ROWS: 2

ENTER NUMBER OF COLUMNS: 2

ENTER ELEMENT 1.1: 2

ENTER ELEMENT 1.2: 1

ENTER ELEMENT 2.1: 4

ENTER ELEMENT 2.2: 3

ENTER ELEMENT 1.1: 5

ENTER ELEMENT 1.2: 6

ENTER ELEMENT 2.1: 7

ENTER ELEMENT 2.2: 8

17 20

41 48

RESULT:
Thus the program has been executed successfully and output verified
EX.NO: 5
BIONOMIAL CO-EFFICIENT USING FUNCTIONS
DATE:

AIM:

To write a C program to find the binomial co efficient by using functions.

ALGORITHM:

STEP 1: Start the program.

STEP 2: Declare all the required

variables. STEP 3: Get the value of n and

r.

STEP 4: Generate the binomial co efficient using formulas.

STEP 5: Print the result.

STEP 6: Stop the process


CODING:

#include<stdio.h>
#include<conio.h>
int fact(int);
void main()
{
int n,r,ncr;
clrscr();
printf(“\n Enter n and r:”);
scanf(“%d%d”,&n,&r);
ncr=fact(n)/(fact(n-r)*fact(r));
printf(“\n Binomial co-efficient : %d”,ncr);
getch();
}
int fact(int x)
{
if(x==0)
return 1;
else
return(x*fact(x-1));
}
OUTPUT:

Enter the values for n and r:

The Binomial coefficient is: 10

RESULT:

Thus the program has been executed successfully and output is verified.
EX.NO: 06
WHETHER A GIVEN WORD IS A PALINDROME OR NOT
DATE:

AIM:

To write a c program to check whether a given word is a palindrome or not.

ALGORITHM:

STEP 1: Start the program.

STEP 2: Declare all the required variables in array.

STEP 3: Get the value of the string.

STEP 4: Check whether the given string ins palindrome or not.

STEP 5: Print the result.

STEP 6: Stop the program


CODING:

#include <stdio.h>
#include<string.h>
void main()
{
char a[100],b[100];
clrscr();

printf(“Enter a string to check if it is a palindrome\n”);


gets(a);

strcpy(b,a);
strrev(b);

if(strcmp(a,b) = = 0)
printf(“Entered string is a palindrome.\n”);
else
printf(“Entered string is not a palindrome.\n”);

getch();
}
OUTPUT:

Enter a string to check if it is a

palindrome: Malayalam

Enter string is a palindrome

RESULT:
Thus the program has been executed successfully and output is verified.
EX.NO: 7
BINARY SEARCH TO FIND NAME IN A LIST OF NAMES
DATE:

AIM:

To write a C program to find a particular name in a list of names by using Binary Search.

ALGORITHM:

STEP 1: Start the program.

STEP 2: Declare the required variables in

array. STEP 3: Get the names in ascending

order.

STEP 4: Search the position of the name in the list using strcmp function.

STEP 5: Print the result.


CODING:

#include<stdio.h>
#include<string.h>
void main()
{
int i,n,low,high,mid;
char a[50][50],key[20];
clrscr();
printf(“Enter the number of names to be added\n”);
scanf(“%d”,&n);
printf(“Enter the name in ascending order\n”);
for(i=0;i<n-1;i++)
{
scanf(%s”,&a[i]);
}
printf(“\n”);
printf(“Enter the name to be searched\n”);
scanf(“%s”,&key);
low=0;
high=n-1;
while(low<=high)
{
mid=(low+high)/2;
if(strcmp(key,a[mid])==0)
{
printf(“key found at the position %d\n”,mid+1);
getch();
exit(0);
}
else if(strcmp(key,a[mid])>0)
{
high=high;
low=mid+1;
}
else
{
low=low;
high=mid-1;
}
}
printf(“name not found\n”);
}
OUTPUT:

Enter the number of names to be added:

Enter the name in ascending order:

Gokila priya

Devika

Bharathi

Enter the name to be

searched Devika

Key found at the position:

RESULT:

Thus the program has been executed successfully and output is verified.
EX.NO: 8
ARRANGE NUMBERS IN ASCENDING ORDER
DATE:

AIM:

To write a C program for ascending of given n number.

ALGORITHM:

STEP 1: Start the program.

STEP 2: Declare all required variables.

STEP 3: Get the values of n and all elements for array.

STEP 4: Compare each element with each other for arrange the number in ascending order.

STEP 5: Print the result.

STEP 6: Stop the process.


CODING:

#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,a,n,number[30];
clrscr();
printf(“\t\t SORTING THE LIST OF GIVEN NUMBERS \n”);
printf(“\t\t
***************************************************\
n”); printf(“Enter the value of N:”);
scanf(“%d”,&n);
printf(“\n Enter the %d numbers:\n”,n);
for(i=0;i<n;++i)
scanf(“%d”,&number[i]);
for(i=0;i<n;++i)
{
for(j=i+1;j<n;++j)
{
if(number[i]>number[j])
{
a=number[i];
number[i]=number[j];
number[j]=a;
}
}
}
printf(“The numbers are arranged in ascending order:\n”);
for(i=0;i<n;++i)
printf(“%d\n”,number[i]);
getch();
}
OUTPUT:

SORTING THE LIST OF GIVEN NUMBERS


******************************************

Enter the value of n : 5

Enter the 5 numbers:

7
3
5
2
8

The numbers are arranged in ascending order:

2
3
5
7
8

RESULT:
Thus the program has been executed successfully and output is verified.
EX.NO: 9
STUDENT’S MARK SHEET USING AN ARRAY OF
DATE: STRUCTURES

AIM:

To write a C program to design the mark sheet using structures.

ALGORITHM:

STEP 1: Star the program.

STEP 2: Declare all the required

variables. STEP 3: Get the values for

required fields.

STEP 4: Calculate total, average, secured class and status form the values.

STEP 5: Display the result.

STEP 6: Stop the process.


CODING:

#include<stdio.h>
#include<conio.h>
#include<string.h>
struct mark_sheet
{
char name[20];
long int rollno;
int marks[10];
int total;
float average;
char rem[10];
char c1[20];
}
students[100];
void main()
{
int a,b,n,flag=1;
char ch; clrscr();
printf(“How many students : \n”);
scanf(“%d”,&n); for(a=1;a<=n;+
+a)
{
printf(“\n\n Enter the details of %d students :”, n-a+1);
printf(“\n\n Enter student %d Name : “,a);
scanf(“%s”,students[a].name);
printf(“\n\n Enter student %d Roll Number :”,a);
scanf(“%1d”,&students[a].rollno);
students[a].total=0;
printf(“\n Enter the class of the students:”);
scanf(“%s”,students[a].c1); for(b=1;b<=5;+
+b)
{
printf(“\n\n Enter the mark of subject-%d :”,b);
scanf(“%d”,&students[a].marks[b]);
students[a].total+=students[a].marks[b];
if(students[a].marks[b]<40)
flag=0;
}
students[a].average=students[a].total/n;
if(flag==1)
strcpy(students[a].rem, “pass”);
else
strcpy(students[a].rem, “Fail”);
flag=1;
}
for(a=0;a<=n;++a)
{
clrscr();
printf(“\n\n\t\t\t\t Mark Sheet\n”);
printf(“\n Name of Student:%s”, students[a].name);
printf(“\t\t\t\t Roll No: %1d”, students[a].rollno); printf(“\n
“)
; for(b=1;b<=5;b++)
{
printf(“\n\n\t Subject %d \t\t :\t%d”,b,students[a].marks[b]);
}
printf(“\n\n \
n”); printf(“\n\n Total Marks : %d”, students[a].total); printf(“\t\
t\t\t Average Marks : %5.2f”, students[a].average); printf(“\n\n
Class : %s”, students[a].c1);
printf(“\t\t\t\t Status : %s”, students[a].rem);
printf(“\n\n\n\t\t\t\t Press Y for continue…”);
ch=getchar();
if((ch==’y’)||(ch==’Y’))
continue;
}
getch()
}
OUTPUT:

How many students: 2


Enter the Details of 2 Students:

Enter Student 1 Name : Anusuya


Enter Student 1 Roll Number : 23456
Enter the Class of the Students: CS
Enter the Marks of Subject -1 : 58
Enter the Marks of Subject -2 : 98
Enter the Marks of Subject -3 : 68
Enter the Marks of Subject -4 : 85
Enter the Marks of Subject -5 : 95

Enter the Details of 1 Students:


Enter Student 2 Name : Samyuktha
Enter Student 2 Roll Number :
34567 Enter the Class of the
Students: CS Enter the Marks of
Subject -1 : 59 Enter the Marks of
Subject -2 : 68 Enter the Marks of
Subject -3 : 64 Enter the Marks of
Subject -4 : 87 Enter the Marks of
Subject -5 : 85

RESULT:

Thus the program has been executed successfully and output is verified.
EX.NO: 10
COUNT OF ALPHAPETS, SPECIAL
DATE: CHARCTERS AND WORDS IN A LINE OF
TEXT USING FILE

AIM:

To Write a C program to find the number of alphabets, special characters and word using
file.

ALGORITHM:

STEP 1: Start the process.

STEP 2: Declare all the required

variables. STEP 3: Get the input as line of

text.

STEP 4: Pick each character from the text.

STEP 5: If it is alphabet then check it is anyone of the

vowel. STEP 6: Then increment the variables vowel.

STEP 7: If it is alphabet then check without vowel character.

STEP 8: Then increment the variables constant.

STEP 9: If it is value then check anyone of digits then increment the variables digits.

STEP 10: If it is text the check anyone of special character and increment it.

STEP 11: If it is text the check anyone of word and increment the variable word.

STEP 12: Print the result.


CODING:

#include<stdio.h>
void main()
{
FILE*p;
char ch;
int w=1;
int chh=0;
int no=0;
int sy=0;
clrscr();
p=fopen(“file.txt”,
“r”); if(p==NULL)
{
printf(“file not found”);
}
else
{
ch=fgetc(p);
while(ch!=EOF)
{
printf(“%c”,ch);
if(ch==’ ‘||ch==’\
n’)
{
w++;
}
if(ch>=’0’&&ch<=’9’
) no++;
else if(ch>=’a’&&ch<=’z’)
chh++;
else sy++;
ch=fgetc(p);
}
printf(“\n Words in a file are=%d”,w);
printf(“\n no of char=%d”,chh);
printf(“\n no of numbers=%d”,no);
printf(“\n no of sybols=%d”,sy);
}
fclose(p);
getch();
}
OUTPUT:

Hai how are you 1?

Words in a file are

=4 No of chars =12

No of

numbers=1 No

of symbols=5

RESULT:

Thus the program has been executed successfully and output is verified.

You might also like