So I have this program to calculate the types of meat, I have fixed the system errors but the actual program when I run it comes up with <null> what am I doing wrong?
Code:
#include <stdio.h>
#include <stdlib.h>
#define beef 1 /* multiplication factor of beef*/
#define chicken 1.5 /*factor of chicken*/
#define pork 2 /* factor of pork*/
#define s1 0.5 /* state1 is close to expiry*/
#define s2 1 /*state2 is frozen storage*/
#define s3 1.5 /*state3 is fresh*/
int main(int argc, char *argv[])
{
float x = 0; /*amount of meat*/
char y = 0; /*state of meat*/
char z = 0; /*type of meat*/
float w = 0; /*total price*/
printf ("This program calculates price of meat. \n");
printf ("\n Please enter type of meat ( a, b, c):");
fflush (stdin);
scanf ("%s",&z);
if ((z != beef) || (z != chicken) || (z != pork))
w, "NA";
printf ("\n Please enter state of z(s1, s2, s3):");
fflush (stdin);
scanf ("%s",&st);
if ((y != s1) || (y != s2) || (y != s3))
w, "NA";
printf ("\n Please enter quantity of grams of z (0 - 2000):");
fflush (stdin);
scanf ("%d",&x);
if ((x < 0 ) || (x > 2000))
price, "NA";
else if (x >= 1500)
price = (z*y)*8;
else if (x >= 1000)
price = (z*y)*6;
else if (x >= 500)
price = (z*y)*4;
else
price = (meat*st)*2;
printf( "\n the price is: %s", price);
system("PAUSE");
return 0;
}