You are on page 1of 16

KNS INSTITUTE OF TECHNOLOGY

C LAB MANUAL

DEPARTMENT OF MCA

C Programming Laboratory
Subject Code: 10MCA16 Hours/Week: 3 Total Hours: 42 Part A 1. A). Write a program to find the area of a triangle (Given the three sides). # include<stdio.h> #include<conio.h> #include<math.h> main() { int a,b,c; float area, s; clrscr(); printf(Enter the three sides of triangle\n); scanf(%d %d %d ,&a, &b, &c); s=(a+b+c)/2.0; area=sqrt(s*(s-a)*(s-b)*(s-c)); printf(area of the triangle= %f , area); getch(); } B). Write a program to find the area of a circle (Given the radius). # include<stdio.h> #include<conio.h> #define PI 3,142 main() { float area, r; clrscr(); printf(Enter the radius of circle\n); scanf(%f ,&r); area = PI * r * r; printf(area of Circle= %f, area); getch(); } I.A. Marks: 50 Exam Marks: 50 Exam Hours: 3

Lecturer: Syed Khutubuddin Ahmed

Page 1

KNS INSTITUTE OF TECHNOLOGY


2.

C LAB MANUAL

DEPARTMENT OF MCA

Write a program to find the Simple interest, given the principle, time and rate of interest with appropriate validations. Simple Interest = (P * T * R)/ 100 Compound Interest = P * (1 + r /100)T # include<stdio.h> #include<conio.h> main() { int p, t; float r, si; clrscr(); printf(Enter the principle, rate and Interest \n); scanf(%d %f %d ,&p, &r, &t); si = ( p * t * r ) / 100 printf(Simple Interest= %f, si); getch(); }

3.

Write a program to find out whether a given year is a leap year or not. # include<stdio.h> #include<conio.h> main() { int year; clrscr(); printf(Enter the Year\n); scanf(%d ,&Year); if ( year % 4 == 0) printf(The specified year is a Leap Year); else printf(The specified year is Not a Leap Year ); getch(); } #include <stdio.h> #include <conio.h> void main() { int year,leap; clrscr(); printf("enter the year:- "); scanf("%d",&year); if ((year%100)==0) leap=(year/400)*400; else leap=(year/4)*4; if (leap==year) printf(" %d is a leap year.",year); else printf(" %d is not a leap year.",year); getch(); }

Lecturer: Syed Khutubuddin Ahmed

Page 2

KNS INSTITUTE OF TECHNOLOGY


4.

C LAB MANUAL

DEPARTMENT OF MCA

Write a program to find the roots of a quadratic equation with appropriate error messages. # include<stdio.h> main() { float a, b, c, d, x, x1, x2, rpart, ipart; clrscr(); printf(Enter the three roots of quadratic equation); scanf(%f, %f, %f, &a, &b, &c); if (a = =0) { x= -b/c; printf ("only root x=%7.3f", x); } d=b*b-4*a*c; if (d>0) { printf ("real and distinct roots are *); xl - (-b + sqrt(d)) / (2*a); x2 = (-b - sqrt(d)) / (2*a); printf (xl= 7.3f \n x2=%7.3f ", xl, x2); } // End of IF else if (d = = 0) { printf ("repeated roots are"); xl = -b/ (2*a); x2 = x1; printf ("xl = x2 = %7.3f ",xl,x2); } // End of ELSE-IF else { d = sqrt(abs(d)); rpart = -b/ (2*a); // remember in this line it is B ipart = d/ (2*a); // remember in this line it is D printf ("complex roots are :"); printf ("xl = %7.3f + i % 7.3f", rpart, ipart); printf (nx2 = %7.3f - i % 7.3r, rpart, ipart); } //End of ELSE getch(); }

# include<stdio.h> #include<conio.h> main() { float a, b, c, d, x, x1, x2, rpart, ipart; int choice=1; clrscr(); printf(Enter the three roots of quadratic equation); scanf(%f, %f, %f, &a, &b, &c); if (a = =0) { x= -b/c; printf ("only root x=%7.3f", x); } d=b*b-4*a*c; if (d>0) choice = 1; else if (d = = 0) choice = 2; else choice = 3; switch (choice) { case l: printf ("real and distinct roots are *); xl - (-b + sqrt(d)) / (2*a); x2 = (-b - sqrt(d)) / (2*a); printf (xl= 7.3f \n x2=%7.3f ", xl, x2); break; case 2: printf ("repeated roots are"); xl = -b/ (2*a); x2 = x1; printf ("xl = x2 = %7.3f ",xl,x2); break; case 3: d = sqrt(abs(d)); rpart = -b/ (2*a); // remember in this line it is B ipart = d/ (2*a); // remember in this line it is D printf ("complex roots are :"); printf ("xl = %7.3f + i % 7.3f", rpart, ipart); printf (nx2 = %7.3f - i % 7.3r, rpart, ipart); break; } // End of SWITCH getch(); }

