/*	Michael Funchess
	September 23, 2022
	Computer Science 1011 Section 005
	Lab #4
	Using ASCII values & sending output to external files & stdout vs stderr
*/

#include <stdio.h>
#include <math.h>
// REQUIRED TO MAKE pow() WORK

int main() {
	char lowerc;
	char upperc;
	int input1;
	int input2;
	float cube;
	// SETTING THIS AS A FLOAT TO  GET TRAILING 0S SHOWN IN INSTRUCTIONS

	fprintf(stderr, "Enter a capital letter: ");
	fscanf(stdin, "%c", &upperc);
	fprintf(stderr, "Enter a lowercase letter: ");
	fscanf(stdin, " %c", &lowerc);
	fprintf(stderr, "Enter an integer (33 - 126): ");
	fscanf(stdin, " %i", &input1);
	fprintf(stderr, "Enter an integer: ");
	// ALL THESE ARE stderr TO PRINT EVEN WHEN INPUT IS DIRECTED
	fscanf(stdin, " %i", &input2);
	cube = pow(input2, 3);

	fprintf(stdout, "The lowercase of %c is: %c", upperc, upperc +32);
	fprintf(stdout, "\n");
	upperc = upperc +32;
	// THERE IS A DIFFERENCE OF 32 BETWEEN UPPERCASE AND LOWERCASE
	fprintf(stdout, "The ASCII values for %c are:", upperc);
	fprintf(stdout, "\n");
	fprintf(stdout, "%-16s%-16s%s", "DECIMAL", "OCTAL", "HEX");
	fprintf(stdout, "\n");
	fprintf(stdout, "%-16d%#-16o%#x", upperc, upperc, upperc);
	fprintf(stdout, "\n");
	fprintf(stdout, "The uppercase of %c is: %c", lowerc, lowerc -32);
	lowerc = lowerc -32;
	fprintf(stdout, "\n");
	fprintf(stdout, "The ASCII values for %c are:", lowerc);
	fprintf(stdout, "\n");
	fprintf(stdout, "%-16s%-16s%s", "DECIMAL", "OCTAL", "HEX");
	fprintf(stdout, "\n");
	fprintf(stdout, "%-16d%#-16o%#x", lowerc, lowerc, lowerc);
	fprintf(stdout, "\n");
	fprintf(stdout, "The ASCII character of %i is: %c", input1, input1);
	fprintf(stdout, "\n");
	fprintf(stdout, "%i cubed is %.1f", input2, cube);
	fprintf(stdout, "\n");
	// stdout USED TO PUSH ALL DIRECTLY TO SPECIFICIED OUTPUT

	return 0;
}

