#include <stdio.h> int main(void) { int integerNum = 1234567890987654; float floatNum = 1234567890987654321.0f; float smallNum = 0.00001; printf("%d\n",integerNum); printf("%f\n",floatNum); printf("%f\n",smallNum/200); return 0; }
The output on my PC is:git
1016588934 1234567939550609408.000000 0.000000
#include <stdio.h> int main(void) { char ch; printf("Enter the character: "); scanf("%c", &ch); printf("%c's ASCII code is %d.\n", ch, ch); return 0; }
Enter a floating-point value: 64.25 fixed-point notation: 64.250000 exponential notation: 6.425000e+01 p notation: 0x1.01p+6
#include <stdio.h> int main(void) { float number; printf("Enter a float-pointing number:"); scanf("%f", &number); printf("fixed-point notation: %f\n", number); printf("exponential notation: %e\n", number); printf("p notation: %a\n", number); }
#include <stdio.h> #define seconds_in_a_year 3.156e7 int main(void) { int age; printf("Enter your age in years:"); scanf("%d", &age); printf("Your age in seconds is %lld", age * seconds_in_a_year); }
#include <stdio.h> #define mass_of_a_single_molecule_of_water 3.0e-23 int main(void) { int amount; printf("Enter the amount of water in quarts:"); scanf("%d", &amount); printf("The number of water molecules: %lld", amount * 950 / mass_of_a_single_molecule_of_water); return 0; }
#include <stdio.h> int main(void) { int inch; printf("Enter your height in inches:"); scanf("%d", &inch); printf("%d inches is %.2f centimeters.\n", inch, inch * 2.54); return 0; }
#include <stdio.h> int main(void) { float cup; printf("Enter the volume in cups:"); scanf("%f", &cup); float pint = cup / 2; float ounce = cup * 8; float tablespoon = ounce * 2; float teaspoon = tablespoon * 3; printf("%f cups is %f pints, or %f tablespoons,or %f teaspoons", cup, pint, tablespoon, teaspoon); return 0; }