Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and the Yahoo Answers website is now in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

Why doesn't my program in Turbo c++ work?

Using the do while statement, create a program that will display the menu and will allow the user select from one of the options. This thing won't show me the greeting. Why???

[1] - Philippines

[2] - Japan

[3] - USA

[4] - Italy

[5] - France

[6] - Exit

#include <stdio.h>

#include <conio.h>

void main()

{

clrscr();

int choice;

do {

gotoxy(25,6);

printf("*******************************");

gotoxy(25,7);

printf(" Greeting Menu ");

gotoxy(25,8);

printf("*******************************");

gotoxy(25,9);

printf("\t[1] - Philippines");

gotoxy(25,10);

printf("\t[2] - Japan");

gotoxy(25,11);

printf("\t[3] - USA");

gotoxy(25,12);

printf("\t[4] - Italy");

gotoxy(25,13);

printf("\t[5] - France");

gotoxy(25,14);

printf("\t[6] - Exit");

gotoxy(25,16);

printf("\tEnter the number of your choice: ");

scanf("%d", choice);

gotoxy(30,19);

switch(choice)

{

case 1:

clreol();

printf("Magandang Umaga");

break;

case 2:

clreol();

printf("Ohayo Gozaimasu");

break;

case 3:

clreol();

printf("Good Morning");

break;

case 4:

clreol();

printf("Buon Giorno");

break;

case 5:

clreol();

printf("Bonjour");

break;

default:

break;

}

gotoxy(30,23);

printf("Choose another number...");

choice=getch();

} while (choice<6);

getch();

}

1 Answer

Relevance
  • ?
    Lv 7
    7 years ago
    Favorite Answer

    This: scanf("%d", choice);

    needs to be replaced by this: scanf("%d", &choice);

    This here:

    gotoxy(30,23);

    printf("Choose another number...");

    Needs to go into the default of the switch.

    choice = getch() can be deleted!

Still have questions? Get your answers by asking now.