#include <stdio.h>
int main() {
char myChar = 'A';
int myInt = myChar;
printf("myChar: %c\n", myChar);
printf("myInt: %d\n", myInt);
int myNewInt = 98;
char myNewChar = myNewInt;
printf("myNewInt: %d\n", myNewInt);
printf("myNewChar: %c\n", myNewChar);
return 0;
}
/*
CSE374 datatype demo by Diana Dai
*/
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
int main(){
int anint;
float afloat;
char achar;
// some initial values:
anint = 374;
afloat = 374.473;
achar = 'A'; // aka, ascii code 65
printf ("int: %d, float: %f, char: %c\n", anint, afloat, achar);
printf ("Cast to int.\n");
printf ("int: %d, float: %d, char: %d\n", anint, (int)afloat, (int)achar);
printf ("Cast to float.\n");
printf ("int: %f, float: %f, char: %f\n", (float)anint, afloat, (float)achar);
printf ("Cast to char.\n");
printf("Change int to 66, float to 67.76\n");
anint=66;
afloat = 67.76;
printf ("int: %c, float: %c, char: %c\n", (char)anint, (char)afloat, achar);
}