pushkar


{ City } pune
< Country > india
* Profession *
User No # 68162
Total Questions Posted # 0
Total Answers Posted # 1

Total Answers Posted for My Questions # 0
Total Views for My Questions # 0

Users Marked my Answers as Correct # 6
Users Marked my Answers as Wrong # 4
Questions / { pushkar }
Questions Answers Category Views Company eMail




Answers / { pushkar }

Question { UCB, 9266 }

I'm having trouble with coming up with the correct code. Do
I need to put a loop? Please let me know if I'm on the right
track and what areas I need to correct. I still don't have a
good grasp on this programming stuff. Thanks =)

The assignment was to write a program using string functions
that accepts a coded value of an item and displays its
equivalent tag price. The base of the keys:

0 1 2 3 4 5 6 7 8 9
X C O M P U T E R S

Sample I/O Dialogue:

Enter coded value: TR.XX
Tag Price : 68.00


Answer

#include
#include

void main()
{
char
v1[11]={'X','C','O','M','P','U','T','E','R','S','\0'},p='.';
int v2[11]={0,1,2,3,4,5,6,7,8,9};
char ip[10];
int n,i,j,k=0,cnt=0;
//clrscr();

printf("Enter coded value: ");
scanf("%s",ip);

// printf("\nur entered code = %s",ip);
printf("\nUr price is = ");


for(i=0;v1[i]!='\0';i++)
{
if(ip[k]=='.')
{
++k;
printf("%c",p);
}
if(ip[k]==v1[i])
{
printf("%d",i);
++k;
i=-1;
if(ip[k]=='\0')
break;
}
}
}
//compiled by GCC

Is This Answer Correct ?    6 Yes 4 No