I've been trying to learn C from a book called C Programming Absolute Beginner's Guide and I have come across a problem and the one bad thing is you can't ask a book a question! Typed the error into Google and it brought me to this site. The error I'm getting is in the question title and this is my code.
#include <stdio.h>
main(
{
//Set up the variables, as well as define a few
char firstInitial, middleInitial;
int number_of_pencils;
int number_of_notebooks;
float pencils = 0.23;
float notebooks = 2.89;
float lunchbox = 4.99;
//The information for the first child
firstInitial = 'J';
middleInitial = 'R';
number_of_pencils = 7;
number_of_notebooks = 4;
printf("%c%c needs %d pencils, %d notebooks, and 1 lunchbox\n",
firstInitial, middleInitial,number_of_pencils,
number_of_notebooks);
printf("The total cost is £%.2f\n\n", number_of_pencils*pencils + number_of_notebooks*notebooks + lunchbox);
//The information for the second child
firstInitial ='A';
middleInitial = 'J';
number_of_pencils = 10;
number_of_notebooks = 3;
printf("%c%c needs %d pencils, %d notebooks, and 1 lunchbox\n",
firstInitial, middleInitial,number_of_pencils,
number_of_notebooks);
printf("The total cost is £%.2f\n\n", number_of_pencils*pencills
+ number_of_notebooks*notebooks + lunchbox);
//The information for the third child
firstInitial = 'M';
middleInitial = 'T';
number_of_pencils = 9;
number_of_notebooks = 2;
printf("%c%c needs %d pencils, %d notebooks, and 1 lunchbox\n",
firstInitial, middleInitial,number_of_pencils,
number_of_notebooks);
printf("The total cost is £%.2f\n",
number_of_pencils8pencils + number_of_notebooks*notebooks + lunchbox);
return0;
}
)
What's wrong with this code?