SlideShare a Scribd company logo
1 of 4
Download to read offline
// C code
#include
#include
#include
#include
#include
#include
void sortInputstring(char*);
void main()
{
char input[100];
printf("Enter the string ");
scanf(" %[^ ]s", input);
sortInputstring(input);
}
void sortInputstring(char *str)
{
int i, j, k, ws = 0;
char p[50][100],temp[50];
char *c;
c=str;
for (i = 0;i < strlen(str);i++)
{
if ((str[i] == ' ')||(str[i] == ',')||(str[i] == '.'))
{
ws++;
}
}
for (i = 0, j = 0, k = 0;j < strlen(str);j++)
{
if ((str[j] == ' ')||(str[j] == 44)||(str[j] == 46))
{
p[i][k] = '0';
i++;
k = 0;
}
else
p[i][k++] = str[j];
}
for (i = 0;i 0))
{
strcpy(temp, p[i]);
strcpy(p[i], p[j]);
strcpy(p[j], temp);
}
}
}
printf(" Sorting the input string:  ");
for (i = 0;i <= ws;i++)
{
printf(" %s ", p[i]);
}
}
/*
output:
Enter the string
things stuff otherstuff blarp
Sorting the input string:
blarp
otherstuff
stuff
things
*/
Solution
// C code
#include
#include
#include
#include
#include
#include
void sortInputstring(char*);
void main()
{
char input[100];
printf("Enter the string ");
scanf(" %[^ ]s", input);
sortInputstring(input);
}
void sortInputstring(char *str)
{
int i, j, k, ws = 0;
char p[50][100],temp[50];
char *c;
c=str;
for (i = 0;i < strlen(str);i++)
{
if ((str[i] == ' ')||(str[i] == ',')||(str[i] == '.'))
{
ws++;
}
}
for (i = 0, j = 0, k = 0;j < strlen(str);j++)
{
if ((str[j] == ' ')||(str[j] == 44)||(str[j] == 46))
{
p[i][k] = '0';
i++;
k = 0;
}
else
p[i][k++] = str[j];
}
for (i = 0;i 0))
{
strcpy(temp, p[i]);
strcpy(p[i], p[j]);
strcpy(p[j], temp);
}
}
}
printf(" Sorting the input string:  ");
for (i = 0;i <= ws;i++)
{
printf(" %s ", p[i]);
}
}
/*
output:
Enter the string
things stuff otherstuff blarp
Sorting the input string:
blarp
otherstuff
stuff
things
*/

More Related Content

Similar to C code #include stdio.h #include stdlib.h #include mat.pdf

Java AssignmentWrite a program using sortingsorting bubble,sele.pdf
Java AssignmentWrite a program using sortingsorting bubble,sele.pdfJava AssignmentWrite a program using sortingsorting bubble,sele.pdf
Java AssignmentWrite a program using sortingsorting bubble,sele.pdf
eyewatchsystems
 
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
rushabhshah600
 
Data StructuresPLEASE USING THIS C++ PROGRAM BELOW, I NEED HEL.pdf
Data StructuresPLEASE USING THIS C++ PROGRAM BELOW, I NEED HEL.pdfData StructuresPLEASE USING THIS C++ PROGRAM BELOW, I NEED HEL.pdf
Data StructuresPLEASE USING THIS C++ PROGRAM BELOW, I NEED HEL.pdf
rozakashif85
 
#include ctype.h #include stdio.h #include string.hstati.pdf
#include ctype.h #include stdio.h #include string.hstati.pdf#include ctype.h #include stdio.h #include string.hstati.pdf
#include ctype.h #include stdio.h #include string.hstati.pdf
apleather
 
Daapracticals 111105084852-phpapp02
Daapracticals 111105084852-phpapp02Daapracticals 111105084852-phpapp02
Daapracticals 111105084852-phpapp02
Er Ritu Aggarwal
 
Hi, Please find my codeimport java.util.Random;public class Pro.pdf
Hi, Please find my codeimport java.util.Random;public class Pro.pdfHi, Please find my codeimport java.util.Random;public class Pro.pdf
Hi, Please find my codeimport java.util.Random;public class Pro.pdf
anujsharmaanuj14
 
#include String.hpp#include ..Functionsfunctions.hpp.docx
#include String.hpp#include ..Functionsfunctions.hpp.docx#include String.hpp#include ..Functionsfunctions.hpp.docx
#include String.hpp#include ..Functionsfunctions.hpp.docx
gertrudebellgrove
 

