Wednesday, November 15, 2017

C++ programming language part: 01 Programming Language

 Programming Language

Hi Think you’re ready to became a Boss of your PC
So, Share the time with your faculty
and run C++ & write the following program

//My first program
#include
void main()
{
     cout<<"Hello, I'm Ludmina. This is my first progran ";
}
Result : What happened? We will discuss details a little latter. Let us have a close look as follows.

Hello from Nova System,
Think you really sure that computer just knows some binary calculation and nothing else. Think a little bit about HTML, whenever you write  “”, the color of the screen turns blue. So, your PC could understand your words means your language.

Cause, Something works as an interpreter between you and your PC. That is a software, made by any computer language. You know it also that software is a group of instruction for computer.
Imagine you are working with MS word. Microsoft has coded all the instructions of it. Is it possible to think that all instructions are coded by binary digit (Like 0110001)? Must something interprets the normal instruction to machine Instruction automatically. Programmers of Microsoft coded the instructions with a normal language interface and the binary code has generated by the computer Language.

Computer Engineers had coded the instruction of Computer Languages. Software engineers had coded the instruction for software by Computer languages.

Working Process: Language works in three processes.
 











C++ programming language part: 02 Compiler

Compiler: Compiler is the main part of computer language. Its interprets all instructions to machine Code for individual use. Usually we understand English, French etc The normal language. The computers only understand a language of electronic signal, called machine language. Software called the compiler converts the computer language to machine language. For example, There is a C compiler that converts programs in the C language to machine language.

Classifications of Language: Basically two types of computer language we use.
Low Level Language: Instruction of this language is like (+/-), (n/y), or binary instructions. Its very hard to write a program and not comfortable at all. Assembly language  is a low level language.

High Level Language: - Its user friendly. You can easily run your  Program to all computers without changing its instruction. It does provide a friendly interface and language like English. Fortran, Pascal, Cobol, C, BASIC are called high level language.

Code: Instruction of program is called “CODE” in Programming Language.


Source and Object Code: The Instruction before compiling is called Source Code. It does need to take the help of Compiler to run for each time. And the instruction after compiling is called object code. It does need to take the help of Compiler to run.

C++ programming language part: 03 Programming Logic

Programming Logic

A set of instruction to solve a problem is termed as an algorithm. Algorithms can be express in different ways, for example, by drawing flowcharts using specific symbols or writing the solution in simple English. The later is called pseudocode easy to understand.
Program no 1

// This is the first program
{
display “Hello”;
display “Nova”;
}
Output: Hello Nova

Exercise: Write a program to display your name.

C++ programming language part: 04 Data Type

Data Type

Data:  Main task of a program to deal with data. There are two kinds of data
Constants: It refers to fixed values that may not be altered by the program. Constants are Two type, one is Alphanumeric and the other is numeric.
Alphanumeric constants: It cannot be used for arithmetic calculation. A set of characters is called a String.
Numeric constants:  These are two types. Integer what is Whole number and Float what is numbers with decimals.
Variable: String and numeric values can be stored in memory for subsequent use, then number can be called variable. Its are two type as constant.

Declaring Variable
The usual way to declare variable is: {data type} {name of variable}
suppose: char name or int quantity salary or float pric

Assigning Values: It can be done by two ways
suppose: float price=50.25 or
                           float price;
                           price=50.25
consider the program no 2.

Let us have a look at the following example accepts a name from the user and display the name.

//Program number 2
NAME ACCEPT & DISPLAY
{
char name;
display “Type your name”; // pseudocode
accept name;
display “Hello”;
display “ name”
}
Result: Hello name

Exercise: Write a program to accept & display Name, Quantity and Price.

Monday, November 13, 2017

C++ programming language part: 05 Programming in C++

Programming in C++

C++ is the most popular, known high level language which can provide the advantages of low level language. It was originally developed in 1971s by Dennis Ritchie at Bill Lab, inc. In 1980s it was developed by Bjarne Stroustrup at AT&T Bell Lab. The standard  was finally adopted in 1990 by Turbo.   Its used to solve the most difficult problem like: - hardware programming, OS Design etc. It’s also used to create different kinds off application software. C++ is called as mother language of languages.



Structure of a C++ Program: Type the following program taking a new page.


Program 1
                        // hi C++ ( Program Name)
                        // This program is to print a name
                        #include
                        void main()
                        {
                        cout<<”This is Nova System”;  // massage to display
                        }

Comments //    :- used to write something in program as comments. It does not affect on
     program  & helps to understand letter.
    Example: - // This program is to print a name

#include   :- used to use built library function included with C++ and details data
       of cout<<”” is built in this library
       Example: -#include
function Main()  :- used to start C++ program. A function body is surrounded by Curly
         braces({}). Every function must have a pair of braces.
        Example:- void main ()
Delimiters { }     :- this bracket contain function’s statement. At our program it’s used to contain    
      statement of main() command.
     Example: {--------}
