0

Running functions in main

Is there a way to "call" or "run" a whole function (already declared) within MAIN () function? I'm still in the "Functions" lesson in the "C ++ tutorial" and I've only seen a way to "cout" another functions result within MAIN (). Thanks

30th Aug 2018, 2:39 AM
Jean Tosta
Jean Tosta - avatar
1 ответ
0
Lets take the below code as an exemple: --------------------------------------- int TEST(){ int var_01; int var_02; int var_03; int x=0; cin>>var_01; cin>>var_02; cin>>var_03; for(x=0; x<5; x++){ cout<<"----------"<<endl; cout<<x<<":"<<var_01<<endl; cout<<x<<":"<<var_02<<endl; cout<<x<<":"<<var_03<<endl; var_01=++var_01; var_02=++var_02; var_03=++var_03; } return 0; } int main(){ TEST(); return 0; } -------------------------------------------- There is two different functions: 1-> TEST() 2-> MAIN() If I don't get "TEST()" declared within "MAIN()" function....then no action will be taken and the program will just return zero. So....is it correct to say that -> if you do not declare your function within "MAIN()" then it will not run? if yes, is there any other way to declare this function within the "MAIN()"? Thank you for your help. I appreciate.
31st Aug 2018, 1:35 AM
Jean Tosta
Jean Tosta - avatar