#include<stdio.h>
#include<conio.h>

main()
{
      char c;
      
      printf("Enter the code for the chart: \n");
      do
      {
                    scanf("%c",&c);
                    switch (c)
                    {
                            case 'A':printf("Area Chart\n");break;
                            case 'B':printf("Bar Chart\n");break;
                            case 'U':printf("Bubble Chart\n");break;
                            case 'C':printf("Column Chart\n");break;
                            case 'N':printf("Cone Chart\n");break;
                            case 'Y':printf("Cylinder Chart\n");break;
                            case 'D':printf("Doughnut Chart\n");break;
                            case 'L':printf("Line Chart\n");break;
                            case 'I':printf("Pie Chart\n");break;
                            case 'P':printf("Pyramid Chart\n");break;
                            case 'R':printf("Radar Chart\n");break;
                            case 'S':printf("Scatter Chart\n");break;
                            case 'F':printf("Surface Chart\n");break;
                            case 'K':printf("Stock Chart\n");break;
                            default:printf("The code is not valid.\n);
                            }
                            }
                            while (c='\n');
                            getch();
                            }

whenever i type the code, it displays the kind of chart but also the default. how can i fix this? help me please. :(

Your do-while loop will never, ever end. Every time you get to

while (c='\n');

c is made to equal '\n', which always evaluates to true. So, after the first time, you have made c equal to '\n', and the loop goes round again, and presumably that time goes to the default.

Did you mean something like this?

while (c!='\n');

but my professor said that he want the kind of program that can enter another code after another so i made

while (c='\n')

but is it because of that whenever i type a code it displays the kind of chart and default? like for example.

A
Area Chart
The code is not valid

Also, I think you've confused = with ==

= sets the value of a variable.

== checks if the value of something is the same as something else.

I FORGOT about that, thanks! the program is working fine now, but what will i do so that i can input more than 1 code for the chart? :D here is the code.

#include<stdio.h>
#include<conio.h>

main()
{
      char c;
      
      printf("Enter the code for the chart: \n");
      do
      {
                    scanf("%c",&c);
                    switch (c)
                    {
                            case 'A':printf("Area Chart\n");break;
                            case 'B':printf("Bar Chart\n");break;
                            case 'U':printf("Bubble Chart\n");break;
                            case 'C':printf("Column Chart\n");break;
                            case 'N':printf("Cone Chart\n");break;
                            case 'Y':printf("Cylinder Chart\n");break;
                            case 'D':printf("Doughnut Chart\n");break;
                            case 'L':printf("Line Chart\n");break;
                            case 'I':printf("Pie Chart\n");break;
                            case 'P':printf("Pyramid Chart\n");break;
                            case 'R':printf("Radar Chart\n");break;
                            case 'S':printf("Scatter Chart\n");break;
                            case 'F':printf("Surface Chart\n");break;
                            case 'K':printf("Stock Chart\n");break;
                            default:printf("The code is not valid.\n");
                            }
                            }
                            while (c=='\n');
                            getch();
                            }
This question has already been answered. Start a new discussion instead.