projects
projects
#include <stdio.h> #include <stdlib.h> int main() { int a, *b; short int c; char d; float e; b = (int *) malloc (sizeof(int) * 1); fprintf(stdout, "Enter an integer: "); fscanf(stdin, "%u", &a); fprintf(stdout, "Enter another integer: "); fscanf(stdin, "%u", b); // why don't we need & in this case? fprintf(stdout, "Enter a short int: "); fscanf(stdin, "%hu", &c); fprintf(stdout, "Enter a char: "); fscanf(stdin, "%c", &d); fprintf(stdout, "Enter a float value: "); fscanf(stdin, "%f", &e); fprintf("Your ints are: %u and %u\n", a, *b); fprintf("Your short int is: %hu\n", c); fprintf("Your char is: '%c'\n", d); fprintf("Your float (trimmed at 2 decimal places) is: %.2f\n", e); return(0); }