1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Need Help For C Functions

Discussion in 'C' started by chubsonacle, Oct 9, 2011.

  1. chubsonacle

    chubsonacle New Member

    Joined:
    Oct 9, 2011
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    pls help me. can i get the function for converting roman numeral to decimal ?? plss ? urgently needed .:( here is the code :

    Code:
    #include<stdio.h>
    #include<conio.h>
    void input(int *num1,int *num2);
    void addition(int num1,int num2,int *sum);
    void subtraction(int num1,int num2,int *diff);
    void division(int num1,int num2,int *quot);
    void multiplication(int num1,int num2,int *prod);
    void modulus(int num1,int num2,int *mod);
    void main()
    {int x=0,y=0;
    int sum,diff,quot,prod,mod;
    char choice;
    char again1;
    clrscr(); do{ clrscr();
    gotoxy(25,1);
    textcolor(YELLOW);
    printf("************************************");
    gotoxy(25,3);
    printf("* MENU *");
    gotoxy(25,6);
    printf("************************************");
    gotoxy(25,9);
    printf("* (+) ADDITION *");
    gotoxy(25,11);
    printf("* (-) SUBTRACTION *");
    gotoxy(25,13);
    printf("* (/) DIVISION *");
    gotoxy(25,15);
    printf("* (*) MULTIPLICATION *");
    gotoxy(25,17);
    printf("* (%) MODULUS *");
    gotoxy(25,19);
    printf("************************************");
    gotoxy(25,21);
    printf("PLEASE ENTER YOUR CHOICE:");
    scanf("%s",&choice);
    clrscr();
    input(&x,&y);
    switch(choice){
    case '+':clrscr();
    addition(x,y,&sum);
    gotoxy(36,10);
    printf("SUM:%d",sum);
    gotoxy(15,18);
    printf("press Y or y if you want to go back from the menu:");
    scanf("%s",&again1);
    break;
    case '-':clrscr();
    subtraction(x,y,&diff);
    gotoxy(36,10);
    printf("DIFFERENCE:%d",diff);
    gotoxy(15,18);
    printf("press Y or y if you want to go back from the menu:");
    scanf("%s",&again1);
    break;
    case '/':clrscr();
    division(x,y,&quot);
    gotoxy(36,10);
    printf("QUOTIENT:%d",quot);
    gotoxy(15,18);
    printf("press Y or y if you want to go back from the menu:");
    scanf("%s",&again1);
    break;
    case '*':clrscr();
    multiplication(x,y,&prod);
    gotoxy(36,10);
    printf("PRODUCT:%d",prod);
    gotoxy(15,18);
    printf("press Y or y if you want to go back from the menu:");
    scanf("%s",&again1);
    break;
    case '%':clrscr();
    modulus(x,y,&mod);
    gotoxy(36,10);
    printf("MODULUS:%d",mod);
    gotoxy(15,18);
    printf("pres Y or y if you want to go back from the menu:");
    scanf("%s",&again1);
    break;
    default:clrscr();gotoxy(33,10); printf("ERROR IN CODE"); } }
    while(again1=='Y'||again1=='y');
    getch();
    }
    void input(int *num1,int *num2)
    {gotoxy(25,5);
    int xx;
    int yy;
    printf("ENTER THE FIRST NUMBER:");
    scanf("%d",&xx);gotoxy(25,7);
    printf("ENTER THE SECOND NUMBER:");
    scanf("%d",&yy);
    *num1=xx;
    *num2=yy;
    }
    void addition(int num1,int num2,int *sum)
    {*sum=num1+num2;}
    void subtraction(int num1,int num2,int *difference)
    {*difference=num1-num2;}
    void division(int num1,int num2,int *quotient)
    {*quotient=num1/num2;}
    void multiplication(int num1,int num2,int *product)
    {*product=num1*num2;}
    void modulus(int num1,int num2,int *modulu)
    {*modulu=num1%num2;}
     

Share This Page