Webhosting in Pakistan
Results 1 to 4 of 4

Thread: C++ Quick Guide Class 2

  1. #1
    Join Date
    28 Apr 2015
    Location
    Sindh
    Gender
    Male
    Posts
    386
    Threads
    81
    Credits
    1,802
    Thanked
    38

    Unhappy C++ Quick Guide Class 2

    Webhosting in Pakistan
    Asslam-o-alaikum.
    Guys This Thread part of C++ Quick Guide Class 2,
    i hope u understend, if not so Reply Me.

    So Start C++ Quick Guide Class 2,

    Variable Definition & Initialization in C++:
    Some examples are:
    Code:
    extern int d, f      // declaration of d and f
    int d = 3, f = 5;    // definition and initializing d and f.
    byte z = 22;         // definition and initializes z.
    char x = 'x';        // the variable x has the value 'x'.
    C++ Variable Scope:
    A scope is a region of the program and broadly speaking there are three places where variables can be declared:

    Inside a function or a block which is called local variables,

    In the definition of function parameters which is called formal parameters.

    Outside of all functions which is called global variables.

    C++ Constants/Literals:
    Constants refer to fixed values that the program may not alter and they are called literals.

    Constants can be of any of the basic data types and can be divided in Integer Numerals, Floating-Point Numerals, Characters, Strings and Boolean Values.

    Again, constants are treated just like regular variables except that their values cannot be modified after their definition.

    C++ Modifier Types:
    C++ allows the char, int, and double data types to have modifiers preceding them. A modifier is used to alter the meaning of the base type so that it more precisely fits the needs of various situations.

    The data type modifiers are listed here:

    * signed

    * unsigned

    * long

    * short

    The modifiers signed, unsigned, long, and short can be applied to integer base types. In addition, signed and unsigned can be applied to char, and long can be applied to double.

    The modifiers signed and unsigned can also be used as prefix to long or short modifiers. For example unsigned long int.

    C++ allows a shorthand notation for declaring unsigned, short, or long integers. You can simply use the word unsigned, short, or long, without the int. The int is implied. For example, the following two statements both declare unsigned integer variables.
    Code:
    unsigned x;
    unsigned int y;
    Storage Classes in C++:

    A storage class defines the scope (visibility) and life time of variables and/or functions within a C++ Program. These specifiers precede the type that they modify. There are following storage classes which can be used in a C++ Program

    * auto

    * register

    * static

    * extern

    * mutable

    C++ Operators:
    An operator is a symbol that tells the compiler to perform specific mathematical or logical manipulations. C++ is rich in built-in operators and provides following type of operators:

    * Arithmetic Operators ( +, -, \, *, ++, --)

    * Relational Operators (==, !=, >. <, >=, <=)

    * Logical Operators (&&, ||, ! )

    * Bitwise Operators (& |, ^, ~, <<, >>)

    * Assignment Operators (=, +=, -=, *=, /=, %=, <<=, >>=, &=, ^=, |=)

    * Misc Operators ( sizeof, & cast, comma, conditional etc.)

    C++ Loop Types:
    C++ programming language provides the following types of loops to handle looping requirements. Click the following links to check their detail.

    Loop Type Description
    while loop Repeats a statement or group of statements while a given condition is true. It tests the condition before executing the loop body.
    for loop Execute a sequence of statements multiple times and abbreviates the code that manages the loop variable.
    do...while loop Like a while statement, except that it tests the condition at the end of the loop body

    C++ Decision Making:
    C++ programming language provides following types of decision making statements. Click the following links to check their detail.
    Statement Description
    if statement An if statement consists of a boolean expression followed by one or more statements.
    if...else statement An if statement can be followed by an optional else statement, which executes when the boolean expression is false.
    switch statement A switch statement allows a variable to be tested for equality against a list of values.
    nested if statements You can use one if or else if statement inside another if or else if statement(s).
    nested if statements You can use one if or else if statement inside another if or else if statement(s).
    nested switch statements You can use one swicth statement inside another switch statement(s).
    C++ Functions:
    The general form of a C++ function definition is as follows:
    Code:
    return_type function_name( parameter list )
    {
       body of the function
    }
    A C++ function definition consists of a function header and a function body. Here are all the parts of a function:

    * Return Type: A function may return a value. The return_type is the data type of the value the function returns. Some functions perform the desired operations without returning a value. In this case, the return_type is the keyword void.

    * Function Name: This is the actual name of the function. The function name and the parameter list together constitute the function signature.

    * Parameters: A parameter is like a placeholder. When a function is invoked, you pass a value to the parameter. This value is referred to as actual parameter or argument. The parameter list refers to the type, order, and number of the parameters of a function. Parameters are optional; that is, a function may contain no parameters.

    * Function Body: The function body contains a collection of statements that define what the function does.

    Numbers in C++:
    Following a simple example to show few of the mathematical operations on C++ numbers:

    Code:
    #include <iostream>
    #include <cmath>
    using namespace std;
     
    int main ()
    {
       // number definition:
       short  s = 10;
       int    i = -1000;
       long   l = 100000;
       float  f = 230.47;
       double d = 200.374;
     
       // mathematical operations;
       cout << "sin(d) :" << sin(d) << endl;
       cout << "abs(i)  :" << abs(i) << endl;
       cout << "floor(d) :" << floor(d) << endl;
       cout << "sqrt(f) :" << sqrt(f) << endl;
       cout << "pow( d, 2) :" << pow(d, 2) << endl;
     
       return 0;
    }
    C++ Arrays:
    Following is an example, which will show array declaration, assignment and accessing arrays in C++:
    Code:
    #include <iostream>
    using namespace std;
     
    #include <iomanip>
    using std::setw;
     
    int main ()
    {
       int n[ 10 ]; // n is an array of 10 integers
     
       // initialize elements of array n to 0          
       for ( int i = 0; i < 10; i++ )
       {
          n[ i ] = i + 100; // set element at location i to i + 100
       }
       cout << "Element" << setw( 13 ) << "Value" << endl;
     
       // output each array element's value                      
       for ( int j = 0; j < 10; j++ )
       {
          cout << setw( 7 )<< j << setw( 13 ) << n[ j ] << endl;
       }
     
       return 0;
    }
    C++ Strings:
    C++ provides following two types of string representations:

    The C-style character string as follows:

    Code:
    char greeting[6] = {'H', 'e', 'l', 'l', 'o', '\0'};
    The standard C++ library provides a string class type that supports all the operations mentioned above, additionally much more functionality. Following is the example:
    Code:
    #include <iostream>
    #include <string>
     
    using namespace std;
     
    int main ()
    {
       string str1 = "Hello";
       string str2 = "World";
       string str3;
     
       // copy str1 into str3
       str3 = str1;
       cout << "str3 : " << str3 << endl;
     
       // concatenates str1 and str2
       str3 = str1 + str2;
       cout << "str1 + str2 : " << str3 << endl;
      
       return 0;
    }
    Guys Wait 4 Next Class, And Don't Forget Thanks,

    Allah Hafiz,,,,,,,

    Last edited by A_Qayoom; 7th January 2016 at 07:30 PM. Reason: worng items intered

  2. #2
    Sardaaaar is offline Junior Member
    Last Online
    30th May 2016 @ 02:33 PM
    Join Date
    31 Aug 2015
    Location
    Faislabad
    Age
    25
    Gender
    Male
    Posts
    12
    Threads
    1
    Credits
    0
    Thanked
    0

    Default

    ma ny jb ye join kiya tha to mjy btaya gya tha k yahan english mian post krna mana ha to ye kya hai phr ye C++ b urdu ma kro

  3. #3
    Join Date
    28 Apr 2015
    Location
    Sindh
    Gender
    Male
    Posts
    386
    Threads
    81
    Credits
    1,802
    Thanked
    38

    Default

    Quote Sardaaaar said: View Post
    ma ny jb ye join kiya tha to mjy btaya gya tha k yahan english mian post krna mana ha to ye kya hai phr ye C++ b urdu ma kro
    Bhai Agar Main Yeh Classes urdu main post karta to,
    ap logo ko Samjh ne main Problem Hote,,
    Q K,
    Aap jab Code Writing karin gy to W Bhe Apko English Main Likhna Parre ga,

    Aur Programming languages Sekhni ke liye English Achy Honi chahiye,

  4. #4
    Join Date
    09 Apr 2009
    Location
    کر&
    Gender
    Male
    Posts
    15,393
    Threads
    244
    Credits
    19,276
    Thanked
    1705

    Default

    Webhosting in Pakistan
    بہت خوب یہ معلوماتی کلاس ہمارے ساتھ شئیر کرنے کا بہت شکریہ کافی کچھ سیکھنے کو ملا

Similar Threads

  1. C++ Quick Guide Class 1
    By A_Qayoom in forum C++
    Replies: 12
    Last Post: 22nd March 2018, 10:51 PM
  2. Replies: 28
    Last Post: 1st September 2015, 08:29 PM
  3. Replies: 2
    Last Post: 31st May 2015, 06:37 PM
  4. MaNAGEMENT take NOTICE ,Quick,very Quick ResPoNse Needed. (zoOp)
    By MUBBI_UNPREDICTABLE in forum Tajaweez aur Shikayat
    Replies: 4
    Last Post: 25th August 2009, 05:46 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •