#include <stdio.h>


main()
{

       int ctr, bin, quotient, deci=0, binary,octal,hexa;
    	float rem;
       char mark_magic;

clrscr();

do
{
	clrscr();
	quotient = 1;
	binary = 1;

	gotoxy(32,3); printf("-=< MAIN MENU >=-");
	gotoxy(15,5); printf("from any Number System to Decimal System conversion");
	gotoxy(5,6); printf("------------------------------------------------------------------------");
	gotoxy(5,7); printf("------------------------------------------------------------------------");
	gotoxy(26,9); printf("[A] Binary System");
	gotoxy(26,11); printf("[B] Octal System");
	gotoxy(26,13); printf("[C] Hexadecimal System");
	gotoxy(26,15); printf("[X] Exit");
	gotoxy(26,21); printf("what's your choice?: ");

	mark_magic = getche();
	
	clrscr();


	switch(toupper(mark_magic))

	 {
		case 'A':
			clrscr();

			gotoxy(10,5); printf("########^_^ Convert Decimal system to Binary system ^_^########");
			gotoxy(5,6); printf("------------------------------------------------------------------------");
			gotoxy(5,7); printf("------------------------------------------------------------------------");			
			binary = 2;
			
			gotoxy(28,9);printf("enter decimal number: ");

			scanf("%d",&deci);


			quotient = deci / binary;
			
			
			
			for(bin=1;bin>=15;bin++)
			{	
			bin = deeci%2;	
			gotoxy(28,11);printf("Equivalent in Binary is %.0f",bin);
			}

			gotoxy(51,24); printf("press any key to exit: ");
		     

		     getche();
		     clrscr();
		     break;

		  case 'B':
			clrscr();

			gotoxy(10,5); printf("########^_^ Convert Decimal system to Octal system ^_^########");
			gotoxy(5,6); printf("------------------------------------------------------------------------");
			gotoxy(5,7); printf("------------------------------------------------------------------------");
			octal = 8;
			

			gotoxy(28,9);printf("enter decimal number: ");

			scanf("%d",&deci);

			for (ctr = 1; ctr<=deci; ctr++)

			quotient = deci / octal;

			gotoxy(28,11);printf("Equivalent in Octal is %d",quotient);


			gotoxy(51,24); printf("press any key to exit: ");

			getche();
			break;

		 case 'C':

			clrscr();

			gotoxy(10,5); printf("########^_^ Convert Decimal system to Hexadecimal system ^_^########");
			gotoxy(5,6); printf("------------------------------------------------------------------------");
			gotoxy(5,7); printf("------------------------------------------------------------------------");
			hexa = 16;

			gotoxy(28,9);printf("enter decimal number: ");

			scanf("%d",&deci);

			for (ctr = 1; ctr<=deci; ctr++)

			quotient = deci / hexa;

                        gotoxy(28,11);printf("Equivalent in Hexadecimal is %d",quotient);

			gotoxy(51,24); printf("press any key to exit: ");

			getche();
			break;

			}
			}
while(toupper(mark_magic) != 'X');

}

this was rejected by my teacher,she said a lot of codes is missing. the problem is, I don't know what i'm going to write coz im new with C. Can you pls. help me with my problem?

thanks a lot!

When you run a program and the first choice shows nothing, it's safe to say it's lacking! :)

I re-worked Choice A, but the answer is being written out in reverse. You need to take the digits and first put them into a small array or LIFO buffer of some kind, and print them out from that array or buffer in last in, first out, ourder, so when the number is 3, the zero's are all printed out before the 1's.

Always highlight your code you want to post on the forum, and press the # sign, so it will be made to look more like code, and not regular forum text.

#include <stdio.h>


int main()  {
   int ctr, bin, quotient, deci=0, binary,octal,hexa, gar;
   float rem;
   char mark_magic;

   do   {
      clrscr();
      quotient = 1;
      binary = 1;

      gotoxy(32,3); printf("-=< MAIN MENU >=-");
      gotoxy(15,5); printf("from any Number System to Decimal System conversion");
      gotoxy(5,6); printf("------------------------------------------------------------------------");
      gotoxy(5,7); printf("------------------------------------------------------------------------");
      gotoxy(26,9); printf("[A] Binary System");
      gotoxy(26,11); printf("[B] Octal System");
      gotoxy(26,13); printf("[C] Hexadecimal System");
      gotoxy(26,15); printf("[X] Exit");
      gotoxy(26,21); printf("what's your choice?: ");

      mark_magic = getche();
      clrscr();
      switch(toupper(mark_magic))   {
         case 'A':
         clrscr();
         gotoxy(10,5); printf("########^_^ Convert Decimal system to Binary system ^_^########");
         gotoxy(5,6); printf("------------------------------------------------------------------------");
         gotoxy(5,7); printf("------------------------------------------------------------------------");
         binary = 2;
         gotoxy(28,9);printf("enter decimal number: ");

         scanf("%d",&deci);
         quotient = deci / binary;
         gotoxy(28,11);printf("Equivalent in Binary is ");
         for(bin=1; bin <=16; bin++)  {
            printf("%d",deci % 2);
            deci = deci / 2;
         }

         gotoxy(51,24); printf("press any key to exit: ");
         getche();
         clrscr();
         break;

         case 'B':
            clrscr();
            gotoxy(10,5); printf("########^_^ Convert Decimal system to Octal system ^_^########");
            gotoxy(5,6); printf("------------------------------------------------------------------------");
            gotoxy(5,7); printf("------------------------------------------------------------------------");
            octal = 8;
            gotoxy(28,9);printf("enter decimal number: ");
            scanf("%d",&deci);
            for (ctr = 1; ctr<=deci; ctr++)
               quotient = deci / octal;
            gotoxy(28,11);printf("Equivalent in Octal is %d",quotient);
            gotoxy(51,24); printf("press any key to exit: ");
            getche();
            break;
         case 'C':
            clrscr();
            gotoxy(10,5); printf("########^_^ Convert Decimal system to Hexadecimal system ^_^########");
            gotoxy(5,6); printf("------------------------------------------------------------------------");
            gotoxy(5,7); printf("------------------------------------------------------------------------");
            hexa = 16;
            gotoxy(28,9);printf("enter decimal number: ");
            scanf("%d",&deci);
            for (ctr = 1; ctr<=deci; ctr++)
            quotient = deci / hexa;
            gotoxy(28,11);printf("Equivalent in Hexadecimal is %d",quotient);
            gotoxy(51,24); printf("press any key to exit: ");
            getche();
            break;

      }
   }while(toupper(mark_magic) != 'X');
   gar = getchar(); gar++;
   return 0;
}


