Page 4 of 9 FirstFirst ... 234567 ... LastLast
Results 31 to 40 of 82
  1. #31

    @chaosorb: bacn required sa ila mag-gamit ug function. natingala pud ko sa TS nganong redundant iya getch();

  2. #32
    Elite Member
    Join Date
    Aug 2008
    Posts
    1,053
    Blog Entries
    1
    "Create a pseudocode, flowchart and C program that ask the user 2 integer numbers. The user then enters another character in order to choose which operator to perform: A - addition, S - subtraction, M - multiplication, D- division. Create separate functions for each operation."

  3. #33
    Quote Originally Posted by xiao_xiao View Post
    @chaosorb: bacn required sa ila mag-gamit ug function. natingala pud ko sa TS nganong redundant iya getch();
    ana dyud na xiao basta gikan sa teachers, gamiton ang getch(); para mo pause.

  4. #34
    Quote Originally Posted by ChaosOrb View Post
    to TS, below is my take on your program. I'm not sure if this will run, but more or less, its the appropriate solution.

    TIPS
    *KISS(keep it short and simple)
    -avoid using too many variables
    -avoid using unnecessary functions
    -recycle variables if necessary

    PHP Code:
    #include <stdio.h>
    #include <conio.h>

    int main() {
      
    int ab;
      
    char c;
      
      
    clrscr();
      
    printf("Enter value for 1st number: ");
      
    scanf("%i",&a);
      
    printf("Enter value for 2nd number: ");
      
    scanf("%i",&b);
      
      
    printf("\nChoices:\n\t[A]ddition\n\t[S]ubtraction\n\t[M]ultiplication\n\t[D]ivision\nSelect: ");
      
    getche();
      
      if(
    c=='A'){
        
    printf("The sum of %i and %i is %i",ab, (a+b));
      }
      if(
    c=='S'){
        
    printf("The difference of %i and %i is %i",a,b,(a-b));
      }
      if(
    c=='M'){
        
    printf("The product of %i and %i is %i",a,b,(a*b));
      }
      if(
    c=='D'){
        
    printf("The quotient of %i and %i is %6.2f",a,b,(a/b));
      }
      
    getch();

    critic to your hearts content
    Compiling....

    Mo exit ang program after selecting choice D or d.

    Answered na ni sa post #18

  5. #35
    kung pseudocode basihan sayop japon kang smarkies... dapat i-input daan ang integers before choices. hehe

    gika ra ni kang smarkies... gi-change lng nako ang order sa pag input... base sa pseudocode...

    PHP Code:
    #include<stdio.h>
    #include<conio.h>
    int add(intint);
    int subtract(intint);
    float divide(intint);
    int multiply(intint);

    main(void)
    {
     
    int abdef;
     
    float g;
     
    char c;
     
    clrscr();

     
    printf("\nEnter two integers separated by a space: ");
     
    scanf("%d %d", &a, &b); 

     
    printf("Select an operation:\n(A) Add\n(S) Subtract\n(D) Divide\n(M) Multiply\n");
     
    printf("Choice: ");
     
    scanf("%c",&c); 

     if (
    c=='A')
     {
      
    d=add(ab);
      
    printf("The sum of %d and %d is %d"abd);
      
    getch();
     }

     if (
    c=='S')
     {
      
    e=subtract(ab);
      
    printf("The difference of %d and %d is %d"abe);
      
    getch();
     }

     if (
    c=='D')
     {
      
    g=divide(ab);
      
    printf("The quotient of %d and %d is %.2f"abg);
      
    getch();
     }

     if (
    c=='M')
     {
      
    f=multiply(ab);
      
    printf("The product of %d and %d is %d"abf);
      
    getch();
     }
     
    getch();

    }


    int add(int aint b)
    {
     return (
    a+b);
    }
    int subtract(int aint b)
    {
     return (
    a-b);
    }
    int multiply(int aint b)
    {
     return (
    a*b);
    }
    float divide(int aint b)
    {
     return ((float)
    a/b);


  6. #36
    Quote Originally Posted by SmaRkieS View Post
    ana dyud na xiao basta gikan sa teachers, gamiton ang getch(); para mo pause.
    i mean kanang ok ra mn cguro kung isa ra ka getch();
    didto sa last part ra ka magbutang.

  7. #37
    Quote Originally Posted by xiao_xiao View Post
    @harryperales: ok ra mn yata iyang function prototypes...
    ang standard C programs nag-require na cya nga ang imong function prototype including sa iyang parameters should be the same as the one on the function declaration.

  8. #38
    mudagan mn japon...
    bacn good programming practice lng cguro nga butngan ug variable ang parameters.

  9. #39
    Mga bro, salamat kaayo sa inyong pagtabang! I'll see which corrected nga programs nako ang pwede nako magamit.

    Ask lang diay ko, unsa ang gamit sa getche()?

    (PS: Using katong code with getche() ang naka pa work sa program diay so far.. Pero hadlok man ko mugamit sa getche() nga command oi kay magduda nya ang maestra namo ngano kahibaw ko mugamit ana nga wala man siya nagtudlo ana.. )
    Last edited by marcdaven; 02-11-2010 at 10:30 PM. Reason: Compiling questions

  10. #40
    Quote Originally Posted by xiao_xiao View Post
    gika ra ni kang smarkies... gi-change lng nako ang order sa pag input... base sa pseudocode...

    PHP Code:
    #include<stdio.h>
    #include<conio.h>
    int add(intint);
    int subtract(intint);
    float divide(intint);
    int multiply(intint);

    main(void)
    {
     
    int abdef;
     
    float g;
     
    char c;
     
    clrscr();

     
    printf("\nEnter two integers separated by a space: ");
     
    scanf("%d %d", &a, &b); 

     
    printf("Select an operation:\n(A) Add\n(S) Subtract\n(D) Divide\n(M) Multiply\n");
     
    printf("Choice: ");
     
    scanf("%c",&c); 

     if (
    c=='A')
     {
      
    d=add(ab);
      
    printf("The sum of %d and %d is %d"abd);
      
    getch();
     }

     if (
    c=='S')
     {
      
    e=subtract(ab);
      
    printf("The difference of %d and %d is %d"abe);
      
    getch();
     }

     if (
    c=='D')
     {
      
    g=divide(ab);
      
    printf("The quotient of %d and %d is %.2f"abg);
      
    getch();
     }

     if (
    c=='M')
     {
      
    f=multiply(ab);
      
    printf("The product of %d and %d is %d"abf);
      
    getch();
     }
     
    getch();

    }


    int add(int aint b)
    {
     return (
    a+b);
    }
    int subtract(int aint b)
    {
     return (
    a-b);
    }
    int multiply(int aint b)
    {
     return (
    a*b);
    }
    float divide(int aint b)
    {
     return ((float)
    a/b);

    @xiao: muungot man gihapon siya inig input nako sa desired choice nako.. then gitry nako nga walay getch() sa mga if statements, the same problem man gihapon.. T_T

    Code:
    #include<stdio.h>
    #include<conio.h>
    int add(int, int);
    int subtract(int, int);
    float divide(int, int);
    int multiply(int, int);
    
    main(void)
    {
     int a, b, d, e, f;
     float g;
     char c;
     clrscr();
    
     printf("Select an operation:\n(A) Add\n(S) Subtract\n(D) Divide\n(M) Multiply\n");
     printf("Choice: ");
     scanf("%c",&c);
    
     printf("\nEnter two integers separated by a space: ");
     scanf("%d %d", &a, &b);
    
     if (c=='A')
     {
      d=add(a, b);
      printf("The sum of %d and %d is %d", a, b, d);
      getch();
     }
    
     if (c=='S')
     {
      e=subtract(a, b);
      printf("The difference of %d and %d is %d", a, b, e);
      getch();
     }
    
     if (c=='D')
     {
      g=divide(a, b);
      printf("The quotient of %d and %d is %.2f", a, b, g);
      getch();
     }
    
     if (c=='M')
     {
      f=multiply(a, b);
      printf("The product of %d and %d is %d", a, b, f);
      getch();
     }
     getch();
    
    }
    
    
    int add(int a, int b)
    {
     return (a+b);
    }
    int subtract(int a, int b)
    {
     return (a-b);
    }
    int multiply(int a, int b)
    {
     return (a*b);
    }
    float divide(int a, int b)
    {
     return ((float)a/b);
    }  
    
    


    @smarkies: Kani nga program hinuon, muwork ni pero pseudocode namo kay dapat maguna ang input of integers before sa choice sa operation.

    Quote Originally Posted by MarkCuering View Post
    float e; <-- use for what?
    printf("The quotient of %d and %d is %d", a, b, g); <-- how you output floating point numbers?
    Sayup ko ani bro.. Ang e variable kay para sa subtract diay na nga function.. Dapat wala na diay toy float variable declaration within sa if function sa divide.

  11.    Advertisement

Page 4 of 9 FirstFirst ... 234567 ... LastLast

Similar Threads

 
  1. Help me in my laptop problem
    By Wenxp7 in forum Computer Hardware
    Replies: 16
    Last Post: 10-08-2010, 07:48 PM
  2. pls help me in my pldt dsl connection...
    By glenntacan in forum Networking & Internet
    Replies: 5
    Last Post: 01-23-2009, 05:15 PM
  3. help me in my front panel config
    By absimon in forum Computer Hardware
    Replies: 5
    Last Post: 12-05-2008, 07:18 PM
  4. Please help me in martial arts.
    By Chalil in forum Sports & Recreation
    Replies: 11
    Last Post: 09-20-2006, 10:52 PM
  5. Where can I repair my flash drive?!!! Help me!!!
    By jonmlas in forum Gizmos & Gadgets (Old)
    Replies: 13
    Last Post: 11-30-2005, 12:36 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top