468,510 Members | 1,619 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,510 developers. It's quick & easy.

redefinition of 'int main()'

2
I have this code. write a code that asks for a number and define 2 functions. the first must return the remainder of the number by dividing by 7 and the second must return the day of the week (0 =Sunday 1=Monday .. 6=Saturday). so far i have done this:

BUT when i run it , it gives me this error --> redefinition of 'int main()' what does this mean and what do i have to fix?
Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int myNumbers(int a)
  5. {
  6.     return a % 7;
  7. }
  8. void myFuction(string);
  9. int main()
  10. {
  11.     int a;
  12.     cout << "give a number between 0-6: \n";
  13.     cin >> a;
  14.     cout << "the result is " << myNumbers(a);
  15. }
  16.  
  17. int main()
  18. {
  19.     myFuction("sunday");
  20.     myFuction("monday");
  21.     myFuction("tuesday");
  22.     myFuction("thursady");
  23.     myFuction("wendsday");
  24.     myFuction("friday");
  25.     myFuction("saturday");
  26.     return 0;
  27.  
  28.     cout << "then day is:" << myFunction();
  29. }
4 Weeks Ago #1
1 3152
dev7060
431 Expert 256MB
I have this code. write a code that asks for a number and define 2 functions. the first must return the remainder of the number by dividing by 7 and the second must return the day of the week (0 =Sunday 1=Monday .. 6=Saturday). so far i have done this:

BUT when i run it , it gives me this error --> redefinition of 'int main()' what does this mean and what do i have to fix?
Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int myNumbers(int a)
  5. {
  6. return a % 7;
  7. }
  8. void myFuction(string);
  9. int main()
  10. {
  11. int a;
  12. cout << "give a number between 0-6: \n";
  13. cin >> a;
  14. cout << "the result is " << myNumbers(a);
  15. }
  16.  
  17. int main()
  18. {
  19. myFuction("sunday");
  20. myFuction("monday");
  21. myFuction("tuesday");
  22. myFuction("thursady");
  23. myFuction("wendsday");
  24. myFuction("friday");
  25. myFuction("saturday");
  26. return 0;
  27.  
  28. cout << "then day is:" << myFunction();
  29. }
- Function names must be unique.
- The statement below return 0; is not effective.
- myFuction() has no body.
- Watch out for the typos : myFuction() or myFunction() and also, arguments while calling.
- The day is probably not to be passed as argument.
4 Weeks Ago #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

19 posts views Thread by Steven T. Hatton | last post: by
10 posts views Thread by Frederick Ding | last post: by
6 posts views Thread by rahulsinner | last post: by
36 posts views Thread by x_knifer_x | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.