Keywords cout<<    :-statement used to show any message.
                                    Example: cout<<”This is Nova System”

Sentence Terminator ;   :- it is use to end a statement.

                                           Example: ”This is Nova System”;

C++ programming language part: 06 Data Type

Data Type:- C++ supports the several data type. To use any data in computer we need to specify the memory area for each the Data. To specify data area we need to know the data type.



Use of (int) Integer Variable: - Integer variables are used to store whole number.

Program 2        // use of Integer type data
                        #include
                        void main()
                        int x; // integer defined x.
                        int y=5, z; // integer defined and assigned  x value 5 y & z.
                        x=4;
                        z=6;
                        cout<<”The value of x is”<//print the value of x.
                        cout<<”The value of y is”<<; //print the value of y.
                        cout<<”The value of z is”<//print the value of z.
                        }


Output of program:
                        The value of x is 4
                        The value of y is 5
                        The value of z is 6



Use of (char) Character Variable: - Character variables are used to store character constants like ‘A’, ‘m’ and so on. These are enclosed within single quotes.

Program 3       

//use of character variable (usechar.c)
                        #include
                        void main()
                        {
                        char x,y;
                        x=’A’;
                        y=’B’;
                       
                        cout<<”The value of x is”<
cout<<”The value of y is”<
                        }
 

Output of program:
                        The value of x is A
                        The value of y is B
Note: To get space we can use char C=’ ‘; or direct type <<” “;
Exercise 1 : Write your full name with space using character variable & another two programs.


Defining String
To store more than one character, a string has to be defined. mind it, Last value is used to store NULL character (string terminator [\0]) These are enclosed within double quotes
Program_4

                                    //demonstrates string variable (usestr.c)
                                    #include
                                    void main()
                                    {
                                    char x[10]=”LUDMINA”;
                                    cout<<”Hellow! I am “<
                                    }

Output of program:
                                    Hellow! I am LUDMINA


Use of (float) Float Variable: - Float variable is used to store floating point number.
Program_5
                        // use of float variable (usefloat.c)
                        #include
                       
void main()
                        {
float x1=10.50; // float and its variable defined together.
float x2; // float defined
                        x3=12.30; //defined variable
                        cout<<”The value of x1 is”<
                        }
 

Output of program:
                        The value of x1 is 10.5  and The value of x2 is 12.3

Take a close look:- By (cout) two group character and variable printed at a time. (Ask your Faculty).


All variable together with endl
Program_6.1
// use of Integer type data
                        #include
                        void main()
                        {
                        int x; // integer defined x.
                        float y; // float  defined y.
                        char z; // character defined z
                        char p[10]="LUDMINA"; // string defined
                        x=4;
                        y=6.5;
                        z='A';
                   

                        cout<<"The value of x is "<
                        cout<<"The value of y is "<
                        cout<<"The value of z is "<
                        cout<<"Hello! I am "<
                        }

Program_6_2
// use of Integer type data
                        #include
                        #include      // for getch() function
void main()
                        {
                        int x; // integer defined x.
                        float y; // float  defined y.
                        char z; // character defined z
                        char p[10]="LUDMINA"; // string defined
                        x=4;
                        y=6.5;
                        z='A';
                   
                        cout<<"The value of x is "<
                        cout<<"The value of y is "<
                        cout<<"The value of z is "<
                        cout<<"Hello! I am "<
                        getch();

                        }

C++ programming language part: 07 Get Input from keyboard

Get Input from keyboard

Input Using cin

Program 7.1
//(cininput.c)
#include
#include
void main()
{
char p[10];
cout<< "What is your name, Please? ";
cin>>p;
cout<<"Hello! "<
getch();
}
                                                                       

Ask your Faculty for result
Program 7_2
//(cininput.c)
#include
#include
void main()

{
char x[10];
int p;
cout<< "What is your name, Please? ";
cin>>x;
cout<< " How old are you, Please? “;
cin>>p;

cout<<"Hello! "<
getch();
}


Ask your Faculty for result

C++ programming language part:08 Operators

Operators



Arithmetic Operation

There are seven arithmetic operators in C++.



The modulo operator returns the reminder when another divides an integer. 
Program_8
// modulo operator reminder (modulor.c)
                                    #include
                                    #include
                                    void main()
                                    {
                                    int p1=11, p2=5,p,q,r,s,t;
                                    p=p1%p2;
                                    q= p1+p2;
                                    r= p1-p2;
                                    s= p1*p2;
t= p1/p2;
                                    cout<<"The Reminder is "<
                                    cout<<"The Addition is "<
                                    cout<<"The Subtraction is "<
                                    cout<<"The Multiplication is "<
                                    cout<<"The Division is "<
                                    cout<<”The p1+5= “<
                                    getch();
                                    }

Exercise_3: 1) Write the above program using input from keyboard (cin)
2) Write the following program and compile it
Program:-
·         10+10=a
·         a-2=b
·         b*4=c

·         c/2=d