0

I choosed case 1 and else statement is works before scanf.

int main(){
int x;
int y;
char a;
char b;
int c;
int choose;
printf("Which shape would you like to draw?\n 1. Line\n 2. Parabola\n 3. Circle\n 4. Exit\n");
scanf("%d",&choose);
switch(choose){


    case 1:{                                    

            printf("Line formula is y = ax + b \n Enter a and b\n");                                    
            scanf("%c",&a);
            if(isdigit(a))
            {
                scanf("%c",&b);

                int height = 10+abs(b);
                int width = 10+abs(a);
                int y = height;
                for (; y >= -10-abs(b); y--)
                {
                    int x = -10-abs(a);       
                    for (; x <= width; x++)
                    {                        
                        printf(Line (x,y,a,b));                 
                    }                           
                            printf("\n");           

                }
            }
            else 
            {
                printf("hata");                                 
                //scanf("%d",&b);
            }
            break;
           }

I want the user can enter only an integer value. It makes sense to use this method. You can help if there is another method of exception handling.

ryyker
  • 22,849
  • 3
  • 43
  • 87
  • 2
    please reformat your code cos it's a nightmare to read currently – Chris Turner Apr 21 '17 at 16:00
  • Provide a code snippet that is compilable, and that includes as little code as necessary to illustrate the problem. The outer curly brackets ( `{ ... }` ) surrounding code in your `case:` statement are not necessary. And you are missing one curly bracket ( `}` ) to complete switch block – ryyker Apr 21 '17 at 16:09

0 Answers0