Lecturer: Syed Khutubuddin Ahmed

Page 3

KNS INSTITUTE OF TECHNOLOGY


5.

C LAB MANUAL

DEPARTMENT OF MCA

Write a program to display the following files of current directory. i) .EXE files ii) .BAT files iii) .OBJ files iv) .BAK files. By using system DOS command. # include<stdio.h> #include<conio.h> #include<process.h> main() { clrscr(); printf(Displaying Files \n); printf(Displaying *.EXE Files \n); system (dir *.exe); printf(Displaying *.BAK Files \n); system (dir *.bak); printf(Displaying *.OBJ Files \n); system (dir *.obj); printf(Displaying *.BAT Files \n); system (dir *.bat); } getch(); }

6.

Write a program to find GCD and LCM of given two numbers. # include<stdio.h> #include<conio.h> main() { int n, m, lcm, gcd, product; clrscr(); printf(Input two numbers); scanf(%d %d, &m, &n); if( m <= 0 || n <= 0) printf(Invalid Input); else { product = m * n; while (m != n) { if (m > n) m = m n; else n = n m; } gcd = n; lcm = product / gcd; printf(GCD = %d \n, gcd); printf(LCM = %d \n, lcm); } // End of ELSE getch(); }

7.

Write a program to find the value of Sin (x) using the series. Page 4

Lecturer: Syed Khutubuddin Ahmed

KNS INSTITUTE OF TECHNOLOGY

C LAB MANUAL

DEPARTMENT OF MCA

Sin (x) = x x3/3! + x5/5! x7/7! + . #include<stdio.h> #include<conio.h> #define PI 3..1426 void main() { int i,n; float degree, x, term, sum; clrscr(); printf("enter the values of n \n"); scanf ("%d" , &fst); printf(enter the degree \n); scanf(%f, &degree); /*convert degree into radiance*/ x= degree * PI / 180; term = x; sum = term; for(i=3; i<= n; i += 2) { term = term * x * x / (i * (i - 1)); sum = sum + term; } printf(sin(%f) = %f \n, degree, sum); printf(using library function \n); printf(sin (%f) = %f \n, degree, sin(x)); getch(); } . 8. Write a program to print all prime numbers between m and n. #include<stdio.h> #include<conio.h> void main() { int i,fst,lst,j; clrscr(); printf("enter the first and last limt\n"); scanf ("%d%d",&fst,&lst); i=fst; while (i<lst) { for(j=2;j<i;j++) { if(i%j == 0) goto inc; } printf("%d\t",i); inc: i++; } getch(); } .

Lecturer: Syed Khutubuddin Ahmed

Page 5

KNS INSTITUTE OF TECHNOLOGY


9.

C LAB MANUAL

DEPARTMENT OF MCA

Write a program to reverse a number and check whether it is palindrome or Not. # include<stdio.h> main() { long n, temp, reverse; int r; clrscr(); printf(Input a number\n); scanf(%ld, &n); temp = n; reverse=0; while ( n ) { r = n % 10; reverse = reverse * 10 + r; n = n / 10; } if (temp == reverse) printf(%ld is a palindrome, temp); else printf(%ld is not a palindrome, temp); getch(); }

10. Write a program to generate and print first n Fibonacci numbers using function. #include<stdio.h> #include<conio.h> void main() { int n; clrscr(); printf("Input number of elements in the series"); scanf("%d", &n); printf("0 \t"); fib(n); getch(); } fib(int n) { int i,fnext=1,f1=0,f2=1; for(i=1; i<n; i++) { printf("%d \t",fnext); fnext = f1 + f2; f1 = f2; f2 = fnext; } }

Lecturer: Syed Khutubuddin Ahmed

Page 6

KNS INSTITUTE OF TECHNOLOGY

C LAB MANUAL

