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

Data Types

DATA TYPES in C/C++: Since C and C++ are strongly type languages, therefore every thing must be defined. Variables are classified according to their data type, which determines the kind of information that may be stored in them. Data Types Description C-Keyword Format Specifier integer Integers are whole numbers that can have both positive and negative values but no decimal values.   int   %d or %i Float Floating type variables can hold real numbers precision of 6 digits. float %f Double can hold real numbers with the precision of 14 digits. double %f Character data type allows a variable to store only one character. char %c Implementation in C: #include<stdio.h> int main() { printf(“%d n”,18); //this will print integer printf(“%fn”,32.56); //this will print decimal number printf(“%d %d %dn”,32,56,89); // %d is a place holder for integer and it provide place for one integer printf(“%ld...

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

Conditional Statement

Conditional Statement: A conditional statement is an if-then statement which means that if some statement is true then it follows the if-block of code and if the condition is false then it follows the else-block of code. In the programming world, there are two types of conditional statement namely if-else and switch. if-else Statement: Syntax: if (condition 1) { } else if (condition 2) { } else { }   Implementation of If-else statement in C: Q: Write a program to find the greatest of three numbers. #include<stdio.h> int main() { int a,b,c; printf(“Please Enter First Number “); scanf(“%d”,&a); printf(“Please Enter Second Number “); scanf(“%d”,&b); printf(“Please Enter Third Number “); scanf(“%d”,&c); if (a>b && a>c) { printf(“The Greatest Number is %d”,a); } else if (b>c) { printf(“The Greatest Number is %d”,b); } else { pr...