#include <stdio.h>
#include <stdlib.h>
//main function
int main(){
char code[]={'c','o','m','p','u','t','e','r','c','y'};
char price[20];
//prompt user the price of the item
printf("Enter the price of the item: ");
//read price
scanf("%s",&price);
//display the coded price is:
int i=0;
printf("The coded price is: ");
while(price[i]!='\0'){
int number =price[i] - '0';
if(number>=0 && number<10){
//show code
printf("%c",code[number]);
}else{
//show . or other symbol
printf("%c",price[i]);
}
//increment i
i++;
}
system("PAUSE");//delay
return 0;
}
Comments
Leave a comment