Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,113 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,757 people online right now. Registration is fast and FREE... Join Now!




binary or octal to decimal multiplication table

 
Reply to this topicStart new topic

binary or octal to decimal multiplication table, help please!

kellyjohn
14 May, 2007 - 04:19 AM
Post #1

New D.I.C Head
*

Joined: 14 May, 2007
Posts: 2


My Contributions
CODE

#include<stdio.h>
#include<conio.h>
#include<string.h>

int convert(int num);

main(){
    int num=0,num1=0,row,col,prod=0,x=0,prod1=0;
    //textcolor(BLACK);
    //textbackground(15);
    clrscr();
    printf("\n  Enter # of row: ");
    scanf("%d",&row);
    printf("\n  Enter # of column: ");
    scanf("%d",&col);
    printf("\n\n");
    //printf("\n1    2    3    4    5    6    7    8    9    10\n\n");
    for(num=1;num<=row;num++)
    {
        for(num1=1;num1<=col;num1++)
        {

                                                prod=num*num1;
                                                prod1=convert(prod)
            printf("  %d    ",prod1);
        }
        getch();
        printf("\n");
    }
    printf("\n\n  MATH is fun!");
    getch();
    return 0;
}

int convert(int num)
{
    int num1,num2,temp=0,temp2=0,sum=0;

            do{
                num1=num/10;
                num2=num%10;
                temp=temp*8;
                if(temp==0)
                    temp=1;
                temp2=temp*num2;
                sum=sum+temp2;
                num=num1;
            }
            while(num!=0);
    return sum;
}

User is offlineProfile CardPM
+Quote Post

Amadeus
RE: Binary Or Octal To Decimal Multiplication Table
14 May, 2007 - 04:21 AM
Post #2

g++ -o drink whiskey.cpp
Group Icon

Joined: 12 Jul, 2002
Posts: 12,226



Thanked: 37 times
Dream Kudos: 25
My Contributions
Do you have a question with regards to this code? If so, please post the question, along with any errors being generated or undesired behaviour being demonstrated.
User is offlineProfile CardPM
+Quote Post

Xing
RE: Binary Or Octal To Decimal Multiplication Table
14 May, 2007 - 04:23 AM
Post #3

D.I.C Addict
Group Icon

Joined: 22 Jul, 2006
Posts: 723



Thanked: 2 times
Dream Kudos: 1575
My Contributions
Your code had a few errors
CODE

#include<stdio.h>
//#include<conio.h>
#include<string.h>

int convert(int num);

int main(){
    int num=0,num1=0,row,col,prod=0,prod1=0;
    //textcolor(BLACK);
    //textbackground(15);
   // clrscr();
    printf("\n  Enter # of row: ");
    scanf("%d",&row);
    printf("\n  Enter # of column: ");
    scanf("%d",&col);
    printf("\n\n");
    //printf("\n1    2    3    4    5    6    7    8    9    10\n\n");
    for(num=1;num<=row;num++)
    {
        for(num1=1;num1<=col;num1++)
        {

                                                prod=num*num1;
                                                prod1=convert(prod);
            printf("  %d    ",prod1);
        }
        //getch();
        printf("\n");
    }
    printf("\n\n  MATH is fun!");
    //getch();
    return 0;
}


int convert(int num)
{
    int num1,num2,temp=0,temp2=0,sum=0;

            do{
                num1=num/10;
                num2=num%10;
                temp=temp*8;
                if(temp==0)
                    temp=1;
                temp2=temp*num2;
                sum=sum+temp2;
                num=num1;
            }
            while(num!=0);
    return sum;
}


This post has been edited by Xing: 14 May, 2007 - 04:24 AM
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/1/08 09:45PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month