Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a C Program that counts Hexadecimal Digits *******************************

ID: 3862703 • Letter: W

Question

Write a C Program that counts Hexadecimal Digits

*********************************************************

Write a program in C that takes as input a four-digit hexadecimal number and prints the next 10 hexadecimal numbers.

-define a hexadecimal number as int hexNum[4]

-Allow upper or Lowercase letters for the input and use uppercase letters for the hexadecimal output.

-For Example: 3C6f should be a valid input and should produce output 3C6F, 3C70, 3C71 and so on for the next 10 hexadecimal digits.

************************************************

Test the program with input 3C6f and output the 10 4-digit hexadecimal digits that follow.

Explanation / Answer

#include <stdio.h>

int main(void) {

int n, hex[4] = { 0 };
int i, j;
printf("Enter the number ");
scanf("%x", &n);


for (j = 0; j<10; j++)
{

hexNum[3]++;

for (i = 3; i>0; i--)
{
if (hex[i] == 16)
{
hex[i - 1]++;
hex[i] = 0;
}
}
printf(" %x%x%x%x ", hex[0], hex[1], hex[2], hex[3]);

}
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote