void keyword

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • filitsa
    New Member
    • Mar 2007
    • 1

    #1

    void keyword

    Hello to all,
    I am a trying really hard to understand keywords for a rerort I have to make for my university but I don't seem to get the main idea....
    There is a question and if you have any ideas there are all very very wellcome:
    Whitch yould be the outcome after operating the func3 ( ), Explain ???
    Code:
    void func1 (int a)
    {
                  a=10;
    }
    int func2 (int a)
    {
                  a=10;
                  return (a);
    }
    void func3 ( )
    {
                  int a=2;
                  int b=5;
    
                  func1 (a);
                  b=func2 (a);
                  printf("a=%d,  b=%d\n", a, b);
    }
    Best Regards from Greece
    Filitsa
    Last edited by sicarie; Mar 13 '07, 01:55 PM. Reason: Added [code] and [/code] tags.
  • sicarie
    Recognized Expert Specialist
    • Nov 2006
    • 4677

    #2
    Originally posted by filitsa
    Hello to all,
    I am a trying really hard to understand keywords for a rerort I have to make for my university but I don't seem to get the main idea....
    There is a question and if you have any ideas there are all very very wellcome:
    Whitch yould be the outcome after operating the func3 ( ), Explain ???
    Code:
    void func1 (int a)
    {
                  a=10;
    }
    int func2 (int a)
    {
                  a=10;
                  return (a);
    }
    void func3 ( )
    {
                  int a=2;
                  int b=5;
    
                  func1 (a);
                  b=func2 (a);
                  printf("a=%d,  b=%d\n", a, b);
    }
    Best Regards from Greece
    Filitsa
    Ok, so this is a pretty basic example - what were you thinking about this one? Did you try to trace through it with a value? (Hint, assign arbitrarily small values to a and b and move through each line yourself)

    Comment

    • Ganon11
      Recognized Expert Specialist
      • Oct 2006
      • 3651

      #3
      There's no point in assigning arbitrary values to a and b - they are given values in the first two lines of func3. Knowing what you know about scope and functions, step through the program and find out what answers will be.

      Comment

      • sicarie
        Recognized Expert Specialist
        • Nov 2006
        • 4677

        #4
        Originally posted by Ganon11
        There's no point in assigning arbitrary values to a and b - they are given values in the first two lines of func3. Knowing what you know about scope and functions, step through the program and find out what answers will be.
        Haha, ah, I feel like an idiot... :(

        Comment

        Working...