DEPARTMENT OF MCA

11. Write a program to find a factorial of a given number using recursive function. #include<stdio.h> #include<conio.h> void main() { int n; clrscr(); printf("Input number of elements in the no"); scanf("%d", &n); //printf("0 \t"); printf("%d", fact(n)); getch(); } fact(int n) { int fac; if(n == 0 ) { return 1; } fac = n * fact(n-1); return fac; }

12. Write a program to convert UPPERCASE alphabets to LOWERCASE alphabets in a given string and vice-versa. #include<stdio.h> #include<conio.h> void main() { char str[15]; int i, len; clrscr(); printf("Enter a String \n"); gets(str); len = strlen (str); for(i = 0; i < len; i ++) { if (str [i] > a && str [i] < z) str [i] = str [i] - 32; else if (str [i] > A && str [i] < Z) str [i] = str [i] + 32; } Printf (Converted String is %s, str); getch(); }

Lecturer: Syed Khutubuddin Ahmed

Page 7

KNS INSTITUTE OF TECHNOLOGY

C LAB MANUAL

DEPARTMENT OF MCA

13. Write a program to read two strings and concatenate them (without using library functions). #include<stdio.h> #include<conio.h> void main() { char str1[100], str2[100]; int i, length1, length2; clrscr(); printf("enter the first string\n"); gets(str1); length1= strlen (str1); printf("enter second string \n"); gets(str2); length2= strlen(str2); /*append the content of str1 to str2 */ for(i=0; i<length2 ; i++) { str1[length1+i]= str2[i]; } str1[length1+length2]='\0'; printf("concatenated string is \n%s",str1); getch(); } 14. Write a program to read a sentence and count the number of vowels and consonants. #include<stdio.h> #include<conio.h> void main() { char str[50]; int len,i,vowel_count=0,consonent=0; clrscr(); printf("enter the sentence \n"); gets(str); i=0; while(str[i] != '\0') { if(str[i] == 'a' || str[i]=='e' || str[i]=='i'|| str[i]=='o'|| str[i]=='u') { vowel_count++; } else { if(str[i]!= ) consonent++; } i++; } printf("count of vowels=%d \n",vowel_count); printf("count of consonents=%d",consonent); getch(); }

PART - B Lecturer: Syed Khutubuddin Ahmed Page 8

KNS INSTITUTE OF TECHNOLOGY

C LAB MANUAL

DEPARTMENT OF MCA

1) Write a program to read N integers (zero, + ve and ve) into an array and find sum of positive numbers, sum of negative numbers and average of all input numbers. #include<stdio.h> #include<conio.h> #define SIZE 100 void main() { int a[SIZE]; int i, n, sum_neg = 0, sum_pos = 0; float avg, sum=0; clrscr(); printf("enter no of elemets\n"); scanf("%d", &n); printf("Enter the array elemets\n"); for(i=0 ; i<n ; i++) { scanf("%d", &a[i]); if(a[i]>0) sum_pos = sum_pos + a[i]; else sum_neg = sum_neg + a[i]; } printf("sum of postive no=%d\n", sum_pos); printf("sum of Negative no=%d\n", sum_neg); avg=(sum_neg + sum_pos)/n; printf("average of all no=%f", avg); getch(); }

2) Write a program to input N real numbers and to find the mean, variance and standard Mean = xi / N (xi mean)2 Variance = ---------------N Deviation = variance and 0 i < n #include<stdio.h> #include<conio.h> #include<math.h> #define SIZE 100 void main() { int n, i; float a[SIZE], sum=0, mean=0, variance=0, deviation=0; clrscr(); printf(Enter the size of array) scanf(%d, &n); printf(Enter the numbers in array \n); for(i=0; i < n; i++) scanf (%d, a[i]); // find mean value for(i=0; i < n; i++) { sum = sum + a[i]; } mean = sum / n; Printf(Mean (Average)= %d, mean);

deviation, where,

// find variance value for(i=0; i < n; i++) { sum = sum + (a[i] - mean) * (a[i] - mean); } variance = sum / n; printf(Variance = %f, variance); // find standard deviation deviation = sqrt (variance); Printf(Deviation = %f \n, deviation); getch(); }

Lecturer: Syed Khutubuddin Ahmed

Page 9

KNS INSTITUTE OF TECHNOLOGY

C LAB MANUAL

DEPARTMENT OF MCA

