What is an interpreter and its need?

An interpreter is a program that translates source code written in high-level language to machine code. It is similar to compiler and does the same task of translation from high-level to low-level language. Despite of its similarity, the working mechanism of interpreter and compiler are different.

An interpreter does not translate whole code at once like compiler. Rather, is reads entire source code at once. Translates single instruction to machine code or some intermediate code. Then executes the translated machine code instruction immediately and translates next instruction if needed.

Read more

What is a compiler and its need?

A Compiler is a program or set of programs that converts source code written in a high-level language to low-level language (assembly language or machine language). A programming language can have many compilers. For example – GCC C, Turbo C, Quick C etc. are different compilers for C programming language.

Read more

Various programming paradigms

Programming paradigm is a way to classify programming languages according to their style of programming and features they provide. There are several features that determine a programming paradigm such as modularity, objects, interrupts or events, control flow etc. A programming language can be single paradigm or multi-paradigm.

With the wide spread of programming, various programming paradigms came into existence. Some popular programming paradigms are:

Imperative programming

Imperative programming is the oldest paradigm and is still in practice. It is the widely practiced paradigm in the day-to-day programming. It mainly focuses on steps to be done and works on the logic of “First do this then do that”. It defines a sequence of statements in order of which the operations must take place. In imperative programming, the control flow is explicit and depend on collection of GOTO statements. Imperative programming lacks the support of modularity.

Examples of imperative programming languages are – Assembly, C, C++, Java etc.

Read more

What is computer program and programming

Programming is an art, skill, poetry that is mastered through immense practice, patience, and experience. Before I formally define programming, let us talk about what is a computer program?

What is a computer program?

A Program is a set of instructions compiled together in a file to perform some specific task by the CPU (Central Processing Unit). It is a series of binary numbers (0s and 1s) arranged in a sequence, which when given to the computer performs some task.

Read more

C program to right rotate an array

Write a C program to right rotate an array by n position. How to right rotate an array n times in C programming. Logic to rotate an array to right by n position in C program.

Right array rotation

Example

Input

Input 10 elements in array: 1 2 3 4 5 6 7 8 9 10
Input number of times to rotate: 3

Output

Array after right rotation: 8 9 10 1 2 3 4 5 6 7

Read more

C program to left rotate an array

Write a C program to left rotate an array by n position. How to rotate left rotate an array n times in C programming. Logic to rotate an array to left by n position in C program.

Left rotate an array

Example

Input

Input 10 elements in array: 1 2 3 4 5 6 7 8 9 10
Input number of times to rotate: 3

Output

Array after left rotation 3 times: 4 5 6 7 8 9 10 1 2 3

Read more

C program to swap two numbers using call by reference

Write a C program to swap two numbers using pointers and functions. How to swap two numbers using call by reference method. Logic to swap two number using pointers in C program.

Example

Input

Input num1: 10
Input num2: 20

Output

Values after swapping:
Num1 = 20
Num2 = 10

Read more

C program to add two numbers using pointers

Write a C program to read two numbers from user and add them using pointers. How to find sum of two number using pointers in C programming. Program to perform arithmetic operations on number using pointers.

Example

Input

Input num1: 10
Input num2: 20

Output

Sum = 30
Difference = -10
Product = 200
Quotient = 0

Read more