We, beginners, should help each other.:)
Here you are. The code is written in C++. So you need to investigate it and rewrite it in C yourself.
#include <iostream>
int main()
{
while ( true )
{
std::cout << "Input the number of elements : ";
unsigned int n;
if ( not ( std::cin >> n ) or ( n == 0 ) ) break;
std::cout << "Input the size of each element : ";
unsigned int m;
if ( not ( std::cin >> m ) or ( m == 0 ) ) break;
std::cout << '\n';
for ( unsigned int i = 0; i < m + 2; i++ )
{
char c1 = i == 0 || i == m + 1 ? '+' : '|';
char c2 = i == 0 || i == m + 1 ? '-' : ' ';
for ( unsigned int j = 0; j < n + m * ( n - 1 ); j++ )
{
std::cout << ( j % (m + 1) == 0 ? c1 : c2 );
}
std::cout << '\n';
}
std::cout << std::endl;
}
return 0;
}
The program output might look the following way
Input the number of elements : 10
Input the size of each element : 3
+---+---+---+---+---+---+---+---+---+
| | | | | | | | | |
| | | | | | | | | |
| | | | | | | | | |
+---+---+---+---+---+---+---+---+---+
Input the number of elements : 0
solved Pattern by means of function