Similar to C code #include stdio.h #include stdlib.h #include mat.pdf (20)

12 1 문자열
12 1 문자열12 1 문자열
12 1 문자열
 
SPL 13 | Character Array(String) in C
SPL 13 | Character Array(String) in CSPL 13 | Character Array(String) in C
SPL 13 | Character Array(String) in C
 
Java AssignmentWrite a program using sortingsorting bubble,sele.pdf
Java AssignmentWrite a program using sortingsorting bubble,sele.pdfJava AssignmentWrite a program using sortingsorting bubble,sele.pdf
Java AssignmentWrite a program using sortingsorting bubble,sele.pdf
 
Data Structure in C Programming Language
Data Structure in C Programming LanguageData Structure in C Programming Language
Data Structure in C Programming Language
 
C program
C programC program
C program
 
4. chapter iii
4. chapter iii4. chapter iii
4. chapter iii
 
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
 
Data Structures Using C Practical File
Data Structures Using C Practical File Data Structures Using C Practical File
Data Structures Using C Practical File
 
Data StructuresPLEASE USING THIS C++ PROGRAM BELOW, I NEED HEL.pdf
Data StructuresPLEASE USING THIS C++ PROGRAM BELOW, I NEED HEL.pdfData StructuresPLEASE USING THIS C++ PROGRAM BELOW, I NEED HEL.pdf
Data StructuresPLEASE USING THIS C++ PROGRAM BELOW, I NEED HEL.pdf
 
#include ctype.h #include stdio.h #include string.hstati.pdf
#include ctype.h #include stdio.h #include string.hstati.pdf#include ctype.h #include stdio.h #include string.hstati.pdf
#include ctype.h #include stdio.h #include string.hstati.pdf
 
Daapracticals 111105084852-phpapp02
Daapracticals 111105084852-phpapp02Daapracticals 111105084852-phpapp02
Daapracticals 111105084852-phpapp02
 
week-6x
week-6xweek-6x
week-6x
 
Hi, Please find my codeimport java.util.Random;public class Pro.pdf
Hi, Please find my codeimport java.util.Random;public class Pro.pdfHi, Please find my codeimport java.util.Random;public class Pro.pdf
Hi, Please find my codeimport java.util.Random;public class Pro.pdf
 
#include String.hpp#include ..Functionsfunctions.hpp.docx
#include String.hpp#include ..Functionsfunctions.hpp.docx#include String.hpp#include ..Functionsfunctions.hpp.docx
#include String.hpp#include ..Functionsfunctions.hpp.docx
 
InsertionSort.pdf
InsertionSort.pdfInsertionSort.pdf
InsertionSort.pdf
 
[3] 프로세싱과 아두이노
[3] 프로세싱과 아두이노[3] 프로세싱과 아두이노
[3] 프로세싱과 아두이노
 
Os lab file c programs
Os lab file c programsOs lab file c programs
Os lab file c programs
 
Nonlinear analysis of frame with hinge by hinge method in c programming
Nonlinear analysis of frame with hinge by hinge method in c programmingNonlinear analysis of frame with hinge by hinge method in c programming
Nonlinear analysis of frame with hinge by hinge method in c programming
 
C lab manaual
C lab manaualC lab manaual
C lab manaual
 
Cpd lecture im 207
Cpd lecture im 207Cpd lecture im 207
Cpd lecture im 207
 

More from ANANDSALESINDIA105

i do not agree with above statement. Mathematics is something relate.pdf
i do not agree with above statement. Mathematics is something relate.pdfi do not agree with above statement. Mathematics is something relate.pdf
i do not agree with above statement. Mathematics is something relate.pdf
ANANDSALESINDIA105
 
Human - ecosystem interaction is sustainable when the social system .pdf
Human - ecosystem interaction is sustainable when the social system .pdfHuman - ecosystem interaction is sustainable when the social system .pdf
Human - ecosystem interaction is sustainable when the social system .pdf
ANANDSALESINDIA105
 
Here is the code.compile g++ Playlist.cpp main.cppPlaylist.h.pdf
Here is the code.compile  g++ Playlist.cpp main.cppPlaylist.h.pdfHere is the code.compile  g++ Playlist.cpp main.cppPlaylist.h.pdf
Here is the code.compile g++ Playlist.cpp main.cppPlaylist.h.pdf
ANANDSALESINDIA105
 
