Results 1 to 2 of 2

Thread: Modularity using Functions

  1. #1
    Junior Member
    Join Date
    Apr 2008
    Answers
    8

    Modularity using Functions

    Determine the output generated by the following code segments, assuming the surrounding program code (whatever it is) compiles correctly.

    int F1 (int a, int b);
    int F2 (int b, int c);

    main()
    {
    int a = 1, b = 2, c = 3;

    c = F1 (a, b);
    printf ("main: %d %d %d\n", a, b, c);
    b = F2 (a, c);
    printf ("main: %d %d %d\n", a, b, c);
    }

    int F1 (int a, int b)
    {
    printf ("F1: %d %d\n", a, b);
    return a;
    }

    int F2 (int b, int c)
    {
    printf ("F2: %d %d\n", b, c);
    return c;
    }


  2. #2

    Re: Modularity using Functions

    The output for the given code will be like
    F1:1 2
    main:1 2 1
    F2:1 1
    main:1 1 1


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
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact