Take Sentence as input in C

Write a program to take input sentence in c

C Program
#include <stdio.h>

int main()
{
    char str[1000];

    printf("Enter a sentence : ");
    scanf("%[^\n]%*c"str);
    printf("Your sentence is\n"str);
    printf("%s"str);
    return 0;
}

Input:

Enter a sentence : This is a C Program
Output:

Your sentence is This is a C Program


No comments:

Post a Comment