2. INTRODUCTION TO PROGRAMMING
LANGUAGES
There are so many programming languages and let’s see some of the most widely used programming languages.
Now let us discuss about the programming languages such as c,c++,python and java.
3. #include <stdio.h>
int main()
{
int x, y, z;
printf("Enter two numbers to addn");
scanf("%d%d", &x, &y);
z = x + y;
printf("Sum of the numbers = %dn", z);
return 0;
}
In the above c program #include<stdio.h> is a header file.we write the program in main function,We declare 3 variables x,y,z.As we are adding
the numbers
We use int as the data type which says the compiler that the given variable inputs are of interger type. printf statement is used to print the
statements
Present between the double quotes.Scanf is used to read the inputs.z is another variable and we add x and y and by using the assignment
operator(=)
we assign the value to z.And by using printf statement we print the value of z,i.e; addition of x and y. retutn 0 indicates that the code is ended.
C PROGRAM
4. C++ Program:
#include <iostream>
using namespace std;
int main()
{
int num1=15 ,num2=10, sum;
sum = num1 + num2;
cout<<“sum”;
return 0;
}
In the above c program #include<iostream> is a header file.we write the program in main function,We declare
3 variables as num1,num2,sum.As we are adding the numbers
We use int as the data type which says the compiler that the given variable inputs are of interger type. cout
statement is used to print the statements
Present between the double quotes.in general cin is used to read the inputs.sum is another variable name and
we add num1 and num2 and by using the assignment operator(=)
we assign the value to sum.And by using cout statement we print the value of z,i.e; addition of num1 and
num2. retutn 0 indicates that the code is ended.
5. PYTHON programming:
x = 5
y = 10
print(x + y)
Python is a very easy language to implement.It is one of the most popular languages present days.in above
program x and y bare variables which contains the values 5 and 10 individualy.the print is used to give the
output.
We can also implement this by taking inputs from the user aswell.
6. Java programming:
import java.util.Scanner;
class Add
{
public static void main(String[] arg)
{
int a,b,c;
Scanner sc=new Scanner(System.in);
System.out.println("Enter first number");
a=sc.nextInt();
System.out.println("Enter second number");
b=sc.nextInt();
c=addition(a,b);
System.out.println(" Addition of two numbers is : "+c);
}
static int addition(int x,int y)
{
return x+y;
}
}
In the above program the import statement is
used,and we define the class name as add.,inside
class we have our addition of two numbers
code,which produces the security to the code.
The new is the name which is used to define the
object to the class.In java System.out.println is
used to give the output.int x and int y are the
variables which gives the input values to the class.
7. Basic differences:
>The c language is the basic programming language. Dennis Ritchie is the founder of c language.
>The c++ is the addition of c language.It was developed by Bjarne Strustrup.The c++ language has
the security to the code as it contain the classes and it is object oriented language.
>The python is developed by Guido Van Rossum.The python is the interpreted language i.e; it
line.The indentation to be followed in python language.It is very easy to learn due to its general
>james gosling is the father of java.java is the most widely used language in the world as it
provides the security to the code.java is the completely object oriented language.It is hard to
learn and implement compared all other languages.But most of the applications are developed by
using java.