Main method declaration
Main method declaration is declaring to computer that from here the implementation of my code should be done. The process of declaring main is same in C and C++. As we declare int main where int stands for return type we should have to return something integral at the end of code so that it compiles without error. We can write our code in between the curly braces.
C
// C program to demonstrate // declaring main #include <stdio.h> int main() { // Your code here return 0; } |
C++
// C++ program to demonstrate // declaring main #include <iostream> int main() { // Your code here return 0; } |
It is not necessary to declare main in python code unless and until you are declaring another function in your code. So we can declare main in python as follows.
Python3
# Python program to demonstrate # declaring main def main(): # write your code here if __name__ = = "__main__" : main() |
Comparing Python with C and C++
In the following article, we will compare the 3 most used coding languages from a beginner’s perspective. It will help you to learn basics of all the 3 languages together while saving your time and will also help you to inter shift from one language you know to the other which you don’t. Let’s discuss a brief history of all the 3 languages and then we will move on to the practical learning.