Need Help!

closed account (9wX36Up4)
#include<stdio.h>

int main()
{
     char shape;
     int i=1,k,x,y;
     
     printf("Shape :");
     scanf("%c",&shape);
     printf("Column :");
     scanf("%d",&x);
     printf("Line :");
     scanf("%d",&y);
     
     while(i<=y)
     {
          k=1;
          while(k<=x)
          {
                printf("%c",shape);
                k++;
          }
          i++;
          printf("\n");
     }
     
     return main();
}

I write this but after one try it doesn't work anymore i need help n i m only a beginner. I didn't understand what the problem is. Please help me!
And i use DevC++
Last edited on
What's the error you are getting?(if any).
The logic works,I have tried the same code with C++ (Visual Studio) and it works...however there are few changes I've made...check the code below :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
int main()
{
     char *shape; //use char pointer or string
     int i=1;
	 int k,x,y;
     
     shape  = new char[10];
	 cout<<"Shape : ";
	 cin>>shape;
	 cout<<"Column :";
	 cin>>x;
	 cout<<"Line :";
	 cin>>y;
     
     while(i<=y)
     {
          k=1;
          while(k<=x)
          {
			  cout<<"Shape : "<<shape<<endl;
              k++;
          }
          i++;
          printf("\n");
     }
     delete[] shape;
     return 0; //Return 0 and not main
}
closed account (9wX36Up4)
even this u write didn't work i guess the program that i use is bad devc++ what program u use??
Last edited on
What does it mean when you say it doesn't work?Any compile errors??Plz ellaborate,because the above code is a basic C++ one .You just need to include the header iostream.h for the code to compile, as in C you include stdio.h.
I am using Visual Studio 2005.
closed account (9wX36Up4)
thx for the reply and u help
Topic archived. No new replies allowed.