C Lab Manual Final 2022-ArunSir
C Lab Manual Final 2022-ArunSir
BASIC C PROGRAMS
EX.NO:1a
PRINTING STUDENT NAME AND COLLEGE NAME
DATE:
AIM:
To write a program in C to display the student name and college name.
ALGORITHM:
Step 3: Display the student name and college name using printf statement.
PROGRAM:
#include<stdio.h>
#include<coinio.h>
void main()
{
printf(“ANBU\n”);
printf(“RVSCET”);
getch();
}
OUTPUT:
ANBU
RVSCET
RESULT:
Thus the C program for displaying the names has been executed successfully and
output is verified.
EX.NO:1b
AREA CALCULATION OF VARIOUS SHAPES
DATE:
AIM:
ALGORITHM:
PROGRAM:
#include<stdio.h>
#include<conio.h>
void main()
{
float r,l,b,s,h;
float circle,rectangle,square,triangle;
printf("enter the numbers:");
scanf("%f%f%f%f%f",&r,&l,&b,&s,&h);
circle=(22*r*r)/7;
printf("\narea of the circle is:%f",circle);
rectangle=l*b;
printf("\narea of the rectangle is:%f",rectangle);
square=s*s;
printf("\narea of the square is:%f",square);
triangle=(b*h)/2;
printf("\narea of the triangle is:%f",triangle);
getch();
}
OUTPUT:
RESULT:
Thus a C program to find the area of various geometric shapes has been executed
successfully and got verified.
EX.NO:1c
AIM:
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
float a,b,c,d,r1,r2;
clrscr();
printf(“\nEnter the values of a,b and c”);
scanf(“%f%f%f”,&a,&b,&c);
d=b*b-4*a*c;
r1=(-b+sqrt(d))/(2*a);
r2=(-b-sqrt(d))/(2*a);
printf(“The root1 and root2 of a=%f b=%f c=%f is \n %f \n %f“,a,b,c,r1,r2);
getch();
}
Output:
Enter the values of a,b and c
7
35
9
The root1 and root2 of a=7 b=35 c=9 is
-0.271932
-4.728068
RESULT:
Thus the program to find the root of a quadratic equation has been executed successfully
and output is verified.
EX.NO:1d
AIM:
To write a C Program to find the given number is odd or even.
ALGORITHM:
#include<stdio.h>
#include<conio.h>
void main()
{
int number;
clrscr();
printf(“\nEnter the number”);
scanf(“%d”,&number);
if(number%2==0)
{
printf(“\nThe number is even number”);
}
else
{
printf(“\nThe number is odd number”);
}
getch();
}
OUTPUT:
Enter the number
5
The number is odd number
Enter the number
4
The number is even number
RESULT:
Thus the program to find the given number is odd or even has been executed
successfully.
EX.NO:1e
FIND THE LARGEST OF THREE NUMBERS
DATE:
AIM:
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
printf(“\nEnter the numbers a,b and c”);
scanf(“%d %d%d”,&a,&b,&c);
if(a>b)
{
if(a>c)
printf(“\n%d is largest number”,a);
else
printf(“\n%d is largest number”,c);
}
else
{
if(b>c)
printf(“\n%d is largest number”,b);
else
printf(“\n%d is largest number”,c);
}
getch();
}
OUTPUT:
RESULT:
Thus the program to find the largest among three numbers has been successfully
executed and output is verified.
EX.NO:1f
MULTIPLICATION TABLE FOR THE GIVEN NUMBER
DATE:
AIM:
ALGORITHM:
#include<stdio.h>
#include<conio.h>
void main()
{
int table;
int i,count;
clrscr();
printf("Enter the number of table you want to print\n");
scanf("%d",&table);
printf("Result:\n");
for(i=1;i<=10;i++)
{
printf("%d * %d =%d\n",i,table,i*table);
}
getch();
}
OUTPUT:
RESULT:
Thus the program for printing multiplication table has been successfully executed and
output is verified.
EX.NO:1g
FIRST N NUMBERS DIVISIBLE BY 5
DATE:
AIM:
To write a program in c to print the first n numbers divisible by 5.
ALGORITHM:
PROGRAM:
#include<stdio.h>
#include<conio.h>
void main()
{
int i,n;
printf("\n Enter the number of terms:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
if(i%5==0)
{
printf("\t%d",i);
}
}
getch( );
}
OUTPUT:
Enter the number of terms: 50
5 10 15 20 25 30 35 40 45 50
RESULT:
Thus a C program to print the first n numbers divisible by 5 has been executed
successfully and output is verified.
EX.NO:1h
PALINDROME USING INTEGERS
DATE:
AIM:
ALGORITHM:
PROGRAM:
#include<stdio.h>
#include<conio.h>
void main()
{
int n,result=0,sum=0,e;
clrscr();
printf("Enter no:");
scanf("%d",&n);
e=n;
while(n>0) {
result =n%10;
sum =sum *10+result;
n=n/10;
} if(e==sum)
printf("It ia a Palindrome");
else
printf("It is not a palindrome");
getch();
}
Output:
Enter no:121
It is a Palindrome
Enter no: 345
It is not a palindrome
RESULT:
Thus the program for checking the palindrome of a given number has been
executed successfully.
EX.NO:1i
CHECKING PRIME NUMBER
DATE:
AIM:
ALGORITHM:
PROGRAM:
#include<stdio.h>
#include<conio.h>
void main()
{
int a,c=0,i,n;
clrscr();
printf(" Enter the no to be checked:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
a=n%i;
if(a==0)
{
c=c+1;
}
}
if(c==2)
{
printf(" It is a prime number");
}
else
{
printf(" It is not a prime number");
}
getch( );
}
OUTPUT:
Enter a no to be checked: 6
It is not a prime number
Enter a no to be checked: 5
It is a prime number
RESULT:
Thus the program for checking the prime number of a given number has been
executed successfully.
EX.NO:1j
FIBONACCI NUMBER
DATE:
AIM:
To create a C program to generate the Fibonacci series for the given number.
ALGORITHM:
#include<stdio.h>
#include<conio.h>
void main()
{
int f,f1=-1,f2=1,x,a;
clrscr();
printf("Enter a no:");
scanf("%d",&n);
for(a=0;a<n;a++)
{
f=f1+f2;
f1=f2;
f2=f;
printf("\n%d",f);
}
getch();
}
OUTPUT:
Enter a no: 5
01123
RESULT:
Thus the C program to generate the Fibonacci series for the given number has been
executed successfully.
EX.NO:1k
ASCENDING/ DESCENDING ORDER
DATE:
AIM:
To create a C program to sort the numbers in ascending and descending order using an
array.
ALGORITHM:
#include<stdio.h>
#include<conio.h>
void main()
{
int a[10],n,i,j,temp;
clrscr();
printf("Enter the no of values");
scanf("%d",&n);
printf("Enter the elements one by one\n");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0;i<n-1;i++)
{
for(j=i+1;j<n;j++)
{
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}}}
printf("\n Ascending order");
for(i=0;i<n;i++)
printf("\t%d",a[i]);
printf("\n Descending order");
for(i=n-1;i>=0;i--)
printf("\t%d",a[i]);
getch();
}
OUTPUT:
RESULT:
Thus the program to sort the number in ascending and descending order has been
executed and verified.
EX.NO:1l
MATRIX ADDITION
DATE:
AIM:
To write a C program to add two matrices using an array.
ALGORITHM:
PROGRAM:
#include<stdio.h>
#include<conio.h>
void main()
{
int a[3][3],b[3][3],c[3][3],i,j;
clrscr();
printf(“Enter the values of Matrix A : \n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
scanf(“%d”,&a[i][j]);
}
}
printf(“Enter the values of Matrix B : \n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
scanf(“%d”,&b[i][j]);
}
}
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
c[i][j]=a[i][j]+b[i][j];
}
}
printf(“Resultant Matrix:\n”);
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf(“%d\t”,c[i][j]);
}
printf(“\n”);
}
getch();
}
OUTPUT:
2 2 2
2 2 2
2 2 2
2 2 2
2 2 2
2 2 2
Resultant Matrix:
4 4 4
4 4 4
4 4 4
RESULT:
Thus the program for addition of two matrices has been executed and verified.
EX.NO:1m
MATRIX MULTIPLICATION
DATE:
AIM:
To write a C program to multiply two matrices using an array.
ALGORITHM:
PROGRAM:
#include<stdio.h>
#include<conio.h>
void main()
{
int a[3][3],b[3][3],c[3][3],i,j,k;
clrscr();
printf(“Enter the values of Matix A : \n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
scanf(“%d”,&a[i][j]);
}
}
printf(“Enter the values of Matix B : \n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
scanf(“%d”,&b[i][j]);
}
}
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
c[i][j]=0;
for(k=0;k<m;k++)
{
c[i][j]=c[i][j]+a[i][k]*b[k][j];
}
}
}
printf(“Resultant Matrix\n”);
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf(“%d\t”,c[i][j]);
}
printf(“\n”);
}
getch();
}
OUTPUT:
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
Resultant Matrix:
2 4 6
8 10 12
14 16 18
RESULT:
Thus the program for multiplication of two matrices has been executed and verified.
EX.NO:1n
PROGRAM TO FIND TRANSPOSE OF MATRIX
DATE:
AIM:
To write a C program to compute the transpose of matrix using an array.
ALGORITHM:
}
Output:
1 2 3
4 5 6
7 8 9
1 4 7
2 5 8
3 6 9
RESULT:
Thus the program to compute transpose of matrix has been executed successfully.
EX.NO:1o
FACTORIAL USING RECURSIVE FUNCTION
DATE:
AIM:
To write a C program to compute the factorial of a given number.
ALGORITHM:
PROGRAM:
#include<stdio.h>
#include<conio.h>
int fact(int);
int main()
{
int a;
clrscr();
printf("\nEnter the number:");
scanf("%d",&a);
printf("The factorial of %d! is %d",a,fact(a));
}
int fact(int x)
{
int f;
if(x==1)
return(1);
else
f=x*fact(x-1);
return(f);
}
OUTPUT:
RESULT:
Thus a C program to find factorial of a given number using recursive function has been
executed successfully and got verified.
2. PROGRAMS USING STRING FUNCTIONS
EX.NO:2a
STRING FUNCTIONS
DATE:
AIM:
ALGORITHM:
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char str[50],str1[50];
int l;
clrscr();
printf("\nEnter the string1:");
gets(str);
printf("\nEnter the string2:");
gets(str1);
l=strlen(str);
printf("Length of the string is :%d\n",l);
strupr(str);
printf("Upper case string is :%s\n",str);
strlwr(str);
strcat(str,str1);
printf("concatenated string is: %s\n",str);
strcpy(str1,str);
printf("Copied string is: %s\n",str1);
strrev(str);
printf("Reversed string is :%s\n",str);
getch();
}
OUTPUT:
RESULT:
Thus the C program for manipulations of strings has been successfully executed and
verified.
EX.NO:2b
PALINDROME USING STRINGS
DATE:
AIM:
ALGORITHM:
PROGRAM:
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char s1[15],s2[15];clrscr( );
printf("\nEnter the string:");
scanf("%s",s1);
strcpy(s2,s1);
strrev(s1);
if(strcmp(s1,s2)==0)
printf("\n The string is palindrome");
else
printf("\n The string is not a palindrome");
getch();
}
OUTPUT:
Enter the string:ece
The string is palindrome
Enter the string:cse
The string is not a palindrome
RESULT:
Thus the C program for palindrome of strings has been successfully executed and
verified.
EX.NO:2c
COUNT THE NUMBER OF VOWELS,CONSONANTS DIGITS AND
DATE: WHITE SPACES PRESENT IN A LINE OF TEXT
AIM:
To write a program in c to accept a line of text and count the number of vowels,
consonants, white spaces and digits present in it.
ALGORITHM:
PROGRAM:
#include<stdio.h>
#include<conio.h>
int main()
{
char line[150];
int i, vowels, consonants, digits, spaces;
clrscr();m
vowels = consonants = digits = spaces = 0;
printf("Enter a line of string: ");
scanf("%[^\n]", line);
for(i=0; line[i]!='\0'; ++i)
{
if(line[i]=='a' || line[i]=='e' || line[i]=='i' ||
line[i]=='o' || line[i]=='u' || line[i]=='A' ||
line[i]=='E' || line[i]=='I' || line[i]=='O' ||
line[i]=='U')
{
++vowels;
}
else if((line[i]>='a'&& line[i]<='z') || (line[i]>='A'&& line[i]<='Z'))
{
++consonants;
}
else if(line[i]>='0' && line[i]<='9')
{
++digits;
}
else if (line[i]==' ')
{
++spaces;
}
}
printf("Vowels: %d",vowels);
printf("\nConsonants: %d",consonants);
printf("\nDigits: %d",digits);
printf("\nWhite spaces: %d", spaces);
getch();
return 0;
}
OUTPUT:
RESULT:
Thus a C program to count vowels, consonants and digits has been executed successfully
and got verified.
3. PROGRAMS USING STRUCTURES AND POINTERS
EX.NO:3a
SWAPPING TWO NUMBERS USING CALL BY VALUE AND CALL
DATE: BY REFENCE
AIM:
To write a C program for swapping of two numbers using call by value and call by
reference.
ALGORITHM:
Call by value:
Step 4: Pass the value of the actual arguments to the formal arguments
Call by reference:
Step 4: Pass the address of the actual arguments to the formal arguments
Call by value:
#include <stdio.h>
#include<conio.h>
int add(int,int);
int main()
int a,b,c;
clrscr();
scanf("%d%d",&a,&b);
c=add(a,b);
printf("\nSum is:%d",c);
int z;
z=x+y;
return(z);
Call by reference:
#include <stdio.h>
#include<conio.h>
void swap(int*,int*);
void main()
{
int x,y;
scanf("%d",&x);
scanf("%d",&y);
swap(&x,&y);
printf("\nx=%d,y=%d",x,y);
int c;
c=*a;
*a=*b;
*b=c;
printf("\nx=%d,y=%d",*a,*b);
}
OUTPUT:
Call by value:
Sum is:13
OUTPUT:
Call by reference:
x=6,y=5
RESULT:
Thus the C program for swapping of two numbers has been executed successfully
and output is verified
EX.NO:3b
MARKSHEET OF ‘N’ STUDENTS USING STRUCTURES
DATE:
AIM:
To create a program to print the mark sheet of ‘n’ student using structures
ALGORITHM:
PROGRAM:
#include<stdio.h>
#include<conio.h>
struct student
{
char name[10][10];
int rollno,m1,m2,m3,total;
};
void main()
{
int num,i,j;
struct student s1[10];
clrscr();
printf("Enter the number of students");
scanf("%d",&num);
for(i=0;i<num;i++)
{
printf("Enter the roll number\n");
scanf("%d",&s1[i].rollno);
printf("Enter the name \n");
scanf("%s",&s1[i].name);
printf("Enter the mark1\n");
scanf("%d",&s1[i].m1);
printf("Enter the mark2\n");
scanf("%d",&s1[i].m2);
printf("Enter the mark3\n");
scanf("%d",&s1[i].m3);
s1[i].total=s1[i].m1+s1[i].m2+s1[i].m3;
}
printf("The details of the mark list is as follows \n");
printf("\nRollno");
printf("\tName ");
printf("\tMark1");
printf("\tMark2");
printf("\tMark3");
printf("\tTotal");
printf("\n");
for(i=0;i<num;i++)
{
printf("\n%d",s1[i].rollno);
printf("\t%s",s1[i].name);
printf("\t%d",s1[i].m1);
printf("\t%d",s1[i].m2);
printf("\t%d",s1[i].m3);
s1[i].total=s1[i].m1+s1[i].m2+s1[i].m3;
printf("\t%d",s1[i].total);
}
getch();
}
OUTPUT:
Enter the number of stuents2
Enter the roll number
4561
Enter the name
Lokesh
Enter the mark198
Enter the mark278
Enter the mark369
Enter the roll number
4562
Enter the name
Mani
Enter the mark188
Enter the mark289
Enter the mark398
The details of the mark list is as follows
Rollno Name Mark1 Mark2 Mark3 Total
4561 Lokesh 98 78 69 245
4562 Mani 88 89 98 275
RESULT:
The program to print the mark sheet of students using Structure has been executed
successfully.
EX.NO:3c
ARRAY USING POINTERS
DATE:
AIM:
To write a “C” Program to print elements of array using pointers
ALGORITHM:
PROGRAM:
#include<stdio.h>
#include<conio.h>
void main()
{
int i,n,x[10];
int *ipa;
clrscr();
printf("Enter the number of elements:\n");
scanf("%d",&n);
printf("Enter the array numbers one by one\n");
for(i=0;i<n;i++)
scanf("%d",&x[i]);
printf("The elements present in the array are\n");
ipa=&x[0];
for(i=0;i<n;i++)
printf("\n%d",*(ipa+i));
getch();
}
OUTPUT:
Enter the number of elements:
4
Enter the array numbers one by one
8201
The elements present in the array are
8201
RESULT:
Thus a C program has been written to print elements of array using pointers.
4. IMPLEMENTATION OF LINEAR SEARCH AND BINARY SEARCH
EX.NO:4a
LINEAR SEARCH
DATE:
AIM:
To write a C program to search the key value in an array using linear search.
ALGORITHM:
Step 1: Start the program
PROGRAM:
#include<stdio.h>
#include<conio.h>
void main()
{
int a[10],i,n,key,f=0;
clrscr();
printf("\n\n LINEAR SEARCH \n\n");
printf("Enter the array limit:");
scanf("%d",&n);
printf("Enter array elements:\n");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
printf("Enter the element to be searched:\n");
scanf("%d",&key);
for(i=0;i<n;i++)
{
if(a[i]==key)
{
printf("Element is found\n");
f=1;
break;
}
}
if(f==0)
{
printf("Element is not found\n");
}
getch();
}
OUTPUT:
LINEAR SEARCH
Enter the array limit:5
Enter array elements:
1
3
5
7
9
Enter the element to be searched: 9
Element is found
LINEAR SEARCH
Enter the array limit 5
Enter array elements:
2
4
6
8
10
Enter the element to be searched: 9
Element is not found
RESULT:
Thus c program to search the key value with an array using linear search has been
executed and output is verified.
EX.NO:4b
BINARY SEARCH
DATE:
AIM:
To write a c program to search a number using binary search.
ALGORITHM:
Step 1: start the program
Step 2: read the element.
PROGRAM:
#include<stdio.h>
#include<conio.h>
int main()
{
int arr[50],i,n,x,flag=0,first,last,mid;
clrscr();
printf("Enter size of array:");
scanf("%d",&n);
printf("\nEnter array element(ascending order)\n");
for(i=0;i<n;++i)
scanf("%d",&arr[i]);
first=0;
last=n-1;
while(first<=last)
{
mid=(first+last)/2;
if(x==arr[mid]){
flag=1;
break;
}
else
if(x>arr[mid])
first=mid+1;
else
last=mid-1;
}
if(flag==1)
printf("\nElement is found at position %d",mid+1);
else
printf("\nElement is not found");
getch();
return 0;
}
OUTPUT:
RESULT:
Thus a c program to search a number using binary search has been executed and
verified.
EX.NO:4c
BINARY SEARCH USING RECURSION
DATE:
AIM:
To write a c program to search a number using binary search using recursion.
ALGORITHM:
Step 1 : Find the middle element of array. using ,
#include <stdio.h>
int main()
printf("-----------------------------------\n");
scanf("%d", &n);
printf(" Input %d numbers of elements in the array in ascending order :\n", n);
for (i = 0; i < n; i++)
scanf("%d", &arr1[i]);
scanf("%d", &md);
low = 0, hg = n - 1;
if (c == 0)
else
return 0;
int binarySearch(int arr1[], int n, int md, int low, int hg)
int mid, c = 0;
if (md == arr1[mid])
{
c = 1;
else
} else
return c;
OUTPUT:
element - 0 : 15
element - 1 : 25
element - 2 : 35
RESULT:
Thus a c program to search a number using binary search using recursion has been
executed and verified.
5. SORTING
EX.NO:5
SELECTION SORT
DATE:
AIM:
ALGORITHM:
Step 3 – swap the first location with the minimum value in the array
PROGRAM:
#include <stdio.h>
int main()
{
int a[100], n, i, j, position, swap;
printf("Enter number of elementsn");
scanf("%d", &n);
printf("Enter %d Numbersn", n);
for (i = 0; i < n; i++)
scanf("%d", &a[i]);
for(i = 0; i < n - 1; i++)
{
position=i;
for(j = i + 1; j < n; j++)
{
if(a[position] > a[j])
position=j;
}
if(position != i)
{
swap=a[i];
a[i]=a[position];
a[position=swap;
}
}
printf("Sorted Array:n");
for(i = 0; i < n; i++)
printf("%dn", a[i]);
return 0;
}
OUTPUT:
RESULT:
Thus a c program to sort the given numbers using selection sort has been executed and
verified successfully.
6. FILE HANDLING (SEQUENTIAL ACCESS)
EX.NO:6a
READING A FILE
DATE:
AIM:
PROGRAM
#include<stdio.h>
void main( )
{
FILE *fp ;
char ch ;
fp = fopen("sample.txt","r") ;
while ( 1 )
{
ch = fgetc ( fp ) ;
if ( ch == EOF )
break ;
printf("%c",ch) ;
}
fclose (fp ) ;
}
OUTPUT:
Sample.txt
Department of CSE
RESULT:
Thus a c program to opens a file in read mode has been executed and verified
successfully.
EX.NO:6b
EMPLOYEE INFORMATION
DATE:
AIM:
PROGRAM:
#include <stdio.h>
void main()
{
FILE *fptr;
int id;
char name[30];
float salary;
fptr = fopen("emp.txt", "w+");/* open for writing */
if (fptr == NULL)
{
printf("File does not exists \n");
return;
}
printf("Enter the id\n");
scanf("%d", &id);
fprintf(fptr, "Id= %d\n", id);
printf("Enter the name \n");
scanf("%s", name);
fprintf(fptr, "Name= %s\n", name);
printf("Enter the salary\n");
scanf("%f", &salary);
fprintf(fptr, "Salary= %.2f\n", salary);
fclose(fptr);
}
OUTPUT:
Enter e id
1
Enter the name
sonoo
Enter the salary
120000
emp.txt
Id= 1
Name= sonoo
Salary= 120000
RESULT:
Thus a c program to store employee information as entered by user from console has
been executed and verified successfully.
RANDOM ACCESS
EX.NO:6c
FSEEK
DATE:
AIM:
To write a C program to set the file pointer to the specified offset and to write data into file
at desired location.
PROGRAM:
#include<stdio.h>
#include<conio.h>
void main(){
FILE *fp;
char c;
clrscr();
fp=fopen("myfile.txt","r");
while((c=fgetc(fp))!=EOF){
printf("%c",c);
}
fclose(fp);
getch();
}
OUTPUT:
Enter e id
myfile.txt
1
Salary= 120000
RESULT:
Thus C program to set the file pointer to the specified offset and to write data into file at
desired location has been executed and verified successfully.
RANDOM ACCESS
EX.NO:6d
FTELL
DATE:
AIM:
To write a C program to returns the current file position of the specified stream and to get
the total size of a file after moving file pointer at the end of file
PROGRAM:
#include <stdio.h>
#include <conio.h>
void main (){
FILE *fp;
int length;
clrscr();
fp = fopen("file.txt", "r");
fseek(fp, 0, SEEK_END);
length = ftell(fp);
fclose(fp);
printf("Size of file: %d bytes", length);
getch();
}
OUTPUT:
Enter e id
1
Salary= 120000
RESULT:
Thus C program to returns the current file position of the specified stream and to get the
total size of a file after moving file pointer at the end of file has been executed and verified
successfully.
RANDOM ACCESS
EX.NO:6e
REWIND
DATE:
AIM:
To write a C program to set the file pointer at the beginning of the stream and to use
stream many times.
PROGRAM:
#include<stdio.h>
#include<conio.h>
void main(){
FILE *fp;
char c;
clrscr();
fp=fopen("file.txt","r");
while((c=fgetc(fp))!=EOF){
printf("%c",c);
while((c=fgetc(fp))!=EOF){
printf("%c",c);
fclose(fp);
getch();
}
OUTPUT:
Enter e id
1
Salary= 120000
RESULT:
Thus C program to set the file pointer at the beginning of the stream and to use stream
many times has been executed and verified successfully.