3) Write a program to input N numbers (integers or real) and store them in an array. Conduct a Linear search for a given key number and report success or failure in the form of a suitable message. #include<stdio.h> #include<conio.h> #define SIZE 100 void main() { int n, key, a[SIZE], i, flag=0; clrscr(); printf(Enter the size of array) scanf(%d, &n); printf(Enter the numbers in array \n); for(i=0; i < n; i++) scanf (%d, a[i]); printf(Enter the elements to be searched); scanf(%d, &key); // leaner search for(i=0; i < n; i++) { if (a[i] == key) flag=1; } if (flag == 1) printf(Key Element %d found at position= %d, key , i ); else printf(Key Element NOT found); getch(); }

4) Write a program to sort N numbers in ascending or descending order using bubble sort. #include<stdio.h> #include<conio.h> #define SIZE 100 void main() { int n, i, j, temp, a[20]; Printf(Enter the number of items \n); Scanf(%d, &n); Printf(Enter the items to sort); for(i=1; i<n; i++) for(j=0; j<n-I; ++) { if (a[j] >= a[j+1]) temp=a[j]; a[j]= a[j+1]; a[j+1]= temp; } Printf(Sorted Elements in Ascending order); for(i=0; i<n; i++) printf(%d \n, a[i]); Printf(Sorted Elements in Descending order); for(i=n-1; i >= 0; i--) printf(%d \n, a[i]); getch(); }

Lecturer: Syed Khutubuddin Ahmed

Page 10

KNS INSTITUTE OF TECHNOLOGY

C LAB MANUAL

DEPARTMENT OF MCA

5) Write a program to accept N numbers sorted in ascending order and search for a given number using binary search. Report success or failure in the form of suitable messages. #include<stdio.h> #include<conio.h> #include<stdlib.h> void main() { int i, n, item, low, high, mid, a[20]; clrscr(); printf("enter the value of n \t"); scanf("%d",&n); printf("Enter n values\t"); for(i=0;i<n;i++) scanf("%d",&a[i]); printf("Enter the item to search\t"); scanf("%d",&item); low=0; high=n-1; while(low <= high) { mid= (low + high)/2; if(item == a[mid]) { printf("Sucess item present at location=%d",mid+1); getch(); exit(0); } if(item < a[mid]) { high= mid-1; } else low=mid+1; } printf("Unsuccessful search"); getch(); }

6) Write a program to read two matrices A and B of size M x N and perform product of two given matrices. #include<stdio.h> #include<conio.h> #include<stdlib.h> void main() { int m,n,p,q,i,j,k,sum; int a[10][10],b[10][10],c[10][10]; clrscr(); printf("enter the size of the matrix A \n"); scanf("%d%d",&m,&n); printf("Enter the elements of matrix A \t"); for(i=0;i<m;i++) { for(j=0;j<n;j++) { scanf("%d",&a[i][j]); } } printf("Enter the size of the matrix B"); scanf("%d%d",&p,&q); printf("Enter the elements of matrix B \t"); for(i=0;i<p;i++) { for(j=0;j<q;j++) { scanf("%d",&b[i][j]); } } // check whether multiplication is possible or Not if(n != p) { printf("Multipliction is not possible \n"); getch(); exit(0); } // multiply A and B for(i=0;i<m;i++) { for(j=0;j<q; j++) { sum=0; for(k=0;k<n;k++) { sum = sum + a[i][k]*b[k][j]; } c[i][j]=sum; } } //displaying the result printf("The resultant matrix C is\n"); for(i=0;i<m;i++) { for(j=0;j<q;j++) { printf("%d\t",c[i][j]); } printf("\n"); } getch(); }

Lecturer: Syed Khutubuddin Ahmed

Page 11

KNS INSTITUTE OF TECHNOLOGY


7)

C LAB MANUAL

DEPARTMENT OF MCA

Write a program to list the names of students who have scored more than 60% of total marks in three subjects using structure variables. for(i=0;i<5;i++) { if(s[i].tot_marks>60) printf("%s",s[i].name); } getch(); }

