+ 1
a c program using string functions that accepts a coded value of an item and display its equivalent tag price
How to Write a c program using string functions that accepts a coded value of an item and display its equivalent tag price? Can someone enlighten me how you guys did it?? The base of the key is: 0 1 2 3 4 5 6 7 8 9 X C O M P U T E R S Sample input/output dialogue: Enter coded value: TR.XX Tag price: 68.00 Note: the numbers below are the corresponding equivalent values of the letters. [Edited]
9 Réponses
+ 2
Muhammad Belal
Never give the direct solution to a problem. The problem is for the OP to solve. You should only lead them to the answer.
ruiririririri
You should follow these steps:
1. Make a string `input`
2. Take input into `input`
3. Make another string `tag_price` of size strlen(input) + 1
4. Iterate through the string `input`. For each character in the string `input`, use switch-case/if-conditions to add the digit corresponding to the character to `tag_price`. For example, if the character is 'X', add the character '0' to `tag_price`
5. When for-loop is over, convert `tag_price` to float using the atof() function of the <stdlib.h> header
http://www.cplusplus.com/reference/cstdlib/atof/
+ 2
Information incomplete.
"a coded value of an item" - coded in what form?
"display its equivalent tag price" - on what basis will the tag proce be found? Does it have to be found by decoding the accepted 'coded' value? If yes, how does ot have to be decoded?
+ 2
Give here some code sample
+ 2
char num[]={'0','1','2','3','4','5','6','7','8','9'};
char str[]={'X', 'C', 'O', 'M', 'P', 'U', 'T', 'E', 'R', 'S'};
int digit=0;
for(;digit<=strlen(num);digit++){
num[digit]=str[digit];
digit++;
}
scanf();//as u scan
printf();//
+ 1
Not really🤧 but I’m trying✨
+ 1
continue it otherwise you can me message
+ 1
You have a point. Thank you very much XXX
0
Are you able to understand this code
0
Yes I will. Thank You sir✨