Converting ASCII to different types | C

Anonymous

September 27th, 2021 10:42:30 AM

					
#include <stdio.h> int main() { unsigned char character; int i, temp; printf("Enter an ASCII character: "); scanf("%c", &character); printf("The ASCII value of the character is: \n"); printf(" dec -- %d\n", character); printf(" hex -- %x\n", character); printf(" bin -- "); for(int i = 7; i >= 0; i--) { temp = character >> i; if(temp & 1) { printf("1"); } else { printf("0"); } } printf("\n"); return 0; }

Featured Posts