Program to enter N words and convert them into sentence.

//Enter the Number of words and combine them into sentence.
#include<stdio.h>
#include<string.h>
int main()
{
    int n, i;
    char words[20];
    char sentence[500]="";
    printf("Enter Number of Words: ");
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
    printf("Word-%d: ",i);
    scanf("%s",&words);
    strcat(sentence," ");
    strcat(sentence,words);
    }
    strcat(sentence,".");
    printf("\nSentence formed is %s\n",sentence);
    return 0;
}


1 comment:

Post your comments

Powered by Blogger.