METHOD-1 void main() { struct student { char name[10]; float sub1; float sub2; float sub3; float tot_marks; }s[3]; int i; clrscr(); printf("Enter the values\n"); for(i=0;i<3;i++) { printf("Enter the name and marks of three subjects"); scanf("%s%f%f%f",s[i].name,&s[i].sub1,&s[i].sub2,&s[i].sub3); s[i].tot_marks=s[i].sub1+s[i].sub2+s[i].sub3; } METHOD-2 Follow method 2 void main() { struct student { char name[10]; int sub1; int sub2; int sub3; float tot_marks; }s[3]; int i; clrscr(); printf("Enter the values\n"); for(i=0;i<3;i++) { printf("Enter the name and marks of three subjects"); scanf("%s%d%d%d",s[i].name,&s[i].sub1,&s[i].sub2,&s[i].sub3); s[i].tot_marks=s[i].sub1+s[i].sub2+s[i].sub3; }

//just include this function in your program other wise you may get an error during runtime as floating point linkage error. linkfloat( ) { float a = 5, *b ; b = &a ; /* cause emulator to be linked */ a = *b ; /* suppress the warning - variable not used */ } for(i=0;i<5;i++) { if(s[i].tot_marks>60) printf("%s",s[i].name); } getch(); }

Lecturer: Syed Khutubuddin Ahmed

Page 12

KNS INSTITUTE OF TECHNOLOGY


8)

C LAB MANUAL

DEPARTMENT OF MCA

Write a program to compute the sum of two complex numbers passing a structure to a function. void main(void) { struct struct_type c1,c2; clrscr(); printf("Enter the real and imginary part of 1st complex no\n"); scanf("%d%d",&c1.real,&c1.imag); printf("Enter the real and imginary part of 2nd complex no\n"); scanf("%d%d",&c2.real,&c2.imag); f1(c1,c2); getch(); }

#include <stdio.h> struct struct_type { int real; int imag; }; void f1(struct struct_type x1,struct struct_type x2) { struct struct_type x3; x3.real=x1.real+x2.real; x3.imag=x1.imag+x2.imag; printf("sum of complex no=%d + i %d",x3.real,x3.imag); }

9)

Define a book structure having title of the book, ISBN, author, price and month and year of publication as its members. Use a substructure to store the month and year of Publication information. Develop a program to accept a date (in the form of month and year) and list out all the book titles (along with price and ISBN) published during that date. scanf("%d",&s1[i].isbn); printf("Enter the author name:"); scanf("%s",s1[i].author); printf("Enter the price of book:"); scanf("%f",&s1[i].price); printf("Enter the Book published Month And Year:\n"); scanf("%d%d",&s1[i].d.mm,&s1[i].d.yy); } // End of For Loop printf("\n\n\n\n\n\nEnter Book Published Month And Year\n"); scanf("%d%d",&smm,&syy); printf("**The Books details of %d-%d: ***\n",smm,syy); for(i=0;i<n;i++) { if(smm==s1[i].d.mm&&syy==s1[i].d.yy) printf("%s\n%d\n%s\n%f\n\n",s1[i].title,s1[i].isbn,s1[i].author,s1[i].pr ice); } getch(); } linkfloat() { float a=0,*b; b=&a; a=*b; }

#include<stdio.h> #include<conio.h> main() { int i,n,smm,syy; struct date { int mm,yy; }; struct book { char title[50]; int isbn; char author[20]; float price; struct date d; }s1[200]; // Input operation printf("Enter the No. of books:\n"); scanf("%d",&n); for(i=0;i<n;i++) { printf("ENTER THE BOOK DETAILS NO. %d :",i+1); printf("\nEnter the Book title:"); scanf("%s",s1[i].title); printf("Enter the book ISBN No.:");

Lecturer: Syed Khutubuddin Ahmed

Page 13

KNS INSTITUTE OF TECHNOLOGY

C LAB MANUAL

DEPARTMENT OF MCA

10) Define a student structure having the name, USN (university seat number), marks in five subjects, total and percentage of marks as its members. Marks of all the subjects are to be stored in an array. Develop a program to list the names of all the students who have failed. #include<stdio.h> main() { int n,i,j; struct student { char name[20]; char usn[10]; int marks[5]; int sum; float avg; }st[100]; printf("Enter the structure Size:\n"); scanf("%d",&n); printf("Enter the student details\n"); for(i=0;i<n;i++) { printf("\n\nName:"); scanf("%s",st[i].name); printf("USN No.:"); scanf("%s",st[i].usn); } for(j=0;j<5;j++) { printf("Enter the Subject%d Marks:",j+1); scanf("%d",&st[i].marks[j]); st[i].sum=st[i].sum+st[i].marks[j]; } st[i].avg=(float)st[i].sum/5; } printf("\n\n\nFaild Students Are:\n"); for(i=0;i<n;i++) for(j=0;j<5;j++) { if(st[i].marks[j]<35) { printf("\n\nStudent Name:%s\n",st[i].name); printf("Usn No.:%s\n",st[i].usn); printf("Total Marks:%d\n",st[i].sum); printf("Percentage :%f\n",st[i].avg); break; } } getch();

