Print the characters of String with space

Description

Get  a String and Prints it characters with Space
Input:
Hello
Output:
H e l l o 

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;
}

	

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.



Interesting Pattern Programs: for more Patterns

Input:
5
Output:
*
**
***
****
*****
****
***
**
*Solution
Input:
5
Output:
    *
   ***
  *****
 *******
*********
 *******
  *****
   ***
    *Solution
Input:
5
Output:
*        *
**      **
***    ***
****  ****
**********Solution
Input:
5
Output:
*       *
**     **
***   ***
**** ****
*********Solution
Input:
5
Output:
*       *
**     **
***   ***
**** ****
*********
**** ****
***   ***
**     **
*       *Solution
Input:
5
Output:
*********
 *******
  *****
   ***
    *
   ***
  *****
 *******
*********Solution