5 Basic Concepts of any Programming Language


LanguageExample program
“C”#include <stdio.h>
void main() {
printf(“Hello World”);
C++#include <iostream>
int main() {
cout << “Hello World”;
return 0;
Pascalprogram helloworld (output);
writeln(‘Hello World’);

2. Variable Declaration

A variable or scalar is a storage location paired with an associated symbolic name, which contains some known or unknown quantity of information referred to as a value. The variable name is the usual way to reference the stored value. Variables are the backbone of any program, and thus the backbone of any programming language.in simple terms, a variable is simply a way to store some sort of information for later use, and we can retrieve this information by referring to a “word” that will describe this information.

Different types of variables include:

  • Integer – to store integer or “whole” numbers
  • Real – to store real or fractional numbers (also called float to indicate a floating point number)
  • Character – A single character such as a letter of the alphabet or punctuation.
  • String – A collection of characters

In order to use a variable within a program, the compiler needs to know in advance the type of data that will be stored in it. For this reason, we declare the variables at the start of the program. Variable declaration consists of giving a new name and a data type for the variable. This is normally done at the very start of the program..

For example:

#include <stdio.h>
void main() {
int age;
float salary;
char middle_initial;
age = 25;
salary = 196578.89;
middle_initial = "K";
printf("I am %d years old ", age);
printf("I make %f per year " salary);
printf("My middle initial is %c ", middle_initial);
Prev2 of 4Next

Leave a Reply

Your email address will not be published. Required fields are marked *