Input and Output of a string C Program

Estimated read time 2 min read

Input and Output of a string C Program demonstrates the input and output of a string in C programming language. The char data type is used to declare a string name of size 100.

The scanf function is used to take input from the user and store it in the variable name. The %s format specifier is used to read a string value.

The printf function is used to print the message “Your name is: %s” on the screen.

These are some of the basic input and output programs in C programming language. These programs will help you understand how to take input from the user and how to display output on the screen in C programming language.

Input and Output of a string C Program
Input and Output of a string C Program
#include <stdio.h>

int main()
{
    char name[100];
    printf("Enter your name: ");
    scanf("%s", name);
    printf("Your name is: %s", name);
    return 0;
}

OUTPUT
Enter your name: John
Your name is: John
admin https://study-from-here.com

Digital Marketing Consultants and Social Media Marketing Expert with over 3 years of rich experience in various Branding, Promotions, business directories, On pages and off page optimization, Link building Advertising, Research, paid advertisement, content writing and marketing

You May Also Like

More From Author

+ There are no comments

Add yours