Cprogram Input/output parameter HELP

This is a discussion on Cprogram Input/output parameter HELP within the C Programming forums, part of the General Programming Boards category; Problem : . Function with Input/Output Parameters Write a void function called Result that has only two type int input/output ...

  1. #1
    Registered User
    Join Date
    Feb 2011
    Posts
    39
    Problem : . Function with Input/Output Parameters

    Write a void function called Result that has only two type int input/output parameters. The function will return the sum of the two original parameters through the first parameter. It will also return the differences of the two original parameters through the second parameter.

    Write a main function to test this function


    Need help does not do calculations D:



    Code:
    #include <math.h>
    #include <stdlib.h>
    #include <stdio.h>
    
     
    
    void result(double *smp, double *lgp);
    
    int
    
    main(void)
    
    {
    
              double num1, num2;
              
    
               /* Gets test data */
    
               printf("Enter the first number");
    
               scanf("%lf", &num1);
    
               printf("Enter the second number");
    
               scanf("%lf", &num2);
    
               printf("The first number is %2.f", num1);
    
               printf("The second number is %2.f", num2);
    
               system("pause");
    
               return (0);
    
               }
    
    void
    
    result(double *num2, double *num1)
    
    {
    
                 double temp = *num1;
                  *num1 = *num1 + *num2;
    
                 *num2 = temp - *num2;
    
                           
    }
    it should run like the pic above
    Attached Images Attached Images  

  2. #2
    THANK YOU KINDLY SIR Phenax's Avatar
    Join Date
    Mar 2011
    Posts
    74
    Hint: It doesn't do the calculations, because you never told it to do the calculations.
    Quote Originally Posted by Plato
    Never discourage anyone...who continually makes progress, no matter how slow.

  3. #3
    Registered User
    Join Date
    Feb 2011
    Posts
    39
    soooooo.....yaaa idk lol im just a beginner in all this :P

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    All the calculations are is getting the sum. So just add the second argument to the first.


    Quzah.
    Hope is the first step on the road to disappointment.

  5. #5
    THANK YOU KINDLY SIR Phenax's Avatar
    Join Date
    Mar 2011
    Posts
    74
    Quote Originally Posted by 123456tacos View Post
    soooooo.....yaaa idk lol im just a beginner in all this :P
    C executes the main function by default, and no other function is executed by default. If you want to execute a function that is not main, you have to explicitly do so. You have not explicitly called the function that you have made. C isn't going to automatically figure out what you want the arguments to be and call the function for you.

    Also,
    printf("%.2f", arg); not printf("%2.f", arg);
    Quote Originally Posted by Plato
    Never discourage anyone...who continually makes progress, no matter how slow.

  6. #6
    Registered User
    Join Date
    Feb 2011
    Posts
    39
    ahahaha thanks i got it working DD

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Errors including <windows.h>
    By jw232 in forum Windows Programming
    Replies: 4
    Last Post: 07-29-2008, 02:29 PM
  2. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 01:13 AM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 07:39 AM
  4. ras.h errors
    By Trent_Easton in forum Windows Programming
    Replies: 8
    Last Post: 07-15-2005, 11:52 PM
  5. Learning OpenGL
    By HQSneaker in forum C++ Programming
    Replies: 7
    Last Post: 08-06-2004, 09:57 AM

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