Help with C Program Hw Parameters

This is a discussion on Help with C Program Hw Parameters within the C Programming forums, part of the General Programming Boards category; Hi i need help with my hw: heres the question 2. Function with Input/Output Parameters Write a void function called ...

  1. #1
    Registered User
    Join Date
    Feb 2011
    Posts
    39

    Question Help with C Program Hw Parameters

    Hi i need help with my hw: heres the question

    2. 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.

    This is what i have , ive also include the exe of the program and a sample pic



    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;
    
                 if (*num1 < *num2){
    
                           temp = *num2;
    
                           *num2 = *num1;
    
                           *num1 = temp;
    
                 num1 = num1 + num2;
    
                 num2 = num1 - num2;
    
                           
    
                          }}
    return (0);
    Attached Images Attached Images  

  2. #2
    Programming King Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Middle of NoWhere
    Posts
    320
    Awesome :-)
    What a great program....
    Anyways, was just kidding....
    1. You implemented the function but didn't use.
    2. Inside main you should use that function call.
    I'll recommend you to read this....

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,548
    Your program doesn't produce that output.

    It doesn't contain anything to print "After the function is called..." and it doesn't contain any call to the function you have written.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  4. #4
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    So, what was the plan... Maybe post up some garbage lines to get past the homework rule and then wait for us to fix it for you?

    Please ... do the work and try again.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to execute other program within c program?
    By KoYoungSuk in forum C Programming
    Replies: 7
    Last Post: 06-07-2010, 05:08 AM
  2. Using variables in system()
    By Afro in forum C Programming
    Replies: 8
    Last Post: 07-03-2007, 12:27 PM
  3. BOOKKEEPING PROGRAM, need help!
    By yabud in forum C Programming
    Replies: 3
    Last Post: 11-16-2006, 10:17 PM
  4. process parameters
    By gvector1 in forum C# Programming
    Replies: 3
    Last Post: 06-05-2003, 11:40 AM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM

Tags for this Thread


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