Showing posts with label Paragraph. Show all posts
Showing posts with label Paragraph. Show all posts

C Program To Print Lines Of A Paragraph Having More Than 15 Characters

How to write a C Program To Print Lines Of A Paragraph Having More Than 15 Characters in C Programming Language ?


Solution For C Program :

/*C Program To Print Lines Of A Paragraph Having More Than 15 Characters.*/

#include<stdio.h>
#include<conio.h>

void main()
{
int i=0,n=0;
char c,s[500],temp[100];
clrscr();
printf("\nEnter the paragraph, to stop writing press (CTRL+Z)\n");
/*following code will stop reading after pressing Ctrl+Z :*/
while((c=getch())!='\x1A')
    {
    if(c=='\r')
        {
        printf("\n");
        s[i++]='\n';
        }
    else
        {
        printf("%c",c);
        s[i++]=c;
        }
    }
/*choosing lines with more than 15 characters.*/
for(i=0;s[i]!='\0';i++)
    {
    temp[n]=s[i];
    n++;
    if(s[i]=='\n')
        {
        temp[n]='\0';
        if(n>15)
        printf("\n\t%s",temp);
        n=0;
        }
    }
    if(n>15)
        {
        temp[n]='\0';
        printf("\n\t%s",temp);
        }
getch();
}


You may also learn these C Program/Code :

C Program To Swap Two Numbers Without Using Third Variable



C Program to count number of sentences words and letters in a paragraph

How to write a C Program to count number of sentences words and letters in a paragraph in C Programming Language ?

This C Program to count number of sentences words and letters in a paragraph.

Solution:

  1. #include<stdio.h>
  2. main()
  3. {
  4.         char ch[150];
  5.         int i,c=0,c1=0,c2=0;
  6.         printf("Enter a Paragraph \n");
  7.         gets(ch);
  8.         for(i=0;ch[i]!='\0';i++)
  9.         {
  10.                 if(ch[i]=='.'||ch[i]=='!'||ch[i]=='?')
  11.                 {       c++;
  12.                         c1++;
  13.                 }
  14.                 else if(ch[i]==' '||ch[i]==',')
  15.                         c1++;
  16.                 else if(ch[i]>65&&ch[i]<123)
  17.                         c2++;
  18.         }
  19.         printf("\nNumber of letters = %d \nNumber of words=%d ",c2,c1);
  20.         printf("\nNumber of Sentences = %d\n",c);
  21. }