/*this was rejected by my teacher,she said a lot of codes is missing. the problem is, I don't know what i'm going to write coz im new with C. Can you pls. help me with my problem?
thanks a lot!
*/

Step 1 would be to remove ALL the gotoxy() and clrscr() and any other decorative features until you've actually got the damn thing to work.

Adding eye candy to an already working program is trivial, compared with trying to maintain it whilst you're debugging the code.

a goto statement isnt tat good for programming..
avoid it if possible..
this program becomes pretty simple without em..

When you run a program and the first choice shows nothing, it's safe to say it's lacking! :)

I re-worked Choice A, but the answer is being written out in reverse. You need to take the digits and first put them into a small array or LIFO buffer of some kind, and print them out from that array or buffer in last in, first out, ourder, so when the number is 3, the zero's are all printed out before the 1's.

Always highlight your code you want to post on the forum, and press the # sign, so it will be made to look more like code, and not regular forum text.

#include <stdio.h>


int main()  {
   int ctr, bin, quotient, deci=0, binary,octal,hexa, gar;
   float rem;
   char mark_magic;

   do   {
      clrscr();
      quotient = 1;
      binary = 1;

      gotoxy(32,3); printf("-=< MAIN MENU >=-");
      gotoxy(15,5); printf("from any Number System to Decimal System conversion");
      gotoxy(5,6); printf("------------------------------------------------------------------------");
      gotoxy(5,7); printf("------------------------------------------------------------------------");
      gotoxy(26,9); printf("[A] Binary System");
      gotoxy(26,11); printf("[B] Octal System");
      gotoxy(26,13); printf("[C] Hexadecimal System");
      gotoxy(26,15); printf("[X] Exit");
      gotoxy(26,21); printf("what's your choice?: ");

      mark_magic = getche();
      clrscr();
      switch(toupper(mark_magic))   {
         case 'A':
         clrscr();
         gotoxy(10,5); printf("########^_^ Convert Decimal system to Binary system ^_^########");
         gotoxy(5,6); printf("------------------------------------------------------------------------");
         gotoxy(5,7); printf("------------------------------------------------------------------------");
         binary = 2;
         gotoxy(28,9);printf("enter decimal number: ");

         scanf("%d",&deci);
         quotient = deci / binary;
         gotoxy(28,11);printf("Equivalent in Binary is ");
         for(bin=1; bin <=16; bin++)  {
            printf("%d",deci % 2);
            deci = deci / 2;
         }

         gotoxy(51,24); printf("press any key to exit: ");
         getche();
         clrscr();
         break;

         case 'B':
            clrscr();
            gotoxy(10,5); printf("########^_^ Convert Decimal system to Octal system ^_^########");
            gotoxy(5,6); printf("------------------------------------------------------------------------");
            gotoxy(5,7); printf("------------------------------------------------------------------------");
            octal = 8;
            gotoxy(28,9);printf("enter decimal number: ");
            scanf("%d",&deci);
            for (ctr = 1; ctr<=deci; ctr++)
               quotient = deci / octal;
            gotoxy(28,11);printf("Equivalent in Octal is %d",quotient);
            gotoxy(51,24); printf("press any key to exit: ");
            getche();
            break;
         case 'C':
            clrscr();
            gotoxy(10,5); printf("########^_^ Convert Decimal system to Hexadecimal system ^_^########");
            gotoxy(5,6); printf("------------------------------------------------------------------------");
            gotoxy(5,7); printf("------------------------------------------------------------------------");
            hexa = 16;
            gotoxy(28,9);printf("enter decimal number: ");
            scanf("%d",&deci);
            for (ctr = 1; ctr<=deci; ctr++)
            quotient = deci / hexa;
            gotoxy(28,11);printf("Equivalent in Hexadecimal is %d",quotient);
            gotoxy(51,24); printf("press any key to exit: ");
            getche();
            break;

      }
   }while(toupper(mark_magic) != 'X');
   gar = getchar(); gar++;
   return 0;
}


/*this was rejected by my teacher,she said a lot of codes is missing. the problem is, I don't know what i'm going to write coz im new with C. Can you pls. help me with my problem?
thanks a lot!
*/

wow! thank you very much!! it is very helpful to me..

what is the code of this:


----------------------------------------

This program will convert octal to hexa:

Enter a number: ----

What Would you like to do, Press O for octal and H for hexa: -----

The Answer is: -----

Would you like to convert again(Y/N): ----


thanks

amazing !

i didnt understand a single thing !

hahhahah

can you give a written explaination ?

Wow! a million Thanks to all..

commented: pointless bump. -4
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.