codescracker


c

C Program to Print String



« Previous Program Next Program »


Print String in C

To print a string in C programming, use printf() function with format specifier %s as shown here in the following program.

C Programming Code to Print String

Following C program ask to the user to enter a string like your first name, then it will display your first name after Hello, :

/* C Program - Print String */
		
#include<stdio.h>
#include<conio.h>
void main()
{
	clrscr();
	char str[20];
	printf("Enter your first name : ");
	scanf("%s",str);
	printf("Hello, %s",str);
	getch();
}

When the above c program is compile and executed, it will produce the following result:

c program print string

Same Program in Other Programming Language

You may also like same program in other programming languages:


« Previous Program Next Program »



Tools
Calculator

Quick Links
Signup - Login - Give Online Test