Exempt waste & very low level wasteExempt waste and very low level.pdf
Exempt waste & very low level wasteExempt waste and very low level.pdfExempt waste & very low level wasteExempt waste and very low level.pdf
Exempt waste & very low level wasteExempt waste and very low level.pdf
ANANDSALESINDIA105
 
Diatoms are unicellular photosynthetic algae. These phytoplankton mi.pdf
Diatoms are unicellular photosynthetic algae. These phytoplankton mi.pdfDiatoms are unicellular photosynthetic algae. These phytoplankton mi.pdf
Diatoms are unicellular photosynthetic algae. These phytoplankton mi.pdf
ANANDSALESINDIA105
 

More from ANANDSALESINDIA105 (20)

where is the data .pdf
                     where is the data                                .pdf                     where is the data                                .pdf
where is the data .pdf
 
the insoluble compound in the unknown be represen.pdf
                     the insoluble compound in the unknown be represen.pdf                     the insoluble compound in the unknown be represen.pdf
the insoluble compound in the unknown be represen.pdf
 
That is true. An element is in its simplest for.pdf
                     That is true. An element is in its simplest for.pdf                     That is true. An element is in its simplest for.pdf
That is true. An element is in its simplest for.pdf
 
Mass of mixture = 1+50.3 = 51.3 g Ratio = 150.3 .pdf
                     Mass of mixture = 1+50.3 = 51.3 g Ratio = 150.3 .pdf                     Mass of mixture = 1+50.3 = 51.3 g Ratio = 150.3 .pdf
Mass of mixture = 1+50.3 = 51.3 g Ratio = 150.3 .pdf
 
Lewis dot structure looks like this S=C=N .pdf
                     Lewis dot structure looks like this  S=C=N  .pdf                     Lewis dot structure looks like this  S=C=N  .pdf
Lewis dot structure looks like this S=C=N .pdf
 
Fluoride is an ion that comes from a weak acid. K.pdf
                     Fluoride is an ion that comes from a weak acid. K.pdf                     Fluoride is an ion that comes from a weak acid. K.pdf
Fluoride is an ion that comes from a weak acid. K.pdf
 
Usually the K+ ions will be more inside the cell during nerve impuls.pdf
Usually the K+ ions will be more inside the cell during nerve impuls.pdfUsually the K+ ions will be more inside the cell during nerve impuls.pdf
Usually the K+ ions will be more inside the cell during nerve impuls.pdf
 
trend plus irregularNone of thesetrend plus seasonalSolution.pdf
trend plus irregularNone of thesetrend plus seasonalSolution.pdftrend plus irregularNone of thesetrend plus seasonalSolution.pdf
trend plus irregularNone of thesetrend plus seasonalSolution.pdf
 
Solution.Calculation of Statement of stockholder equity For the ye.pdf
Solution.Calculation of Statement of stockholder equity For the ye.pdfSolution.Calculation of Statement of stockholder equity For the ye.pdf
Solution.Calculation of Statement of stockholder equity For the ye.pdf
 
Solution 9 - (E) $16000Calculation of amount of goodwill at Jnauar.pdf
Solution 9 - (E) $16000Calculation of amount of goodwill at Jnauar.pdfSolution 9 - (E) $16000Calculation of amount of goodwill at Jnauar.pdf
Solution 9 - (E) $16000Calculation of amount of goodwill at Jnauar.pdf
 
Receptor mediated endocytosisThe receptor for low density lipoprot.pdf
Receptor mediated endocytosisThe receptor for low density lipoprot.pdfReceptor mediated endocytosisThe receptor for low density lipoprot.pdf
Receptor mediated endocytosisThe receptor for low density lipoprot.pdf
 
Question 14ans data and instructionsQuestion 15ans data .pdf
Question 14ans  data and instructionsQuestion 15ans  data .pdfQuestion 14ans  data and instructionsQuestion 15ans  data .pdf
Question 14ans data and instructionsQuestion 15ans data .pdf
 
option D is correctSolutionoption D is correct.pdf
option D is correctSolutionoption D is correct.pdfoption D is correctSolutionoption D is correct.pdf
option D is correctSolutionoption D is correct.pdf
 
pH is defined as negative log of concentration of H+ ion in solution.pdf
pH is defined as negative log of concentration of H+ ion in solution.pdfpH is defined as negative log of concentration of H+ ion in solution.pdf
pH is defined as negative log of concentration of H+ ion in solution.pdf
 
