Decode School

Decode School - The School for Problem Solvers
Welcome to My Blog.
Need Assignment / Project Guidance (or) Training in Python?

Print the characters of String with space

Get a String and Prints it characters with Space

Sample Input 1:

Hello

Sample Output 1:

H e l l o

Program or Solution

					    
							
#include<stdio.h>
int main()
{
	char str[50];
	int i = 0;
	fgets(str,50,stdin);
	while(str[i]!='\0')
	{
		printf("%c ",str[i++]);
	}
	return 0;
}

	

					    
					

Program Explanation

Get a String using fgets() function.

Str -> reads the string and stores it in str.

50 -> reads maximum of 50 characters stdin-> reads character from keyboard using for loop print all characters one by one.

"%c " in printf prints character with space.