/* This is HW4_2 Lab EE107
The purpose of this generate prime numbers
Creating the code and free of syntax and grammatical errors.
Author: Ekwegbalum Unachukwu
Star ID:do2170dt
Date: April 17th, 2024.
*/
#include <stdio.h>
int main(void) {
//constant char types assigned for i(indices) for array size 16
const char baseDigits[16] = {
'0','1','2','3','4','5','6','7','8',
'9','A','B','C','D','E','F'
};
//intial values for
//creating a array size of 64
int convertedNumber[64];
long int numbertoCovert;
int nextDigit, base, index = 0;
// get the number and the base
printf("enter the Number to be converted? ");
scanf(" %ld", &numbertoCovert);
printf(" %ld\n" , numbertoCovert);
printf("Base? ");
scanf("%i", &base);
printf(" %i\n", base);
//convert to the indicated base
do {
convertedNumber[index] = numbertoCovert % base;
++index;
numbertoCovert = numbertoCovert / base;
} while (numbertoCovert != 0);
//display the results in the reverse order
printf("Coverted number = ");
for ( --index ; index >= 0 ; --index ) {
nextDigit = convertedNumber[index];
printf("%c ", baseDigits[nextDigit]);
}
printf("\n");
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: