SlideShare a Scribd company logo
S2-3
Write a program in ‘C’ language to accept a paragraph of text as input.
Make a list of words and the number of occurrences of each word in the paragraph
as output.
As part of the processing, an array and structure should be created wherein
each structure consists of two fields, namely, one for storing the word and
the other for storing the number of occurrences of that word.
#include<stdio.h>
#include<conio.h>
struct paragraph
{
char words[15];
int occ;
}p[50];
void main()
{
int i=0,j=0,k=0,flag=0;
char w[15],ch=0;
clrscr();
strcpy(w," ");
printf("Enter the paragraphn");
while(ch!='n')
{
flag=0;
strcpy(p[j].words,"");
p[j].occ=1;
ch=getchar();
w[i]=ch;
i++;
if(ch==' ')
{
w[i]='0';
for(k=0;k<=j;++k)
if(strcmp(p[k].words,w)==0)
{
p[k].occ++;
flag=1;
}
if(flag==0)
{
strcpy(p[j].words,w);
++j;
}
strcpy(w," ");
i=0;
}
}
printf("wordsttoccurancen");
for(i=0;i<j;i++)
printf("%stt%dn",p[i].words,p[i].occ);
getch();
}
Page 1

More Related Content

What's hot (16)

PDF
Program in ‘C’ language to implement linear search using pointers
Dr. Loganathan R
 
PDF
Bcsl 033 data and file structures lab s3-2
Dr. Loganathan R
 
PDF
Implement a queue using two stacks.
Dr. Loganathan R
 
PDF
Bcsl 033 data and file structures lab s5-2
Dr. Loganathan R
 
PPTX
C Programming Example
University of Potsdam
 
PDF
Bcsl 033 data and file structures lab s1-4
Dr. Loganathan R
 
PDF
C Programming Example
PRATHAMESH DESHPANDE
 
PPTX
Computer programing w
cexpertise
 
DOCX
1 (1)
Krish Na
 
DOC
Add digits of number in c
mohdshanu
 
PDF
Odd number
Ankit Dubey
 
PDF
SATySFiのこれからの課題たち
T. Suwa
 
Program in ‘C’ language to implement linear search using pointers
Dr. Loganathan R
 
Bcsl 033 data and file structures lab s3-2
Dr. Loganathan R
 
Implement a queue using two stacks.
Dr. Loganathan R
 
Bcsl 033 data and file structures lab s5-2
Dr. Loganathan R
 
C Programming Example
University of Potsdam
 
Bcsl 033 data and file structures lab s1-4
Dr. Loganathan R
 
C Programming Example
PRATHAMESH DESHPANDE
 
Computer programing w
cexpertise
 
1 (1)
Krish Na
 
Add digits of number in c
mohdshanu
 
Odd number
Ankit Dubey
 
SATySFiのこれからの課題たち
T. Suwa
 

Similar to Bcsl 033 data and file structures lab s2-3 (20)

DOCX
Cd practical file (1) start se
dalipkumar64
 
PDF
String
SANTOSH RATH
 
DOCX
string , pointer
Arafat Bin Reza
 
PPTX
C programming
Samsil Arefin
 
DOCX
Mouse programming in c
gkgaur1987
 
PDF
C- Programming Assignment 3
Animesh Chaturvedi
 
PDF
C programms
Mukund Gandrakota
 
PDF
Strings IN C
yndaravind
 
PPTX
String_C.pptx
HARSHITHA EBBALI
 
PPSX
Concepts of C [Module 2]
Abhishek Sinha
 
PDF
Numerical analysis
Vishal Singh
 
DOCX
Cs project
Dhairya Pant
 
PDF
Principals of Programming in CModule -5.pdfModule-4.pdf
anilcsbs
 
PDF
Data Structure in C Programming Language
Arkadeep Dey
 
DOCX
C Programming
Sumant Diwakar
 
PDF
Data structure week 3
karmuhtam
 
PPTX
Introduction about Low Level Programming using C
PadmavathiKPSGCAS
 
DOCX
Compiler Design Lab File
Kandarp Tiwari
 
PDF
Look Ma, “update DB to HTML5 using C++”, no hands! 
aleks-f
 
DOC
Assignment c programming
Icaii Infotech
 
Cd practical file (1) start se
dalipkumar64
 
String
SANTOSH RATH
 
string , pointer
Arafat Bin Reza
 
C programming
Samsil Arefin
 
Mouse programming in c
gkgaur1987
 
C- Programming Assignment 3
Animesh Chaturvedi
 
C programms
Mukund Gandrakota
 
Strings IN C
yndaravind
 
String_C.pptx
HARSHITHA EBBALI
 
Concepts of C [Module 2]
Abhishek Sinha
 
Numerical analysis
Vishal Singh
 
Cs project
Dhairya Pant
 
Principals of Programming in CModule -5.pdfModule-4.pdf
anilcsbs
 
Data Structure in C Programming Language
Arkadeep Dey
 
C Programming
Sumant Diwakar
 
Data structure week 3
karmuhtam
 
Introduction about Low Level Programming using C
PadmavathiKPSGCAS
 
Compiler Design Lab File
Kandarp Tiwari
 
Look Ma, “update DB to HTML5 using C++”, no hands! 
aleks-f
 
Assignment c programming
Icaii Infotech
 
Ad

More from Dr. Loganathan R (17)

PDF
Ch 6 IoT Processing Topologies and Types.pdf
Dr. Loganathan R
 
