Your question

How to transfer control from one function to another in C language

Tags:
  • Programming
  • Apps
Last response: in Apps General Discussion
October 21, 2013 4:03:00 PM

Hello

I am noob in C programming... Just started learning it.

Please correct this code..

  1. #include <stdio.h>
  2. #include <conio.h>
  3. #include <math.h>
  4. void multi(int); //prototype of function
  5. int main(int argc, char** argv)
  6. {
  7. int x,y=1;
  8. while(y==1)
  9.  
  10. {
  11. printf("\nEnter number to find its multiplication:\n");
  12. scanf("%d",&x);
  13. printf("\nThe multiplication of %d is as follows:-\n",x);
  14. multi(x);// function calling statement
  15. printf("\nPlease press 1 to continue\n",y);
  16. scanf("%d",&y);
  17. }
  18. getch();
  19.  
  20. }
  21. void multi(int num)
  22. {
  23. int i;
  24. for(i=1;i<=10;i++)// Loop
  25. {
  26. printf("\n%d X %d = %d\n",num,i,num*i);
  27. }
  28. return;
  29.  
  30. }


As u can see i have used while loop for jumping control back to the beginning. This way i don't need to restart cmd again. In the multi function i want to transfer control back to its calling statement after its task so that it can show the printf statement below it. How do i do that?
If there are any errors in the code, then please correct them.


Thank you

More about : transfer control function language

a b L Programming
October 21, 2013 4:09:18 PM

When multi() terminates it will automatically return to the caller. Nothing to do in that regard.
m
0
l
Tom’s guide in the world
  • Germany
  • France
  • Italy
  • Ireland
  • UK
Follow Tom’s guide
Subscribe to our newsletter
  • add to twitter
  • add to facebook
  • ajouter un flux RSS