Skip to main content

Fundamentals of Programming

Fundamentals of C and C++:

Every Programming Languages have some basic rules that should be followed to become a good programmer. Some of them are as follows.

Rules for Declaring Variable Names:

  1. Variable name can be any combination of 1 to 31 alphabets, digits or underscore.
  2. The first character of variable name should be an alphabet.
  3. Commas, blanks or any other special symbols are not allowed in variable name.

 

C/C++ Keywords:

int    double    auto    char    if    else    long    switch    case    enum    register    typedef    struct    extern    return    union    const    float    short    unsigned    continue    for    signed    void    default    goto    sizeof    volatile    do    break    static    while  new

Integer Float Conversions:

There are some Rules that should be kept in mind before using mathematic operations on different data types. They are as follows.
  1.  An arithmetic operation between an integer and integer always result in integer.
  2.  An arithmetic operation between a float and float always result in float.
  3.  An arithmetic operation between an integer and float always result in float.

Priority:

In programming languages, every symbol has its own importance and precedence over one another. Some of them are as follows.
  1.  *  /  %
  2. +  –
  3. =

* have highest precedence and then /,%,+,-,= these shold be kept in mind before using them in athematic operations.

Comments

Popular posts from this blog

Stack Data Structure in Cpp (c++)

  What is Stack? Stack refers to an abstract data types (ADTs) that is a collection of elements, with two principal operations that are addition and removal of elements from the collection. It works on the principle of LIFO (last In first out). It is also considered as a linear data structure.   Example: A set of books. It easy to take an item off the top rather from the middle. Basic operations of Stack: Push: Add item to the list. Pop: Removes item from the list.   Advantages: Stack is faster than heap memory allocation (also known as Dynamic Memory Allocation). Stack memory is automatically reclaimed when the function exits, which can be convenient for the programmer if the data is no longer required. Therefore, it is suitable for temporary data, where memory is not needed after the execution of a function. Implementation Of Stack in C++: #include<iostream> using namespace std; class StackMemory...

Tic-Tac-Toe Implementation in Cpp (C++) Step by Step

Inheritance (OOP)

Inheritance: In object-oriented programming,  inheritance  means an object or class has inherited behaviors from another object  or class. A child class is inherited from parent class. A child inherits characteristics of its parents, besides  inherited characteristics, a child may have its own unique characteristic. . In inheritance, every object of a child class is also an object of parent class, but not vice-versa. Base class: It is the class from which features are to be inherited into another class. Derived class: It is the class in which the base class features are inherited. A derived class can have additional properties and methods not present in the parent class that distinguishes it and provides additional functionality. REAL WORLD EXAMPLE: Let’s consider the Windows operating system. Windows 98 had certain properties and methods that were used in Windows XP. Windows XP was derived from Windows 98, but it was sti...