ติดที่ว่ามันเปรียบเทียบ if ไม่ได้ครับ ให้มีค่าตรงกับ japan หรือ thailand
Code (C#)
#include<stdio.h>
#include <conio.h>
struct product{
char proname[20],madein[20];
float proprice;
int qty;
}pd1;
main()
{
printf(" Please input data \n");
printf(" Enter product name :");
scanf("%s",&pd1.proname);
printf(" Enter product made in :");
scanf("%s",&pd1.madein);
printf(" Enter product price :");
scanf("%f",&pd1.proprice);
printf(" Enter quantity :");
scanf("%d",&pd1.qty);
printf(" product %s \n",pd1.proname);
printf(" Your product made in %s \n",pd1.madein);
if(pd1.madein=="japan"){
printf(" Your product is Grade A \n");
}else if(pd1.madein=="thailand")
{
printf(" Your product is Grade B \n");
}
if(pd1.qty<=200)
{
printf(" stock : shot supply \n");
}
else
{
printf(" stock : normal \n");
}
getch();
}
#include<stdio.h>
#include <conio.h>
main()
{
struct product{
char proname[20],madein[20];
float proprice;
int qty;
}pd1;
printf(" Please input data \n");
printf(" Enter product name :");
scanf("%s",&pd1.proname);
printf(" Enter product made in :");
scanf("%s",&pd1.madein);
printf(" Enter product price :");
scanf("%f",&pd1.proprice);
printf(" Enter quantity :");
scanf("%d",&pd1.qty);
printf(" product %s \n",pd1.proname);
printf(" Your product made in %s \n",pd1.madein);
if(pd1.madein.equals("japan")){
printf(" Your product is Grade A \n");
}else if(pd1.madein.equals("thailand"))
{
printf(" Your product is Grade B \n");
}
if(pd1.qty<=200)
{
printf(" stock : shot supply \n");
}
else
{
printf(" stock : normal \n");
}
getch();
}