Coding Structure for dot.program

A idea for a simple program which prints dot in each new line with increasing no of spaces. output may be like this,

 .
  .
   .
    .
     .
      .
       .
        .

I tried it with a recursive function but it doesn't work quite expected.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>
using namespace std;

char maker(char e)
{
	
	cout << "." << e;
	cout << maker(e);
	return 1;
	
}

int main()
{
	char a = '.';
	maker(a);
	return 0;
}

Help would be appreciated
Last edited on
Alot of weird stuff is in your code. I think you should not use recursive functions until you have a solid understanding of how all programming systems works (not to be harsh). Stick with for loops.
1
2
3
4
5
6
int dot_count = 8;
for(int y = 0; y < dot_count; ++y){
  for(int x = 0; x < y; ++x)
    std::cout<<" ";
  std::cout<<".\n";
}
Last edited on
Topic archived. No new replies allowed.