SolvedHelp me understand something

Posts 1–4 of 4 · Page 1 of 1
Help me understand something
What is initial ?



Here is my code


// Example program #1 from Chapter 5 of Absolute Beginners Guide (i recommend this book)
// to C, 3rd Edition
// File Chapter5ex1.c

/* This is a sample program that list three kids and their school
supply needs, as well as cost to buy the supplies */

#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*pencils
+ number_of_notebooks*notebooks + lunchbox);

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*pencils
+ 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\n", number_of_pencils*pencils
+ number_of_notebooks*notebooks + lunchbox);

return 0;
}
Next time please use code tags.

[CODE']

[/CODE']


Initial in this case is the first letter of the name of the kid.
Quote Originally Posted by RoPMadM View Post
Next time please use code tags.

[CODE']

[/CODE']


Initial in this case is the first letter of the name of the kid.
Oh ok, i understand now.
Posts 1–4 of 4 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us