#include <stdio.h> //scanf and printf need thisusing namespace std;int main(){ //C++ has no datatype for octal. Let's stick with a decimal // system and use formatted streams. Trust me, this is far easier. // And by the way, our program has built in run-time error prevention! int octal = 0; int decimal = 0; char wantsToDo[1]; /* MENU */ //This loops until 'Q' is entered. while (wantsToDo[0] != 'Q') { printf("Decimal to Octal conversions\n"); printf("[D] Decimal -> Octal\n"); printf("[O] Octal -> Decimal\n"); printf("[Q]uit\n"); scanf("%s", wantsToDo); /* DECIMAL TO OCTAL */ if (wantsToDo[0] == 'D') { //Prompt. //If the user enters something wrong, the error // will be caught! Try for yourself! printf("\nEnter a decimal integer -->"); //Decimal to octal conversion takes place with "%o". //Amperstand has to do with fancy memory tidbits. scanf("%o", &decimal); //Display the integer, which has been converted for us in scanf. printf("The number, in octal form, is %d\n\n", decimal); } /* OCTAL TO DECIMAL */ else if (wantsToDo[0] == 'O') { //Same happens here except that our conversion happens in printf. printf("\nEnter an octal integer -->"); //Ask. scanf("%d", &octal); //Input. printf("The number, in decimal form, is %o\n\n",octal);//Show oct. } //Exit with friendliness. else if (wantsToDo[0] == 'Q') { printf("Good-bye!\n"); } //Error catching. else printf("\n\nError Caught\n\n-->"); }return 0;}