The document contains C code snippets for various programming problems including calculating the area of shapes, finding roots of quadratic equations, sorting arrays, matrix multiplication, and more. The last problem is a program to list the names of students who scored over 60% total marks across three subjects, using a structure variable to store student data.
This document contains some programs of C using Data structures, like Stack, LinkedList, queue, Fibonacci series, addition and multiplication of two matrices,etc.
This document contains some programs of C using Data structures, like Stack, LinkedList, queue, Fibonacci series, addition and multiplication of two matrices,etc.
These problems are so common that you will find in any C learning curriculum. Either in your college or in any IT institute.
I have provided solutions to these problems as well.
Happy learning...
These problems are so common that you will find in any C learning curriculum. Either in your college or in any IT institute.
I have provided solutions to these problems as well.
Happy learning...
Bubble Sort,Insertion Sort, Structures,Students Mark statement ,Pointers, Arithmetic operations on pointers, Files,Creating file, Reading file,Writing a text file,binary file,lab programs,c programs,example programs,c program,Bubble Sort in c,Insertion Sort in c, Structures in c,Students Mark statement in c ,Pointers in c, Arithmetic operations on pointers in c, Files in c,Creating file in c, Reading file in c,Writing a text file in c,binary file in c,lab program in c,c program,example program,c program,thiruvalluvar university,lab manual,c lab manual
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...Levi Shapiro
Letter from the Congress of the United States regarding Anti-Semitism sent June 3rd to MIT President Sally Kornbluth, MIT Corp Chair, Mark Gorenberg
Dear Dr. Kornbluth and Mr. Gorenberg,
The US House of Representatives is deeply concerned by ongoing and pervasive acts of antisemitic
harassment and intimidation at the Massachusetts Institute of Technology (MIT). Failing to act decisively to ensure a safe learning environment for all students would be a grave dereliction of your responsibilities as President of MIT and Chair of the MIT Corporation.
This Congress will not stand idly by and allow an environment hostile to Jewish students to persist. The House believes that your institution is in violation of Title VI of the Civil Rights Act, and the inability or
unwillingness to rectify this violation through action requires accountability.
Postsecondary education is a unique opportunity for students to learn and have their ideas and beliefs challenged. However, universities receiving hundreds of millions of federal funds annually have denied
students that opportunity and have been hijacked to become venues for the promotion of terrorism, antisemitic harassment and intimidation, unlawful encampments, and in some cases, assaults and riots.
The House of Representatives will not countenance the use of federal funds to indoctrinate students into hateful, antisemitic, anti-American supporters of terrorism. Investigations into campus antisemitism by the Committee on Education and the Workforce and the Committee on Ways and Means have been expanded into a Congress-wide probe across all relevant jurisdictions to address this national crisis. The undersigned Committees will conduct oversight into the use of federal funds at MIT and its learning environment under authorities granted to each Committee.
• The Committee on Education and the Workforce has been investigating your institution since December 7, 2023. The Committee has broad jurisdiction over postsecondary education, including its compliance with Title VI of the Civil Rights Act, campus safety concerns over disruptions to the learning environment, and the awarding of federal student aid under the Higher Education Act.
• The Committee on Oversight and Accountability is investigating the sources of funding and other support flowing to groups espousing pro-Hamas propaganda and engaged in antisemitic harassment and intimidation of students. The Committee on Oversight and Accountability is the principal oversight committee of the US House of Representatives and has broad authority to investigate “any matter” at “any time” under House Rule X.
• The Committee on Ways and Means has been investigating several universities since November 15, 2023, when the Committee held a hearing entitled From Ivory Towers to Dark Corners: Investigating the Nexus Between Antisemitism, Tax-Exempt Universities, and Terror Financing. The Committee followed the hearing with letters to those institutions on January 10, 202
Safalta Digital marketing institute in Noida, provide complete applications that encompass a huge range of virtual advertising and marketing additives, which includes search engine optimization, virtual communication advertising, pay-per-click on marketing, content material advertising, internet analytics, and greater. These university courses are designed for students who possess a comprehensive understanding of virtual marketing strategies and attributes.Safalta Digital Marketing Institute in Noida is a first choice for young individuals or students who are looking to start their careers in the field of digital advertising. The institute gives specialized courses designed and certification.
for beginners, providing thorough training in areas such as SEO, digital communication marketing, and PPC training in Noida. After finishing the program, students receive the certifications recognised by top different universitie, setting a strong foundation for a successful career in digital marketing.
A Strategic Approach: GenAI in EducationPeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
Read| The latest issue of The Challenger is here! We are thrilled to announce that our school paper has qualified for the NATIONAL SCHOOLS PRESS CONFERENCE (NSPC) 2024. Thank you for your unwavering support and trust. Dive into the stories that made us stand out!
Introduction to AI for Nonprofits with Tapp NetworkTechSoup
Dive into the world of AI! Experts Jon Hill and Tareq Monaur will guide you through AI's role in enhancing nonprofit websites and basic marketing strategies, making it easy to understand and apply.
Macroeconomics- Movie Location
This will be used as part of your Personal Professional Portfolio once graded.
Objective:
Prepare a presentation or a paper using research, basic comparative analysis, data organization and application of economic information. You will make an informed assessment of an economic climate outside of the United States to accomplish an entertainment industry objective.
How to Build a Module in Odoo 17 Using the Scaffold MethodCeline George
Odoo provides an option for creating a module by using a single line command. By using this command the user can make a whole structure of a module. It is very easy for a beginner to make a module. There is no need to make each file manually. This slide will show how to create a module using the scaffold method.
Normal Labour/ Stages of Labour/ Mechanism of LabourWasim Ak
Normal labor is also termed spontaneous labor, defined as the natural physiological process through which the fetus, placenta, and membranes are expelled from the uterus through the birth canal at term (37 to 42 weeks
Biological screening of herbal drugs: Introduction and Need for
Phyto-Pharmacological Screening, New Strategies for evaluating
Natural Products, In vitro evaluation techniques for Antioxidants, Antimicrobial and Anticancer drugs. In vivo evaluation techniques
for Anti-inflammatory, Antiulcer, Anticancer, Wound healing, Antidiabetic, Hepatoprotective, Cardio protective, Diuretics and
Antifertility, Toxicity studies as per OECD guidelines
Thinking of getting a dog? Be aware that breeds like Pit Bulls, Rottweilers, and German Shepherds can be loyal and dangerous. Proper training and socialization are crucial to preventing aggressive behaviors. Ensure safety by understanding their needs and always supervising interactions. Stay safe, and enjoy your furry friends!
A workshop hosted by the South African Journal of Science aimed at postgraduate students and early career researchers with little or no experience in writing and publishing journal articles.
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
C lab manaual
1. PART- A
1a. WAP to find the area of the triangle
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
float a,b,c,area,s;//s is semi perometer i.e. s=(a+b+c)/2
clrscr();
printf("enter the three sides of triangle");
scanf("%f%f%f",&a,&b,&c);
if((a+b)>c&&(a+c)>b&&(b+c)>a)
{
s=(a+b+c)/2;
area=sqrt(s*(s-a)*(s-b)*(s-c)) ;
printf("the area of given triangle is-->%f",area);
}
else
printf("the sides given are invalid...enter vaild sides");
getch();
}
2. Output
enter the three sides of triangle
1
1
1
the area of given triangle is-->0.433013
1b. Wap to find the area of the circle
#include<stdio.h>
#include<conio.h>
void main()
{
float p=3.14,r,area;
clrscr();
printf("Enter the value of radious = ");
scanf("%f",&r);
area=p*r*r;
printf("nThe area of circle is = %f",area);
getch();
}
3. Output
Enter the value of radious = 2
The area of circle is = 12.560000
2. Wap to find the simple interest ,given the principle,time and rate of
interest with appropriate validation
#include<stdio.h>
#include<conio.h>
void main()
{
int p,t;
float r,si;
clrscr();
printf("n enter principle,rate and time");
scanf("%d%f%d",&p,&r,&t);
si=(p*r*t)/100;
printf("n simple interest:%f",si);
getch();
}
Output
Enter the year which you know to check that it is leap year or not:->2008
The given year is leap year
4. 3. WAP to check whether the given year is leap year or not
#include<stdio.h>
#include<conio.h>
void main()
{
int n;
clrscr();
printf("n Enter the year which you know to check that it is leap year or not:->");
scanf("%d",&n);
if((n%400==0)||(n%4==0)&&(n%100!=0))
{
printf("n The given year is leap year");
}
else
{
printf("n The given year is not a leap year");
}
getch();
}
5. 4. WAP to find the root of the quadratic equation with appropriate
message.
//roots of the quadratic equation
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int a,b,c,d=0,rp,ip;
float x1,x2,e;
clrscr();
printf("n enter the coefficient of a,b and c");
scanf("%d%d%d",&a,&b,&c);
if(a>0)
{
d=b*b-4*a*c;
if(d==0)
{
printf("n roots are equal");
x1=x2=-b/(2*a);
printf("n root 1=%f",x1);
printf("n root 2=%f",x2);
6. }
else if(d>0)
{
e=sqrt(d);
printf("n roots are real");
x1=-(b+e)/(2*a);
x2=-(b+e)/(2*a);
printf("n root 1=%f",x1);
printf("n root 2=%f",x2);
}
else
{
printf("root are imaginary");
}
}
else
{
printf("n this is not a quadratic equation");
}
getch();
}
7. 6. WAP to find GCD and LCM of given two numbers
#include<stdio.h>
#include<conio.h>
void main()
{
int u,v,temp,a,b,lcm,gcd;
clrscr();
printf("n enter two number");
scanf("%d%d",&u,&v);
a=u;
b=v;
while(v!=0)
{
temp=u%v;
u=v;
v=temp;
}
gcd=u;
lcm=(a*b)/gcd;
printf("n GCD of two number=%d",gcd);
printf("n LCM of the two number=%d",lcm);
getch();
}
8. 7. WAP to calculate sin(x) series.
#include<stdio.h>
#include<conio.h>
void main()
{
int n,sign=1,i;
float x,t,sum;
clrscr();
printf("n enter value of x and n");
scanf("%f%d",&x,&n);
x=(3.14 /180)*x;
sum=t=x;
for(i=1;i<n;i++)
{
sign=-1;
t=sign*t*x*x/(2*i*(2*i+1));
sum=sum+t;
}
printf("sum of sin x series=%f",sum);
getch();
}
9. 8. WAP to print all prime numbers between m and n
#include<stdio.h>
#include<conio.h>
void main()
{
int m,n,i,j,prime=0;
clrscr();
printf("n enter two number from which you want to check prime number");
scanf("%d%d",&m,&n);
if(m<2)
m=2;
for(i=m;i<=n;i++)
{
prime=1;
for(j=2;j<=i-1;j++)
if (i%j==0)
{
prime=0;
break;
}
if(prime)
printf("n %dt",i);
10. }
getch();
}
9. WAp to reverse a number and check whether it is palindrome or not
#include<stdio.h>
#include<conio.h>
void main()
{
int n,d,r=0,u=0;
clrscr();
printf("n enter a number");
scanf("%d",&n);
u=n;
while(n!=0)
{
d=n%10;
r=(r*10)+d;
n=n/10;
}
if (r==u)
printf("n number is palindrome");
else
printf("n number is not palindrome");
getch();
11. }
10 WAP to generate and print first n Fibonacci numbers using function.
#include<stdio.h>
#include<conio.h>
void fibo(int);
void main()
{
int n;
clrscr();
printf("n enter the limit of the seriesn");
scanf("%d",&n);
fibo(n);
getch();
}
void fibo(int n)
{
int a=0,b=1,c,i=3;
printf("n fibonacci series=n");
if(n<1)
printf("enter the valid limit");
else
if(n==1)
printf("0");
else if(n==2)
printf("%dt%d",a,b);
12. else
{
printf("0 t 1");
while(i<=n)
{
c=a+b;
printf("t%d",c);
a=b;
b=c;
i++;
}
}
}
11 WAP to find factorial of a given number usind recursive function.
#include<stdio.h>
#include<conio.h>
int factorial();
void main()
{
int n;
clrscr();
printf("n enter a numbern");
scanf("%d",&n);
printf("n factorial=%d",factorial(n));
getch();
}
13. int factorial(int n)
{
if(n==0)
{
return(1);
}
else
{
return(n*factorial(n-1));
}
}
12 WAP to convert upper case alphabets to lower case alphabets in the given
string and vice versa.
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char str[20];
int i;
clrscr();
puts("enter a stringn");
gets(str);
printf("n original string=%s",str);
for(i=0;str[i]!='0';i++)
{
14. 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("n change string is:%s",str);
getch();
}
13 write a program to read two strings and concatenate them (without using
library function).
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char str1[20],str2[10];
int i=0,j=0;
clrscr();
puts("enter string first");
15. gets(str1);
puts("n enter string second");
gets(str2);
while(str1[i]!='0')
{
str1[i++];
}
while(str2[j]!='0')
{
str1[i]=str2[j];
str1[i++];
str2[j++];
str1[i]='0';
}
printf("concaneted string=");
puts(str1);
getch();
}
14 WAP to read a sentence and count the number of vovel and consonant.
PART -B
1. WAP to read N integer (zero,+ve and -ve) into an arrey and find the
sum of positive numbers, sum of negative numbers and average of
all input numbers
#include<stdio.h>
16. #include<conio.h>
void main()
{
int a[20],n,i,sum1=0,sum2=0;
float avg=0.0;
clrscr();
printf("n enter the size of the arrayn");
scanf("%d",&n);
printf("enter array element 1 by 1 n ");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0;i<n;i++)
{
if(a[i]>0)
sum1=sum1+a[i];
else
sum2=sum2+a[i];
}
avg=(sum1+sum2)/n;
printf("n sum of posotive number=%d",sum1);
printf("n sum of negative number =%d",sum2);
printf("n average on entered number =%f",avg);
getch();
}
17. 2. WAP to input N real numbers and to find the mean , variance and
standard deviation
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
float a[20],sum=0.0,mean=0.0,var,sumsqr,dev;
int n,i;
clrscr();
printf("n enter the size of the arrayn");
scanf("%d",&n);
printf("enter array element 1 by 1 n ");
for(i=0;i<n;i++)
{
scanf("%f",&a[i]);
sum=sum+a[i];
}
mean=sum/n;
for(i=0;i<n;i++)
sumsqr=sumsqr+((a[i]-mean)*(a[i]-mean));
var=sumsqr/n;
dev=sqrt(var);
printf("n mean of entered number =%f",mean);
printf("n variatiuon=%f",var);
18. printf("n deviation=%f",dev);
getch();
}
3. WAP to input N numbers and store them in an array and apply
linear search
#include<stdio.h>
#include<conio.h>
void main()
{
int a[20],item,i,flag=0;
int n;
clrscr();
printf("n enter size of the arrayn");
scanf("%d",&n);
printf("n enter array element 1 by 1 n");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
printf("n enter a searching numbern");
scanf("%d",&item);
for(i=0;i<n;i++)
if(item==a[i])
{
flag=1;
break;
19. }
if(flag)
printf("n searching number %d is found at %d position",item,i+1);
else
printf("n searching value not found");
getch();
}
4. WAP to sort N numbers is ascending order or descending order
using bubble sort
#include<stdio.h>
#include<conio.h>
void main()
{
int a[10],i,j,n,temp;
clrscr();
printf("n enter the size of the arrayn");
scanf("%d",&n);
printf("n enter the array element 1 by 1 n");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
printf("n after insertion array is n");
for(i=0;i<n;i++)
20. printf("%dt",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 after sorting in ascending order array isn");
for(i=0;i<n;i++)
printf("%dt",a[i]);
getch();
}
5. WAP to implement binary search
//binary searching
#include<stdio.h>
#include<conio.h>
void main()
{
int a[10],i,j,n,temp,item,ub,lb,mid,found=0;
clrscr();
printf("n enter the size of the arrayn");
scanf("%d",&n);
21. printf("n enter the array element 1 by 1 in ascending ordern");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
printf("n after insertion array is n");
for(i=0;i<n;i++)
printf("%dt",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 enter a searching numbern");
scanf("%d",&item);
lb=0;
ub=n-1;
while(lb<ub)
{
mid=(lb+ub)/2;
if(item==a[mid])
{
found=1;
break;
22. }
if(item<a[mid])
ub=mid-1;
else
lb=mid+1;
}
if(found)
printf("n searching value is found at %d position",mid+1);
else
printf("n searching value not found");
getch();
}
6. WAP to read two matrices A & B of size M*N and perform product
of two given matrices.
#include<stdio.h>
#include<conio.h>
int main()
{
int a[' '][' '],b[' '][' '],c[' '][' '],i,j,k,m1,n1,m2,n2;
clrscr();
printf("n enter the order of the first matrix");
scanf("%d%d",&m1,&n1);
printf("n enter the order of the second matrix");
scanf("%d%d",&m2,&n2);
if(m1!=n2)
{
printf("multiplication not possible");
getch();
return 0;
}
printf("n enter matrix 1 element 1 by 1");
24. for(j=0;j<n2;j++)
printf("%dt",c[i][j]);
printf("n");
}
getch();
return 0;
}
7. WAP to list the name of the students who have scored more than
60% of total marks in three subject using str var
#include<Stdio.h>
#include<conio.h>
struct student
{
int usn;
char name[10];
int marks[3];
int total;
};
struct student s[5];
void main()
{
int i,j,n;
clrscr();
printf("n enter the number of the studentn");
scanf("%d",&n);
for(i=0;i<n;i++)
{
25. printf("n enter the details of %d studentn",i+1);
printf("enter student usnn");
scanf(" %d",&s[i].usn);
printf("n enter student namen");
scanf("%s",&s[i].name);
printf("n enter three paper marks 1 by 1 n");
for(j=0;j<3;j++)
{
scanf("%d",&s[i].marks[j]);
s[i].total=s[i].total+s[i].marks[j];
}
}
clrscr();
printf("n n student details (scored more than 60%).....");
printf("n ..........");
for(i=0;i<n;i++)
{
if(s[i].total>=180)
{
printf("n usn no.=%d",s[i].usn);
printf("n student name=%s",s[i].name);
printf("n total marks=%d",s[i].total);
}
printf("nnn");
}
26. getch();
}
8 WAP to compute the sum of two complex number-passing a structure
to a function.
#include<stdio.h>
#include<conio.h>
struct complex
{
int real,imag;
};
typedef struct complex s;
void main()
{
s x,y;
clrscr();
printf("n enter the first complex number");
printf("n enter real part=");
scanf("%d",&x.real);
printf("n enter the imaginary part=");
scanf("%d",&x.imag);
printf("n enterthe second imaginary part");
printf("n enter real part=");
scanf("%d",&y.real);
printf("n enter imaginary part=");
scanf("%d",&y.imag);
27. printf("n addition of two complex number
is=(%d+i%d)+(%d+i%d)=(%d+i%d)",x.real,x.imag,y.real,y.imag,x.real+y.real,x.imag+y.imag);
getch();
}
9. Define a book structure having book info . WAP to accept date and list
out all the book infopublished during date.
#include<stdio.h>
#include<conio.h>
struct date
{
int month;
int year;
};
typedef struct date pdate;
struct book
{
int isbn;
char title[20];
char author[20];
int price;
pdate date;
};
typedef struct book books;
void main()
{
pdate search;
28. books mca[20];
int n,i;
clrscr();
printf("n enter how many xbookst");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("n enter the details of %d books n",i+1);
printf("n enter the isbn number t");
scanf("%d",&mca[i].isbn);
printf("n enter the name of the bookt");
scanf("%s",mca[i].title);
printf("n enter the author namet");
scanf("%s",mca[i].author);
printf("n enter the price of the bookt");
scanf("%d",&mca[i].price);
printf("n enter the mounth of the publicationt");
scanf("%d",&mca[i].date.month);
printf("n enter the year of the publicationt");
scanf("%d",&mca[i].date.year);
}
printf("n enter the month of publication that to searcht");
scanf("%d",&search.month);
printf("n enter the year of publication to searcht");
scanf("%d", &search.year);
29. printf("nn book datails.....n");
for(i=0;i<n;i++)
{
if((mca[i].date.month==search.month)&&(mca[i].date.year==search.year))
{
printf("n title=%s",mca[i].title);
printf("n isbn=%d",mca[i].isbn);
printf("n author name=%s",mca[i].author);
printf("n price of the book=%d",mca[i].price);
printf("n month of publication=%d",mca[i].date.month);
printf("n year of publication=%d",mca[i].date.year);
}
}
getch();
}
10. define structure having students info with 5 sub marks using array,
list out all the failed students.
#include<stdio.h>
#include<conio.h>
struct student
{
char name[20];
int usn,tot,sub[5];
};
void main()
30. {
int i,n,j;
struct student std[10];
clrscr();
printf("n enter the number of the student t");
scanf("%d",&n);
printf("n enter the student details..");
for(i=0;i<n;i++)
{
std[i].tot=0;
printf("n enter name of the %d student=t",i+1);
scanf("%s",std[i].name);
printf("n enter usn of the %d student=t",i+1);
scanf("%d",&std[i].usn);
printf("n enter marks of the %d student==t",i+1);
for(j=0;j<5;j++)
{
printf("n enter subject %d markst",j+1);
scanf("%d",&std[i].sub[j]);
while(std[i].sub[j]>100)
{
printf("marks over flow n reemter the markst");
scanf("%d",&std[i].sub[j]);
}
std[i].tot+=std[i].sub[j];
31. }
}
printf("n list of failed studentsn");
for(i=0;i<n;i++)
{
if(std[i].tot<200)
{
printf("n name=%st",std[i].name);
printf("n usn=%dt",std[i].usn);
printf("n total=%d",std[i].tot);
}
}
getch();
}
11. WAP to find the sum of n integers in an array using pointers.
#include<stdio.h>
#include<conio.h>
void main()
{
int n,arr[10],i,*p,sum=0;
p=arr;
clrscr();
printf("n enter the size of the arrayn");
scanf("%d",&n);
printf("n enter %d numbern",n);
32. for(i=0;i<n;i++)
{
scanf("%d",&arr[i]);
}
for(i=1;i<=n;i++)
{
sum=sum+*p;
*p++;
}
printf("n sum of all the number =%d",sum);
getch();
}
12. WAP to read and write to a file.
#include<stdio.h>
#include<conio.h>
FILE *fp;
void main()
{
char name[20];
int usn,marks,n,i;
clrscr();
fp=fopen("student.dat","w");
printf("n how many student records you want to enter t");
scanf("%d",&n);
for(i=1;i<=n;i++)
33. {
printf("n enter %d student name t",i);
scanf("%s",&name);
printf("n enter %d student usn t",i);
scanf("%d",&usn);
printf("n enter %d student marks t",i);
scanf("%d",&marks);
fprintf(fp,"%st%dt%dn",name,usn,marks);
}
fclose(fp);
fp=fopen("student.dat","r");
printf("students records are n");
for(i=1;i<=n;i++)
{
fscanf(fp,"%s%d%d",&name,&usn,&marks);
printf("nnn name of %d student=%s",i,name);
printf("n usn of %d student=%d",i,usn);
printf("n marks of %d student=%d",i,marks);
}
fclose(fp);
getch();
}
13. wap to creat and count number of character in a file.
#include<stdio.h>
void main()
34. {
FILE *f;
char fname[20],c;
int ctr=0;
clrscr();
f=fopen("rj","w");
fclose(f);
printf("n enter the file name to openn");
scanf("%s",fname);
f=fopen("fname","r");
if (!f)
printf("n file not exist..permission denied");
else
{
c=getc(f);
for(;getc(f)!=EOF;ctr++)
{
}
printf("n total count of character is %d",ctr);
}
getch();
}
35. 14. WAP to handle file with mixed data type.
#include<stdio.h>
struct emp
{
char name[20];
int empno;
float sal;
char status[10];
};
void main()
{
typedef struct emp s;
s s1;
FILE *f;
clrscr();
f=fopen("deepak.txt","w");
/* if(!f)
puts("file not exist.permission denied");
else
{ */
printf("...employee details......n");
printf("n enter the employee name=");
scanf("%s",s1.name);
//fflush(stdin);
printf("n enter the employee number =");
scanf("%d",&s1.empno);
36. printf("n enter employee salary=");
scanf("%f",&s1.sal);
// fflush(stdin);
printf("n enter the employee status=");
scanf("%s",s1.status);
// fprintf(f,"%s%d%f%c",s1.name,s1.empno,s1.sal,s1.status);
fclose(f);
f=fopen("deepak.txt","r");
// fscanf(f,"%s%d%f%c",s1.name,&s1.empno,&s1.sal,s1.status);
printf("n name=%s",s1.name);
printf("n emp number =%d",s1.empno);
printf("n employee salary=%f",s1.sal);
printf("n employee status=%s",s1.status);
fclose(f);
getch();
}