Mass of hydrogen = (8.1 x 10256.02 x 1023) mol x 1 gmol= 134.6 g.pdf
Mass of hydrogen = (8.1 x 10256.02 x 1023) mol x 1 gmol= 134.6 g.pdfMass of hydrogen = (8.1 x 10256.02 x 1023) mol x 1 gmol= 134.6 g.pdf
Mass of hydrogen = (8.1 x 10256.02 x 1023) mol x 1 gmol= 134.6 g.pdf
 
i do not agree with above statement. Mathematics is something relate.pdf
i do not agree with above statement. Mathematics is something relate.pdfi do not agree with above statement. Mathematics is something relate.pdf
i do not agree with above statement. Mathematics is something relate.pdf
 
Human - ecosystem interaction is sustainable when the social system .pdf
Human - ecosystem interaction is sustainable when the social system .pdfHuman - ecosystem interaction is sustainable when the social system .pdf
Human - ecosystem interaction is sustainable when the social system .pdf
 
Here is the code.compile g++ Playlist.cpp main.cppPlaylist.h.pdf
Here is the code.compile  g++ Playlist.cpp main.cppPlaylist.h.pdfHere is the code.compile  g++ Playlist.cpp main.cppPlaylist.h.pdf
Here is the code.compile g++ Playlist.cpp main.cppPlaylist.h.pdf
 
Exempt waste & very low level wasteExempt waste and very low level.pdf
Exempt waste & very low level wasteExempt waste and very low level.pdfExempt waste & very low level wasteExempt waste and very low level.pdf
Exempt waste & very low level wasteExempt waste and very low level.pdf
 
Diatoms are unicellular photosynthetic algae. These phytoplankton mi.pdf
Diatoms are unicellular photosynthetic algae. These phytoplankton mi.pdfDiatoms are unicellular photosynthetic algae. These phytoplankton mi.pdf
Diatoms are unicellular photosynthetic algae. These phytoplankton mi.pdf
 

Recently uploaded

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 

Recently uploaded (20)

How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 

C code #include stdio.h #include stdlib.h #include mat.pdf

  • 1. // C code #include #include #include #include #include #include void sortInputstring(char*); void main() { char input[100]; printf("Enter the string "); scanf(" %[^ ]s", input); sortInputstring(input); } void sortInputstring(char *str) { int i, j, k, ws = 0; char p[50][100],temp[50]; char *c; c=str; for (i = 0;i < strlen(str);i++) { if ((str[i] == ' ')||(str[i] == ',')||(str[i] == '.')) { ws++; } } for (i = 0, j = 0, k = 0;j < strlen(str);j++) { if ((str[j] == ' ')||(str[j] == 44)||(str[j] == 46)) { p[i][k] = '0'; i++;
  • 2. k = 0; } else p[i][k++] = str[j]; } for (i = 0;i 0)) { strcpy(temp, p[i]); strcpy(p[i], p[j]); strcpy(p[j], temp); } } } printf(" Sorting the input string: "); for (i = 0;i <= ws;i++) { printf(" %s ", p[i]); } } /* output: Enter the string things stuff otherstuff blarp Sorting the input string: blarp otherstuff stuff things */ Solution // C code #include
  • 3. #include #include #include #include #include void sortInputstring(char*); void main() { char input[100]; printf("Enter the string "); scanf(" %[^ ]s", input); sortInputstring(input); } void sortInputstring(char *str) { int i, j, k, ws = 0; char p[50][100],temp[50]; char *c; c=str; for (i = 0;i < strlen(str);i++) { if ((str[i] == ' ')||(str[i] == ',')||(str[i] == '.')) { ws++; } } for (i = 0, j = 0, k = 0;j < strlen(str);j++) { if ((str[j] == ' ')||(str[j] == 44)||(str[j] == 46)) { p[i][k] = '0'; i++; k = 0; } else
  • 4. p[i][k++] = str[j]; } for (i = 0;i 0)) { strcpy(temp, p[i]); strcpy(p[i], p[j]); strcpy(p[j], temp); } } } printf(" Sorting the input string: "); for (i = 0;i <= ws;i++) { printf(" %s ", p[i]); } } /* output: Enter the string things stuff otherstuff blarp Sorting the input string: blarp otherstuff stuff things */