Connecting Tech Pros Worldwide Help | Site Map

void keyword

  #1  
Old March 13th, 2007, 02:16 PM
Newbie
 
Join Date: Mar 2007
Posts: 1
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 ???
Expand|Select|Wrap|Line Numbers
  1. void func1 (int a)
  2. {
  3.               a=10;
  4. }
  5. int func2 (int a)
  6. {
  7.               a=10;
  8.               return (a);
  9. }
  10. void func3 ( )
  11. {
  12.               int a=2;
  13.               int b=5;
  14.  
  15.               func1 (a);
  16.               b=func2 (a);
  17.               printf("a=%d,  b=%d\n", a, b);
  18. }
  19.  
Best Regards from Greece
Filitsa

Last edited by sicarie; March 13th, 2007 at 02:55 PM. Reason: Added [code] and [/code] tags.
  #2  
Old March 13th, 2007, 02:57 PM
sicarie's Avatar
Moderator
 
Join Date: Nov 2006
Location: USA
Posts: 3,927

re: void keyword


Quote:
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 ???
Expand|Select|Wrap|Line Numbers
  1. void func1 (int a)
  2. {
  3.               a=10;
  4. }
  5. int func2 (int a)
  6. {
  7.               a=10;
  8.               return (a);
  9. }
  10. void func3 ( )
  11. {
  12.               int a=2;
  13.               int b=5;
  14.  
  15.               func1 (a);
  16.               b=func2 (a);
  17.               printf("a=%d,  b=%d\n", a, b);
  18. }
  19.  
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)
  #3  
Old March 13th, 2007, 03:37 PM
Ganon11's Avatar
Moderator
 
Join Date: Oct 2006
Location: New York, United States of America
Posts: 3,444

re: void keyword


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.
  #4  
Old March 13th, 2007, 03:43 PM
sicarie's Avatar
Moderator
 
Join Date: Nov 2006
Location: USA
Posts: 3,927

re: void keyword


Quote:
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... :(
Reply


Similar Threads
Thread Thread Starter Forum Replies Last Post
VOID Keyword (VB vs C# Question) SMH answers 1 October 29th, 2007 11:35 PM
a question related to void liux answers 8 May 19th, 2007 07:25 PM
int main(void) Why void? rahulsinner@gmail.com answers 6 April 7th, 2006 06:45 AM
void keyword Scott answers 3 November 16th, 2005 02:22 PM