Sunday, 19 July 2015

if Statement :


In C++ if statement is used to check the truthness of the expression. Condition written inside If statement consists of a boolean expression. If the condition written inside if is true then if block gets executed.

Syntax

The syntax of if statement is as follows :

             if (condition){
                  statement;
                                   }

The above syntax is used for single statement. A set of statements can also be made conditional. In this case, these statements are written in curly brackets {  } . The set of statements is also called compound statements.

                The syntax for compound statements in if statement is as follows :

            if (condition){
                statement 1;
                statement 2;
                .
                .
                statement n;
                                 }

Example :  

void main(){
int marks;
cout<<"Enter Marks : ";
cin>>marks;
if (marks>40)                        //////////////////////////Condition/////////////
cout<<"Congratulations.....You Have Passed.";               ////////////////Statement////////////
getch();
}

If user enter more than 40 marks then statement is excuted otherwise display will be empty.
Firstly check if condition, condition is fulfil then enter into a body otherwise program will be terminated.

Output :

Enter Marks : 80
Congratulations.....You Have Passed.

Again Run the program,

Enter Marks : 30
///program will be terminated and display screen will be empty.

Friday, 17 July 2015

ASCII Characters :

How to convert ASCII character set to their respective integers representation in C++ programming ?



#include <iostream>
using namespace std;

int main(void)
{
cout<<"For integer number from 32 till 127\n";
cout<<"their representation for\n";
cout<<"characters is shown below.\n";
cout<<"integer      character";
cout<<"-------         ---------\n";

for (int i = 32; i<128; i++)
{
cout<<i<<"\t\t"<<(char) i<<"\n";
 }
return 0;
}


Output example :

For integer number from 32 till
their representation for
characters is shown below

integer    character
-------       ---------

