w3resource logo


C Programming Exercises

C Exercises: Print a block F using hash (#)

Secondary Nav

C Basic Declarations and Expressions : Exercise-2 with Solution

Write a C program to print a block F using hash (#), where the F has a height of six characters and width of five and four characters.

Expected Output :

######
#
#
#####
#
#
#

C Code:

#include <stdio.h> 
 int main() 
 {
	printf("######\n");
	printf("#\n");
	printf("#\n");
	printf("#####\n");
	printf("#\n");
	printf("#\n");
	printf("#\n");

	return(0);
}

Solution

#include <stdio.h> 
 int main() 
 {
	printf("######\n");
	printf("#\n");
	printf("#\n");
	printf("#####\n");
	printf("#\n");
	printf("#\n");
	printf("#\n");

	return(0);
}

Improve this sample solution and post your code through Disqus.



Join our Question Answer community to learn and share your programming knowledge.

Solve these problems:

Java: How to convert a string to an integer in Java?

C#: Loops in c#

SQL: JOIN using more than 5 tables