COOLKILLer
Legacy Member
Dit programma staat in mijn boek van C, en het geeft niet het juiste resultaat.
wat is er mis????
Mijn output is gewoon:
Your weight in grams = 0
In 2010 you will be 2010 years old
Wat het dus helemaal nie moet zijn...
wat is er mis????
Code:
/* Demonstrates variables and constants */
#include <stdio.h>
/* Define a constant to convert from pounds to grams */
#define GRAMS_PER_POUND 454
/* Define a constant for the start of the next century */
const int NEXT_CENTURY = 2010;
/* Declare the needed variables */
long weight_in_grams, weight_in_pounds;
int year_of_birth, age_in_2010;
main()
{
/* Input data from user */
printf("Enter your weight in pounds: ");
scanf("%d, &weight_in_pounds");
printf("Enter your year of birth: ");
scanf("%d, &year_of_birth");
/* Perform conversion */
weight_in_grams = weight_in_pounds * GRAMS_PER_POUND;
age_in_2010 = NEXT_CENTURY - year_of_birth;
/* Display results on the screen */
printf("\nYour weight in grams = %ld", weight_in_grams);
printf("\nIn 2010 you will be %d years old", age_in_2010);
return 0;
}
Your weight in grams = 0
In 2010 you will be 2010 years old
Wat het dus helemaal nie moet zijn...


.
... kdacht idd da Killgore de "juiste" code achter //Fout had geschreven.. lol.. 