Featured Post
- Get link
- X
- Other Apps
Hello readers are you new to coding? Then most probably you must be searching a way to write your first program. Don't worry I am here to help you out. The basic problem beginners face is that they get confused between the languages and their syntax.
The four languages that you can start with are:
1. C2. C++
3. Java
4. Python
Now let us learn how to write programs in these languages.
C Program:
#include<stdio.h>
void details( )
void main( )
{
printf("Hello! welcome to Coding Loops");
details( );
}
details( )
{
printf("Share this blog with your friends");
printf("Comment if you find this article helpful");
}
So as you have seen in the above code you can print the statements using printf( ) function and you have to keep the words you want to display on the screen inside double quotes. You can call a function written outside the main function like above in the code. One more thing you see those # statements, those are called preprocessors you have to write them as it is.
C++ Program:
#include<iostream.h>
#include<conio.h>
details( )
main( )
{
cout<<"Hello! welcome to Coding Loops"<<endl;
details( );
getch( );
}
details( )
{
cout<<"Share this blog with your friends"<<endl;
cout<<"Comment if you find this article helpful"<<endl;
}
C++ is an object oriented language but it is not necessary to create a class unlike in java, you can define a function without a class also. In C++ cout is used to print the statements on the screen. C++ is also known as C with classes.
Java Program:
public class CodingLoops
{
{
void details()
{
System.out.println("Share this blog with your friends");
System.out.println("Comment if you find this article helpful");
System.out.println("Comment if you find this article helpful");
}
public static void main(String args[])
{
System.out.println("Hello! welcome to Coding Loops");
CodingLoops ob=new CodingLoops();
ob.details();
System.out.println("Hello! welcome to Coding Loops");
CodingLoops ob=new CodingLoops();
ob.details();
}
}
}
Java is an object oriented language and it follows the concept of OOPs. In Java it is necessary to create a class and if you want to call a function you have to create the object of that class in which the function is defined, you can see this in the above code. In java System.out.print( ) function is used to display the statements on the screen. The function is always called with the object name just like in above code ob.details statement is calling the function details( ) where ob is object name.
Python Program:
class CodingLoops:
def details(self):
print('Share this blog with your friends')
print("Comment if you find this article helpful")
ob=CodingLoops( )
print("""Hello! welcome to Coding Loops""")
ob.details( )
Python is an object oriented language. In python print( ) function is used to display the statements on the output screen and you can put the statements in single quote or double quote or triple quote also, python provides you this feature. It is not necessary to create class in python, you can define the function without it also.
- Get link
- X
- Other Apps
Comments
Post a Comment