hey guys..

using C language,

how can I ask the user to enter a positive integer

in only these forms --> binary, octal, decimal, or hexadecimal

then save it in a charachter array !

then I ask the use what's the base of this positive number..

and from here I can tell if the form is octel or decimal or .. etc ! ..

Recommended Answers

All 2 Replies

This is what I have done so far

#include <stdio.h>

int main()
{
	char posNumChar[30];

    printf("Please enter positive number: ");
	
    fgets(posNumChar, 30, stdin);

    printf("You entered this positive number, %s", posNumChar);

    getchar();
}

now I want to do the second step.. which is asking the user for the base of the number he entered..

I've been asked to avoid using scanf() to a character and using getchar() --- IN THIS STEP only !

is there any other functions that work the same way as scanf and getchar !! ..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.