23 lines
506 B
C
23 lines
506 B
C
#include<stdio.h>
|
|
|
|
int main(){
|
|
int choice;
|
|
char *names[] = {"apples", "pears", "oranges", "grapes"};
|
|
float price[4] = {3.0,2.5,4.1,10.2};
|
|
|
|
printf("[1] apples\n[2] pears\n[3] oranges\n[4] grapes\n[0] exit\n");
|
|
|
|
for(int i=0;i<5;i++){
|
|
printf("Enter choice: \n");
|
|
scanf("%d",&choice);
|
|
|
|
if(choice==0){break;}
|
|
else if(choice > 0 && choice < 5){printf("[%d] %s price=%.1f\n",choice,names[choice-1],price[choice-1]);}
|
|
else {printf("other price=0.0\n");}
|
|
|
|
}
|
|
|
|
printf("Thanks");
|
|
return 0;
|
|
}
|