Page 7 of 9 FirstFirst ... 456789 LastLast
Results 61 to 70 of 82
  1. #61

    c = getch() version... hehe.. saonz..
    PHP Code:
    #include<stdio.h>
    #include<conio.h>
    int add(intint);
    int subtract(intint);
    float divide(intint);
    int multiply(intint);

    void main(void)
    {
     
    int abdef;
     
    float g;
     
    char c;
     
     
    printf("Enter 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);

     
    getch();

     if (
    c=='a' || c=='A')
     {
      
    d=add(ab);
      
    printf("%c\nThe sum of %d and %d is %d\n"cabd);  
     }

     if (
    c=='s' || c=='S')
     {
      
    e=subtract(ab);
      
    printf("%c\nThe difference of %d and %d is %d\n"cabe);  
     }

     if (
    c=='d' || c=='D')
     {
      
    g=divide(ab);
      
    printf("%c\nThe quotient of %d and %d is %.2f\n"cabg);  
     }

     if (
    c=='m' || c=='M')
     {
      
    f=multiply(ab);
      
    printf("%c\nThe product of %d and %d is %d\n"cabf);  
     }

     
    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);

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

    void main(void)
    {
     
    int abdef;
     
    float g;
     
    char c;
     
     
    printf("Enter 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);

     
    getche();

     if (
    c=='a' || c=='A')
     {
      
    d=add(ab);
      
    printf("\nThe sum of %d and %d is %d\n"abd);  
     }

     if (
    c=='s' || c=='S')
     {
      
    e=subtract(ab);
      
    printf("\nThe difference of %d and %d is %d\n"abe);  
     }

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

     if (
    c=='m' || c=='M')
     {
      
    f=multiply(ab);
      
    printf("\nThe product of %d and %d is %d\n"abf);  
     }

     
    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);


  2. #62
    nahimuot mn ko ui... naabot na ta ug page 5. hehe

  3. #63
    Nganong void main() man jd? int main() is the correct declaration man daw according to The C FAQ.

    Unya use getche() nalang. Aig kahadlok sa imong maestra. Haha. They already know na most students mo research jd na sa internet for their assignments. D nana mahibung nganong nakahibaw ka ug getche() as long as you know what it does.

    Quote Originally Posted by xiao_xiao View Post
    i found out nga case sensitive ang compiler so instead of if(c=='A'), use if(c=='a')...
    Yep case sensitive na since A and a are two different things. 'A' is 65 while 'a' is 97.
    Last edited by doomsweek; 02-12-2010 at 01:16 AM.

  4. #64
    int main() mn ako example at first peru ana ang TS nga void main() daw ganahan sa iyang maestra.

  5. #65
    Quote Originally Posted by xiao_xiao View Post
    int main() mn ako example at first peru ana ang TS nga void main() daw ganahan sa iyang maestra.
    I was referring to the topic starter.

    Pangutana sad sa imong maestra unsay reason why void main() and iyang gpagamit. Don't blindly believe in what they say or teach. I had one teacher that had a demo in front of our class that went wrong and blamed it all on a virus on his laptop, when in fact he just forgot to enable a certain setting to make it work.

  6. #66
    Elite Member
    Join Date
    Aug 2008
    Posts
    1,053
    Blog Entries
    1
    LOL... nice discusson for basic calculation hehehehe

  7. #67
    magloop man cguro ka kung unsa ang giinput then mag swithch ka nindot ang loop kay mag cge dagan imu program

  8. #68
    @markytrigger: wla pa mn tingale ga discuss ilang teacher anang for loop ug switch.
    as for now, kung unsa pay gitudlo sa teacher, mao sa ilang gamiton.

  9. #69
    try daw before every scanf add ug flushall();
    nyah instead of making a lot of if statements, himoa ug if-else if kay aron one time ra magcheck imu program if mkuha na niya ang desired choice.

    and also c = getchar(); para makita nimo ang choice nga giinput

    also ayaw nlng himo ug functions for add, subtract, multiply and divide, dretsoa nlng..the shorter the code the better,,

    and try this:

    if(toupper(c) == 'A')
    {
    //imong statements
    }

    toupper(c) is a function nga muconvert sa charcter to its uppercase form, by this, pwede ra muinput ang user bisan dili big letter kay iconvert naman na niya dretso..

    ..and para maresolve n inyo conflict sa void main(void), mao na xa ang declaration because ang main function does not return anything, and wala pud ipass nga parameters sa main, that's why void main(void).. pwede man pud nang int main(void), pero magbutang ka ug return 0; sa end sa main function, w/c is dugang npd sa code confusion..
    Last edited by drixx101; 02-13-2010 at 12:34 AM. Reason: added info

  10. #70
    ka complicated na gud ug mga suggestions ninyo, hehehe hagbay naman ni na human (page 2 post 1, kilangan ra niya simple nga program according to their discussions sa skul. Na pass nani sa iyang teacher.

  11.    Advertisement

Page 7 of 9 FirstFirst ... 456789 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