11) Write a program to read N integers and store them in an array, find the sum of all these elements using pointer. Output the given array and the computed sum with suitable heading. #include<stdio.h> void main() { int i,n,sum=0,arr[100],*p; clrscr(); printf("\n How Integers you want to store in array?\t"); scanf("%d",&n); printf("\nEnter %d numbers one below the other",n); for(i=0;i<n;i++) { scanf("%d",&arr[i]); } p=arr; printf("\nThe elements of array are:"); for(i=0;i<n;i++) { sum=sum+*p; printf("%d\t",*p); p++; } printf("\n\n The Sum OF ABOVE INTEGERS = %d",sum); getch(); }

Lecturer: Syed Khutubuddin Ahmed

Page 14

KNS INSTITUTE OF TECHNOLOGY


12) Write a program to read and write to a file.

C LAB MANUAL

DEPARTMENT OF MCA

#include<stdio.h> void main() { FILE *fp1,*fp2; char c,src[20],des[20]; clrscr(); printf("\n Enter the source filename: "); gets(src); fp1=fopen(src,"r"); if(fp1==NULL) { printf("\n SORRY!!! The Source File Does Not Exist"); getch(); exit(0); }

printf("\n Enter the Destination filename: "); scanf("%s",des); fp2=fopen(des,"w+"); while((c=fgetc(fp1))!=EOF) { fputc(c,fp2); } printf("\n %s HAS BEEN WRITTEN SUCCESSFULLY",src); fclose(fp1); fclose(fp2); getch(); }

13) Write a program to Create and count number of characters in a file. #include<stdio.h> void main() { FILE *fp; char c,name[20]; int cnt=0; clrscr(); printf("\n Enter the filename\n:"); scanf("%s",name); fp=fopen(name,"w+"); printf("\n Enter the Content with termination '^z'\n:"); while((c=getchar())!=EOF) { fputc(c,fp); cnt++; } fclose(fp); printf("\n %s IS CREATED",name); printf("The Number of charecters in the above file = %d",cnt); getch(); }

Lecturer: Syed Khutubuddin Ahmed

Page 15

KNS INSTITUTE OF TECHNOLOGY


14) Write a program to handle files with mixed data type.

C LAB MANUAL

DEPARTMENT OF MCA

#include<stdio.h> #include<math.h> struct emp { char name[13]; int age; float sal; }; void main() { struct emp e[20]; FILE *fp; char *fname; int i,n; float s; clrscr(); printf("\nEnter the name of the file \t: "); scanf("%s",fname); fp=fopen(fname,"w+"); if(fp==NULL) { printf("\n SORRY!!! The Source File Does Not Exist"); getch(); exit(0); }

printf("\n How many records?\t"); scanf("%d",&n); for(i=0;i<n;i++) { printf("\nEmployee %d Details\n",i+1); printf("\n Enter the name and age and salary:\t"); scanf("%s%d",e[i].name,&e[i].age); printf("\n Enter the salary:\t"); scanf("%f",&s); e[i].sal=s; //scanf("%s%d%f",e[i].name, &e[i].age, &e[i].sal); fprintf(fp,"%s\t%d\t%f\n",e[i].name,e[i].age,e[i].sal); } fclose(fp); fp=fopen(fname,"r"); if(fp==NULL) { printf("\n SORRY!!! The Source File Does Not Exist"); getch(); exit(0); } printf("\nFollowing are the Details of Employees records\n\n"); printf("\n========================="); printf("\nNAME\tAGE\tSALARY"); printf("\n========================="); for(i=0;i<n;i++) { fscanf(fp,"%s%d%f",e[i].name,&e[i].age,&e[i].sal); printf("\n%s\t%d\t%.2f",e[i].name,e[i].age,e[i].sal); } fclose(fp); getch(); }

Lecturer: Syed Khutubuddin Ahmed

Page 16

You might also like