featurez

This is a discussion on featurez within the Linux Programming forums, part of the Platform Specific Boards category; ok so far i have my cal calculate - ,+ ,* ,/ and ^ i want to know am i ...

  1. #1
    Registered User
    Join Date
    Dec 2001
    Posts
    227

    featurez

    ok so far i have my cal calculate - ,+ ,* ,/ and ^ i want to know am i missing something ..? am i missing any featurez...? and another thing iz what if i wanted to calculate another problem how can i make the program run again...when they click on yes(y)... here is the code..

    #include <stdio.h>
    #include <math.h>

    int main()

    {
    int x, y, i;
    char var;
    int result = 1;


    printf("Type the operator +,-,/,* and your prob in this format 5+5\n");
    scanf("%d%c%d",&x,&var,&y);
    switch(var)
    {
    case '+':
    printf("Answer = %d\n",x+y);
    break;
    case '/':
    printf("Answer = %d\n", x/y);
    break;
    case '-':
    printf("Answer = %d\n", x-y);
    break;
    case '*':
    printf("Answer = %d\n", x*y);
    break;
    case '^':
    {
    for(i=0; i<y; i++)

    result *=x;

    printf("Answer = %d\n", result);
    break;
    default:
    printf(" please try that again\n ");

    }

    }
    }

  2. #2
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,825
    ^&^ &^&&^ &^ ^&^&&^& ^&^^^ ^& ^&^& ^^& ^^^ ^&&^ &^ & ^&^^&^?

    How about if someone wants to take the nth root of a number?

    > calculate another problem how can i make the program run again...

    Use a while loop...

    #include <ctype.h>

    char again = 'y';

    while(tolower(again) == 'y')
    {
    //do cool stuff
    //Ask if they wanna go again
    }

  3. #3
    Registered User
    Join Date
    Dec 2001
    Posts
    227
    i keep getting an error and i cant seem to track it down ....

    #include <stdio.h>
    #include <math.h>
    #include <ctype.h>

    int main()

    {
    int x, y, i;
    char var;
    int result = 1;
    char again = 'y';

    printf("Type the operator +,-,/,* and your prob in this format 5+5 or
    if you are working on power then here is the fromat 5^2\n");
    scanf("%d%c%d",&x,&var,&y);
    switch(var)
    {
    case '+':
    printf("Answer = %d\a\n",x+y);
    break;
    case '/':
    printf("Answer = %d\a\n", x/y);
    break;
    case '-':
    printf("Answer = %d\a\n", x-y);
    break;
    case '*':
    printf("Answer = %d\a\n", x*y);
    break;
    case '^':
    {
    for(i=0; i<y; i++)

    result *=x;

    printf("Answer = %d\a\n", result);
    break;
    default:
    printf(" please try that again\n ");

    {
    while(tolower(again) == 'y')
    {
    printf(" would you like to go away ",'y');
    }
    }

    btw can you please tell me alittle about the code that you posted cause i want to be able to understand what you just gave me... thanx

  4. #4
    Registered User
    Join Date
    Oct 2001
    Posts
    197
    and another thing iz what if i wanted to calculate another problem how can i make the program run again...when they click on yes(y)...
    Code:
    #include <stdio.h> 
    #include <math.h> 
    #include <ctype.h> 
    
    int main() 
    
    { 
    int x, y, i; 
    char var; 
    int result = 1; 
    char again = 'y'; 
    
    again: /* jumps to that mark after <goto again;> */
    
    printf("Type the operator +,-,/,* and your prob in this format 5+5 or 
    if you are working on power then here is the fromat 5^2\n"); 
    scanf("%d%c%d",&x,&var,&y); 
    switch(var)
    When you want to make the program run again just put
    Code:
    goto again;
    on it.

    klausi
    When I close my eyes nobody can see me...

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21