PDF
IoT Sensing and Actuation.pdf
Dr. Loganathan R
 
PDF
Ch 4 Emergence of IoT.pdf
Dr. Loganathan R
 
PDF
Bcsl 033 data and file structures lab s4-3
Dr. Loganathan R
 
PDF
Bcsl 033 data and file structures lab s1-2
Dr. Loganathan R
 
PPT
Introduction to Information Security
Dr. Loganathan R
 
PDF
Mcs 012 computer organisation and assemly language programming- ignou assignm...
Dr. Loganathan R
 
PDF
Session 9 4 alp to display the current system time using dos int 21 h
Dr. Loganathan R
 
PDF
Session 9 1 alp to compute a grade using procedures
Dr. Loganathan R
 
PDF
IGNOU Assembly Language Programming
Dr. Loganathan R
 
PDF
Requirement engineering process
Dr. Loganathan R
 
PDF
MCS 012 computer organisation and assembly language programming assignment…
Dr. Loganathan R
 
PDF
Software requirements
Dr. Loganathan R
 
PDF
Software process
Dr. Loganathan R
 
PDF
Software engineering critical systems
Dr. Loganathan R
 
PDF
Software engineering socio-technical systems
Dr. Loganathan R
 
PDF
Software engineering introduction
Dr. Loganathan R
 
Ch 6 IoT Processing Topologies and Types.pdf
Dr. Loganathan R
 
IoT Sensing and Actuation.pdf
Dr. Loganathan R
 
Ch 4 Emergence of IoT.pdf
Dr. Loganathan R
 
Bcsl 033 data and file structures lab s4-3
Dr. Loganathan R
 
Bcsl 033 data and file structures lab s1-2
Dr. Loganathan R
 
Introduction to Information Security
Dr. Loganathan R
 
Mcs 012 computer organisation and assemly language programming- ignou assignm...
Dr. Loganathan R
 
Session 9 4 alp to display the current system time using dos int 21 h
Dr. Loganathan R
 
Session 9 1 alp to compute a grade using procedures
Dr. Loganathan R
 
IGNOU Assembly Language Programming
Dr. Loganathan R
 
Requirement engineering process
Dr. Loganathan R
 
MCS 012 computer organisation and assembly language programming assignment…
Dr. Loganathan R
 
Software requirements
Dr. Loganathan R
 
Software process
Dr. Loganathan R
 
Software engineering critical systems
Dr. Loganathan R
 
Software engineering socio-technical systems
Dr. Loganathan R
 
Software engineering introduction
Dr. Loganathan R
 
Ad

Recently uploaded (20)

PDF
The dynastic history of the Chahmana.pdf
PrachiSontakke5
 
PDF
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
PDF
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
PPTX
grade 5 lesson ENGLISH 5_Q1_PPT_WEEK3.pptx
SireQuinn
 
PPTX
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
PDF
Lesson 2 - WATER,pH, BUFFERS, AND ACID-BASE.pdf
marvinnbustamante1
 
PPTX
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
PPTX
Views on Education of Indian Thinkers Mahatma Gandhi.pptx
ShrutiMahanta1
 
PPTX
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
PDF
community health nursing question paper 2.pdf
Prince kumar
 
PPTX
HYDROCEPHALUS: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
PPTX
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
PDF
SSHS-2025-PKLP_Quarter-1-Dr.-Kerby-Alvarez.pdf
AishahSangcopan1
 
PDF
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
PPTX
Soil and agriculture microbiology .pptx
Keerthana Ramesh
 
PPTX
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
PDF
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
PPTX
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
PPTX
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
PPT
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
The dynastic history of the Chahmana.pdf
PrachiSontakke5
 
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
grade 5 lesson ENGLISH 5_Q1_PPT_WEEK3.pptx
SireQuinn
 
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
Lesson 2 - WATER,pH, BUFFERS, AND ACID-BASE.pdf
marvinnbustamante1
 
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
Views on Education of Indian Thinkers Mahatma Gandhi.pptx
ShrutiMahanta1
 
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
community health nursing question paper 2.pdf
Prince kumar
 
HYDROCEPHALUS: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
SSHS-2025-PKLP_Quarter-1-Dr.-Kerby-Alvarez.pdf
AishahSangcopan1
 
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
Soil and agriculture microbiology .pptx
Keerthana Ramesh
 
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 

Bcsl 033 data and file structures lab s2-3

  • 1. S2-3 Write a program in ‘C’ language to accept a paragraph of text as input. Make a list of words and the number of occurrences of each word in the paragraph as output. As part of the processing, an array and structure should be created wherein each structure consists of two fields, namely, one for storing the word and the other for storing the number of occurrences of that word. #include<stdio.h> #include<conio.h> struct paragraph { char words[15]; int occ; }p[50]; void main() { int i=0,j=0,k=0,flag=0; char w[15],ch=0; clrscr(); strcpy(w," "); printf("Enter the paragraphn"); while(ch!='n') { flag=0; strcpy(p[j].words,""); p[j].occ=1; ch=getchar(); w[i]=ch; i++; if(ch==' ') { w[i]='0'; for(k=0;k<=j;++k) if(strcmp(p[k].words,w)==0) { p[k].occ++; flag=1; } if(flag==0) { strcpy(p[j].words,w); ++j; } strcpy(w," "); i=0; } } printf("wordsttoccurancen"); for(i=0;i<j;i++) printf("%stt%dn",p[i].words,p[i].occ); getch(); } Page 1