32                            >>     means space      
33                !
34                "
35                #
36                $
37                %
38                &
39                '
40                (
41                )
42                *
43                +
44                ,
45                -
46                .
47                /
48                0
49                1
50                2
51                3
52                4
53                5
54                6
55                7
56                8
57                9
58                :
59                ;
60                <
61                =
62                >
63                ?
64                @
65                A
66                B
67                C
68                D
69                E
70                F
71                G
72                H
73                I
74                J
75                K
76                L
77                M
78                N
79                O
80                P
81                Q
82                R
83                S
84                T
85                U
86                V
87                W
88                X
89                Y
90                Z
91                [
92                \
93                ]
94                ^
95                _
96                `
97                a
98                b
99                c
100              d
101              e
102              f
103              g
104                h
105                i
106                j
107                k
108                l
109                m
110                n
111                o
112                p
113                q
114                r
115                s
116                t
117                u
118                v
119                w
120                x
121                y
122                z
123                {
124                |
125                }
126                ~
127                ⌂
Press any key to continue . . .

setprecision Manipulator :


The 'setprecision' manipulator is used to set the number of digits to be displayed after decimal point. It is applied to all subsequent floating point numbers written to that output stream. The value is rounded with the use of this manipulator.

Syntax :


The syntax of 'setprecision' manipulator is as follows :

      setprecision (n)

The n indicates the number of digits displayed after the decimal point. It can be an unsigned positive integer constant, variable and expression.

Example : 

                       #include <iostream.h>
                    #include <conio.h>
                    #include <iomanip.h>
void main(){

                   double r, n1 = 132.364, n2 = 26.91;
                r = n1 / n2;

     cout<<r<<endl;
     cout<<setprecision(5)<<r<<endl;
     cout<<setprecision(4)<<r<<endl;
     cout<<setprecision(3)<<r<<endl;
     cout<<setprecision(2)<<r<<endl;
     cout<<setprecision(1)<<r<<endl;

getch();
}

Output :

                      4.918766
                      4.91877
                      4.9188
                      4.919
                      4.92
                      4.9

Thursday, 16 July 2015

setw() Manipulators :


The word 'setw' stands for set width. The setw manipulator is used to display the value of an expression in specified columns. The value of expression can be string or number. If the value of expression is less than specified columns, the additional columns are left blank from left side. If output is larger than the specified columns. The use of setw has no effect on the output in this case.
  1. setw() is library function in C++.
  2. setw() is declared inside #include<iomanip>.
  3. setw() will set field width.
  4. setw() sets the number of characters to be used as the field width for the next insertion operation.

Syntax :


The syntax of 'setw' manipulator is as follows :
  
     setw(n)

The n indicates the number of columns in which the value is to be displayed.

Example 1 :

                 #include<iostream.h>
                 #include<conio.h>
                 #include<iomanip.h>          

void main(){
                
              cout<< setw (10);
              cout<< "Hello" <<endl;
getch();
}
  • Now Length of String Hello is 5.
  • We have set field width 10 so it will utilizes 5 fields.
  • Remaining 5 fields are kept blank.
  • Default Justification : Left.

Example 2 :


          #include <iostream>
          #include <iomanip>

using namespace std;

   int main(){
  
              int width = 6;
              int row;
              int column;

    for(row=1;row<=10;row++){
        for(column = 1; column <= 4; column++){
     
              cout << setw(width) << row * column;
                                              }
     cout << endl;
                            }

 return 0;
            }

Output :


 1     2     3     4
 2     4     6     8
 3     6     9    12
 4     8    12    16
 5    10    15    20
 6    12    18    24
 7    14    21    28
 8    16    24    32
 9    18    27    36
10    20    30    40

Advantages Of Object Oriented Programming :


Advantages Of Object Oriented Programming

Advantages Of Object Oriented 
           Programming



  • OOP provides a clear modular structure for programs.
  • It is good for defining abstract data types.
  • Implementation details are hidden from other modules and other modules has a clearly defined interface.
  • It is easy to maintain and modify existing code as new objects can be created with small differences to existing ones.
  • Objects, methods, instance, message passing, inheritance are some important properties provided by these particular languages.
  • Encapsulation, polymorphism, abstraction are also counts in these fundamentals of programming language.
  • It implements real life scenario.
  • In OOP, programmer not only defines data types but also deals with operations applied for data structures.

  • Features of Object Oriented Programming :

    • More reliable software development is possible.
    • Enhanced form of c programming language.
    • The most important Feature is that it’s procedural and object oriented nature.
    • Much suitable for large projects.
    • Fairly efficient languages.
    • It has the feature of memory management.

    Wednesday, 15 July 2015

    Sizes of Different Data Types :


    How to Find Sizes of Data Types.
                                                   
                                                Then watch video and follow me :


                  

    Tuesday, 14 July 2015

    Operator Precedence :


    The order of precedence in C++ language is as follows :

    • Any expression given in parentheses is evaluated first.
    • Then multiplication *  and division / operators are evaluated.
    • Then plus +  and minus - operators are evaluated.
    • In case of parentheses within parentheses, the expression of the inner parentheses will be evaluated first.


    Example :

                The expression 5 * (4 / (5 - 1 ) ) + 3 is evaluated in the following order :
    1. First of all, the expression 5 - 1 will be evaluated. It gives a value 4.
    2. Secondly, 4 will be divided by the result of last line i.e. 4 / 4 giving value 1.
    3. Thirdly, will be multiplied by i.e. giving a result 5.
    4. Finally, 5 will be added in 3 and the last result will be 8.

    Difference b/w Prefix and Postfix Increment :


    When increment operator is used independently, prefix and postfix form work similarly. For example, the result of A++ and ++A is same.

     But when increment operator is used in a larger expression with other operators, prefix and postfix forms work differently. For example, the results of two statements A = ++B and A = B++ are different.


    In prefix form, The statement A = ++B contains two operators ++ and =. It works in following order:

    1. It increments the value of B by 1.
    2. It assigns the value of B to A.

    In postfix form, the statement A = B++ works in the following order :

    1. It assigns the value of B to A.
    2. It increments the value of B by 1.



    Monday, 13 July 2015

    Kickstarter Backer & Contributor Version pdf :


                                              C++,khgamujtaba,programming book,C++ How to program

    Kickstarter Backer & Contributor Version pdf Download


    Perform All Mathematical Operations :



                 

    Arithmetic Operators :


    Arithmetic operator is a symbol that performs mathematical operation on data. C++ provides many arithmetic operators. Following is a list of all arithmetic operators in C++.


    OperationSymbolDescription
    Addition+Adds two values
    Subtraction-Subtracts one value from another value
    Multiplication*Multiplies two values
    Division/Divide one value by another value
    Modulus%Gives the remainder of division of two integers


    All arithmetic operators work with numeric values. Suppose we have two variables A and B where A = 10 and B = 5. Arithmetic operators can be used on A and B as follows :


    OperationResult
    A + B15
    A - B5
    A * B50
    A / B2
    A % B0


    Some important points about modulus operator are as follows :

    • Modulus operator is also called remainder operator.
    • The modulus operator works only with integer values.
    • In expression like 3 % 5, 3 is not divisible by 5. Its result is 3.

    Sunday, 12 July 2015

    Circumference of Circle :


    The Formula use in 2*3.14*radius ( r ) .

    User enter radius and display circumference of cicle.


            

    Saturday, 11 July 2015

    Calculate Area of Circle :


    Formula of area of circle = 3.14*r*r

    User enter radius ( r ) and then the formula calculates area of circle. 


                    

    Keywords :


    Keyword is a word in C++ language that has a predefined meaning and purpose. Keywords are also known as reserved words. There are different types of keywords in C++ language. The total number of keywords is 63.


    List of Keywords :



    Identifier :


    The Identifiers are the names used to represent variable, constants, types, functions and labels in the program. Identifier is an important feature of all computer languages. A good identifier name should be descriptive but short.  


    An Identifier in C++ may consist of 31 characters. If the name of an identifier is longer than 31 characters, the first character will be used. The remaining characters will be ignored by C++ compiler.


     Some important rules for identifier name are as follows :
    • The first character must be an alphabetic or underscore ( _ ).
    • The identifier name must consist of only alphabetic characters, digits or underscores.
    • The reserved word cannot be used as identifier name.




    Types of Identifier :


    C++ provides the following types of identifiers :

    1. Standard Identifier :
                                           A type of identifier that has special meaning in C++ is known as standard identifier. 


    Example :

                cout and cin examples of standard identifiers.

        2.   User-defined Identifiers :


                                                             The type of identifier that is defined by the programmer
     to access memory location is known as user-defined identifiers.

    Example :

                   Some examples of user-defined identifiers are a, marks and age etc.

    Friday, 10 July 2015

    White Spaces :

                             The white spaces are used in programs to increase readability. Different types of white spaces include space, tab and carriage return etc. C++ compiler ignores the white spaces. All statements of a program can be written on one line but it will be difficult to read. The white spaces makes the source program more readable. A single statement can be written on two or more lines or order to increase readability but it will remain same for the compiler. 




    Stephen Randy Davis pdf :


    C++,khgamujtaba,programming book,C++ How to program

    Stephen Randy Davis pdf Downlaod


    Token :

                 A token is a language element that is used to form a statement.C++ statement may consist of different tokens.Different types of tokens are as follows :

    • Keywords: Keywords is a word in C language that has predefined meaning and purpose.

    Example:   For               Double             if                 const


    • Identifiers: Identifiers is the name of a variable or function etc.It is also called user-defined word.

    Example:   Student_age           counter             good20                


    • Constants: Constant is a quantity that cannot be changed during execution of a program.

    Example:   113           420               800.4             -300.5      'e'         '%'





    • String literals: A collection of characters written in double quotations is called string or string literal. 

    Example:  "This is a string constant"              "300"             "99-Mall Road."


    • Operators: Operator is a symbol that performs some operation.It acts on different operands.

    Example:     +               -                    *               /             %


    • Special Symbol: Special symbol is a symbol that is used to separate two tokens.It is also called punctuators.

    Example:        [ ]             ( )            { }           ,            ;            .               :   



    Thursday, 9 July 2015

    Microsoft Visual Studio :

    Introduction

    Microsoft Visual Studio is an integrated development environment (IDE) from Microsoft. It is used to develop computer programs for Microsoft Windows, as well as web sites, web applications and web services.




    Microsoft Visual Studio includes a code editor Visual Studio supports different programming languages and allows the code editor and debugger to support (to varying degrees) nearly any programming language, provided a language-specific service exists. Built-in languages include C, C++and C++/CLI (via Visual C++), VB.NET (via Visual Basic .NET), C# (via Visual C#), and F# (as of Visual Studio 2010). Support for other languages such as M, Python, and Ruby among others is available via language services installed separately. It also supports XML/XSLT, HTML/XHTML, JavaScript and CSS. Java (and J#) were supported in the past. (the code completion component) as well as code refactoring. The integrated debugger works both as a source-level debugger and a machine-level debugger. Other built-in tools include a forms designer for building GUI applications, web designer, class designer, and database schema designer.





    Turbo C++ For Windows :

    Introduction

    As we all know the Popular Turbo C 3 [C and C++ compiler by Borland] does not run well on 64 bit OS’s like Windows 7,Windows 8 etc,and on 32 bit OS’s they cant work fullscreen, so we have developed the emulated version of the same TurboC compiler within an environment called DosBoX which works on all OS’s Fullscreen
    normal DosBoX installations require you to download DosBox separately and then mounting the turboc directory and all which was a headache..with our installer you don’t need to mount/configure anything everything is done automatically!.. Just install and Go! you can start using TurboC as soon as you install this..! 



    Image result for turbo c++ logo



    Code Block for Windows :

    Introduction

    Code::Blocks is a free C, C++ and Fortran IDE built to meet the most demanding needs
     of its users. It is designed to be very extensible and fully configurable.
    Finally, an IDE with all the features you need, having a consistent look, feel and operation
    across platforms.
    Built around a plugin framework, Code::Blocks can be extended with plugins. Any kind of
     functionality can be added by installing/coding a plugin. For instance, compiling and
     debugging functionality is already provided by plugins.

    Code block




    Dev C++ for Windows :

    Introduction:


    Bloodshed Dev-C++ is a full-featured Integrated Development Environment (IDE) for the C/C++ programming language. It uses Mingw port of GCC (GNU Compiler Collection) as it's compiler. Dev-C++ can also be used in combination with Cygwin or any other GCC based compiler.


      Features are :

    - Support GCC-based compilers

    - Integrated debugging (using GDB)
    - Project Manager
    - Customizable syntax highlighting editor
    - Class Browser
    - Code Completion
    - Function listing
    - Profiling support
    - Quickly create Windows, console, static libraries and DLLs
    - Support of templates for creating your own project types
    - Makefile creation
    - Edit and compile Resource files
    - Tool Manager
    - Print support
    - Find and replace facilities


    Image result for dev c++



    Types of Codes :

                                     There are two types of codes that are as follows:

    1.   Source Code:

                                     A program written in a high-level language is called source code.Source code is also called source program.Computer cannot understand the statements of high-level language.It is converted into object code and then executed.

    2.   Object Code:

                                     A program in machine language is called object code.It is also called object program or machine code.Computer understands object code directly.

    Difference b/w Source Code and Object Code :


    Source Code:

    1. Source code is written in high-level or assembly language.
    2. Source code is easy to understand.
    3. Source code is easy to modify.
    4. Source code contains fewer statements than object code.

    Object Code:

    1. Object code is written in machine language.
    2. Object code is difficult to understand.
    3. Object code is difficult to modify.
    4. Object code contains more statements than source code.

    Difference b/w Compiler and Interpreter :


    Compiler :

    1. Compiler converts a program into machine code as a whole.
    2. Compiler creates object code file.
    3. Program execution is fast.
    4. Compiler displays syntax errors after compiling the whole program. 




    Interpreter :

    1. Interpreter converts a program into machine code statement by statement.
    2. Interpreter does not create object code file.
    3. Program execution is slow.
    4. Interpreter displays the syntax error on each statement of program.

    Wednesday, 8 July 2015

    Difference b/w Low-Level and High-Level Languages :

    Difference b/w Low-Level and High-Level Languages :

    Low-Level Language :

    1. Low-level languages are difficult to learn.
    2. Low-level languages are far from human languages.
    3. No translator is required.
    4. Programs in low-level languages are fast in execution.
    5. Programs in low-level languages are difficult to modify.
    6. Low-level languages provide facility to write programs at hardware level.
    7. These languages are normally used to write hardware programs.

    High-level languages :

    1. High-level languages are easy to learn.
    2. High-level languages are near to human languages.
    3. Translator is required.
    4. Programs in high-level languages are slow in execution.
    5. Programs in high-level languages are easy to modify.
    6. High-level languages do not provide much facility at hardware level.
    7. These languages are normally used to write application programs.

    Difference b/w Procedural and Non-procedural Languages :

    Difference b/w Procedural and Non-procedural Languages :

    Procedural Languages / 3GL :

    1. Procedural language tells the computer what to do and how to do.
    2. It is difficult to learn.
    3. It is difficult to debug.
    4. It requires large number of procedural instructions.
    5. It is normally used by professional programmers.
    6. It is typically file-oriented.
    7. Procedural language provides many programming capabilities.

    Non-procedural Languages / 4GL :

    1. Non-procedural language tells the computer what to do, not how to do.
    2. It is easy to learn.
    3. It is easy to debug.
    4. It requires a few number of non-procedural instructions.
    5. It can be used professional and non-technical users.
    6. It is typically database-oriented.
    7. Non-procedural language provides less programming capabilities.

    Mostly Languages Used :



    Difference b/w Flowchart and Algorithm:

    Difference b/w Flowchart and Algorithm:


    Flowchart:

    1. Standard symbols are used to design flowchart.
    2. Flowchart is more time-consuming.
    3. It is difficult to modify.
    4. It is a graphical representation of solution.



    Algorithm:

    1. Simple English is used to write algorithm.
    2. Algorithm is less time-consuming. 
    3. It is easier to modify.
    4. It is a step-by-step procedure to solve a problem.

    Example 1:

                     Algorithm of sum of  2 numbers :

    1. Start

    2. Input 1st number

    3. Input 2nd number

    4. Total = 1st number + 2nd number

    5. Display Total

    6. Exit

    Example 2:

                     Algorithm to calculate a the area of circle :
    1. Start
         2.  Input radius

         3.  area = 3.14*radius*radius

         4.  Print area

         5.  Exit