+ Reply to Thread
Page 3 of 7 1 2 3 4 5 ...
Results 21 to 30 of 66

 

Thread: كتب c# باللغة الانجليزية

  • Thread Tools
  1. #21 Collapse post
    zied toumi is offline
    Banned Array
    Join Date
    Oct 2013
    Posts
    78
    Accrued Payments
    6 USD
    Thanks
    0
    Thanked 1 Time in 1 Post
    Console.Write("Press a key followed by ENTER: ");
    // Read a key from the keyboard.
    ch = (char) Console.Read();
    Console.WriteLine("Your key is: " + ch);
    }
    }
    Here is a sample run:
    Press a key followed by ENTER: t
    Your key is: t
    The fact that Read( ) is line-buffered is a source of annoyance at times. When you press
    ENTER, a carriage-return, linefeed sequence is entered into the input stream. Furthermore, these
    characters are left pending in the input buffer until you read them. Thus, for some applications,
    you may need to remove them (by reading them) before the next input operation. You will see
    an example of this later in this chapter.
    The if Statement
    Chapter 1 introduced the if statement. It is examined in detail here. The complete form of the
    if statement is
    if(condition) statement;
    else statement;

    Though trading on financial markets involves high risk, it can still generate extra income in case you apply the right approach. By choosing a reliable broker such as InstaForex you get access to the international financial markets and open your way towards financial independence. You can sign up here.


  2. #22 Collapse post
    ismail1992 is offline
    عضو جديد Array
    Join Date
    Aug 2012
    Posts
    77
    Accrued Payments
    3 USD
    Thanks
    0
    Thanked 0 Times in 0 Posts
    SubscribeSubscribe
    subscribed 0
    سلام عليكم ورحمة الله تعالى وبركاتة شركرا على هدا الموضوع مفيد

    Though trading on financial markets involves high risk, it can still generate extra income in case you apply the right approach. By choosing a reliable broker such as InstaForex you get access to the international financial markets and open your way towards financial independence. You can sign up here.


  3. #23 Collapse post
    zied toumi is offline
    Banned Array
    Join Date
    Oct 2013
    Posts
    78
    Accrued Payments
    6 USD
    Thanks
    0
    Thanked 1 Time in 1 Post
    where the targets of the if and else are single statements. The else clause is optional. Because
    a block of statements can be used wherever a single statement is legal, the targets of both the
    if and else can be blocks of statements. Therefore, the general form of the if using blocks of
    statements is
    if(condition)
    {
    statement sequence
    }
    else
    {
    statement sequence
    }
    If the conditional expression is true, the target of the if will be executed; otherwise, if it
    exists, the target of the else will be executed. At no time will both of them be executed. The
    conditional expression controlling the if must produce a bool result.

    ---------- Post added at 10:59 PM ---------- Previous post was at 10:58 PM ----------

    To demonstrate the if, we will evolve a simple computerized guessing game that would
    be suitable for small children. In the first version of the game, the program asks the player for
    a letter between A and Z. If the player presses the right letter on the keyboard, the program
    responds by printing the message ** Right **. The program is shown here:
    // Guess the letter game.
    using System;
    class Guess {
    static void Main() {
    char ch, answer = 'K';
    Console.WriteLine("I'm thinking of a letter between A and Z.");
    Console.Write("Can you guess it: ");
    ch = (char) Console.Read(); // get the user's guess
    if(ch == answer) Console.WriteLine("** Right **");
    }
    }

    ---------- Post added at 10:59 PM ---------- Previous post was at 10:59 PM ----------

    This program prompts the player and then reads a character from the keyboard. Using an
    if statement, it then checks that character against the answer, which is K in this case. If K was
    entered, the message is displayed. When you try this program, remember that the K must be
    entered in uppercase.
    Taking the guessing game further, the next version uses the else to print a message when
    the wrong letter is picked.
    // Guess the letter game, 2nd version.
    using System;
    class Guess2 {
    static void Main() {
    char ch, answer = 'K';
    Console.WriteLine("I'm thinking of a letter between A and Z.");
    Console.Write("Can you guess it: ");
    ch = (char) Console.Read(); // get the user's guess
    if(ch == answer) Console.WriteLine("** Right **");
    else Console.WriteLine("...Sorry, you're wrong.");
    }
    }

    ---------- Post added at 11:00 PM ---------- Previous post was at 10:59 PM ----------

    Nested ifs
    A nested if is an if statement that is the target of another if or else. Nested ifs are very common
    in programming. The main thing to remember about nested ifs in C# is that an else clause is
    always associated with the nearest if statement that is within the same block as the else and not
    already associated with an else. Here is an example:
    if(i == 10) {
    if(j < 20) a = b;
    if(k > 100) c = d;
    else a = c; // this else refers to if(k > 100)
    }
    else a = d; // this else refers to if(i == 10)
    As the comments indicate, the final else is not associated with if(j<20), because it is not in the
    same block (even though it is the nearest if without an else). Rather, the final else is associated
    with if(i==10). The inner else refers to if(k>100), because it is the closest if within the same block.
    You can use a nested if to add a further improvement to the guessing game. This addition
    provides the player with feedback about a wrong guess.
    // Guess the letter game, 3rd version.

    ---------- Post added at 11:02 PM ---------- Previous post was at 11:00 PM ----------

    using System;
    class Guess3 {
    static void Main() {
    char ch, answer = 'K';
    Console.WriteLine("I'm thinking of a letter between A and Z.");
    Console.Write("Can you guess it: ");
    ch = (char) Console.Read(); // get the user's guess
    if(ch == answer) Console.WriteLine("** Right **");
    else {
    Console.Write("...Sorry, you're ");
    // A nested if.
    if(ch < answer) Console.WriteLine("too low");
    else Console.WriteLine("too high");
    }
    }
    }
    A sample run is shown here:
    I'm thinking of a letter between A and Z.
    Can you guess it: Z
    ...Sorry, you're too high

    ---------- Post added at 11:03 PM ---------- Previous post was at 11:02 PM ----------

    The if-else-if Ladder
    A common programming construct that is based upon the nested if is the if-else-if ladder. It
    looks like this:
    if(condition)
    statement;
    else if(condition)
    statement;
    else if(condition)
    statement;
    .
    .
    .
    else
    statement;
    The conditional expressions are evaluated from the top down. As soon as a true condition is
    found, the statement associated with it is executed, and the rest of the ladder is bypassed. If
    none of the conditions are true, the final else clause will be executed. The final else often acts
    as a default condition; that is, if all other conditional tests fail, the last else clause is executed.
    If there is no final else and all other conditions are false, no action will take place.
    The following program demonstrates the if-else-if ladder:

    ---------- Post added at 11:03 PM ---------- Previous post was at 11:03 PM ----------

    // Demonstrate an if-else-if ladder.
    using System;
    class Ladder {
    static void Main() {
    int x;
    for(x=0; x<6; x++) {
    if(x==1)
    Console.WriteLine("x is one");
    else if(x==2)
    Console.WriteLine("x is two");
    else if(x==3)
    Console.WriteLine("x is three");
    else if(x==4)
    Console.WriteLine("x is four");
    else
    Console.WriteLine("x is not between 1 and 4");
    }
    }
    }

    ---------- Post added at 11:12 PM ---------- Previous post was at 11:03 PM ----------

    The program produces the following output:
    x is not between 1 and 4
    x is one
    x is two
    x is three
    x is four
    x is not between 1 and 4
    As you can see, the final else is executed only if none of the preceding if statements succeed.
    The switch Statement
    The second of C#’s selection statements is the switch. The switch provides for a multiway
    branch. Thus, it enables a program to select among several alternatives. Although a series of
    nested if statements can perform multiway tests, for many situations, the switch is a more
    efficient approach. It works like this: The value of an expression is successively tested against
    a list of constants. When a match is found, the statement sequence associated with that match
    is executed. The general form of the switch statement is
    switch(expression) {
    case constant1:
    statement sequence
    break;
    case constant2:
    statement sequence
    break;
    case constant3:
    statement sequence
    break;
    .
    .
    .
    default:
    statement sequence
    break;
    }

    ---------- Post added at 11:12 PM ---------- Previous post was at 11:12 PM ----------

    The switch expression must be an integral type, such as char, byte, short, or int; an
    enumeration type; or type string. (Enumerations and the string type are described later in
    this book.) Thus, floating-point expressions, for example, are not allowed. Frequently, the
    expression controlling the switch is simply a variable. The case constants must be of a type
    compatible with the expression. No two case constants in the same switch can have identical
    values.

    ---------- Post added at 11:16 PM ---------- Previous post was at 11:12 PM ----------

    The default sequence is executed if no case constant matches the expression. The default
    is optional; if it is not present, no action takes place if all matches fail. When a match is found,
    the statements associated with that case are executed until the break is encountered.
    The following program demonstrates the switch:
    // Demonstrate the switch.
    using System;
    class SwitchDemo {
    static void Main() {
    int i;
    for(i=0; i < 10; i++)
    switch(i) {
    case 0:
    Console.WriteLine("i is zero");
    break;
    case 1:
    Console.WriteLine("i is one");
    break;
    case 2:
    Console.WriteLine("i is two");
    break;
    case 3:
    Console.WriteLine("i is three");
    break;
    case 4:
    Console.WriteLine("i is four");
    break;
    default:
    Console.WriteLine("i is five or more");
    break;
    }
    }
    }
    The output produced by this program is shown here:
    i is zero
    i is one
    i is two
    i is three
    i is four
    i is five or more
    i is five or more
    i is five or more
    i is five or more
    i is

    ---------- Post added at 11:16 PM ---------- Previous post was at 11:16 PM ----------

    five or more
    As you can see, each time through the loop, the statements associated with the case constant
    that matches i are executed. All others are bypassed. When i is five or greater, no case
    constants match, so the statements associated with the default case are executed.
    In the preceding example, the switch was controlled by an int variable. As explained, you
    can control a switch with any integral type, including char. Here is an example that uses a
    char expression and char case constants:
    // Use a char to control the switch.
    using System;
    class SwitchDemo2 {
    static void Main() {
    char ch;
    for(ch='A'; ch <= 'E'; ch++)
    switch(ch) {
    case 'A':
    Console.WriteLine("ch is A");
    break;
    case 'B':
    Console.WriteLine("ch is B");
    break;
    case 'C':
    Console.WriteLine("ch is C");
    break;
    case 'D':
    Console.WriteLine("ch is D");
    break;
    case 'E':
    Console.WriteLine("ch is E");
    break;
    }
    }
    }

    ---------- Post added at 11:17 PM ---------- Previous post was at 11:16 PM ----------

    The output from this program is shown here:
    ch is A
    ch is B
    ch is C
    ch is D
    ch is E
    Notice that this example does not include the default case. Remember, the default is optional.
    When not needed, it can be left out.
    In C#, it is an error for the statement sequence associated with one case to continue on into
    the next case. This is called the no fall-through rule. This is why case sequences end with break.

    Though trading on financial markets involves high risk, it can still generate extra income in case you apply the right approach. By choosing a reliable broker such as InstaForex you get access to the international financial markets and open your way towards financial independence. You can sign up here.


  4. #24 Collapse post
    zied toumi is offline
    Banned Array
    Join Date
    Oct 2013
    Posts
    78
    Accrued Payments
    6 USD
    Thanks
    0
    Thanked 1 Time in 1 Post
    (You can avoid fall-through in other ways, but break is by far the most commonly used approach.)
    When encountered within the statement sequence of a case, break causes program flow to exit
    from the entire switch statement and resume at the next statement outside the switch. One other
    point: The default sequence must also not “fall through,” and it, too, usually ends with a break.
    Although you cannot allow one case sequence to fall through into another, you can have
    two or more case labels for the same code sequence, as shown in this example:
    switch(i) {
    case 1:
    case 2:
    case 3: Console.WriteLine("i is 1, 2 or 3");
    break;
    case 4: Console.WriteLine("i is 4");
    break;
    }
    In this fragment, if i has the value 1, 2, or 3, the first WriteLine( ) statement executes. If it is
    4, the second WriteLine( ) statement executes. The stacking of cases does not violate the no
    fall-through rule because the case statements all use the same statement sequence.
    Stacking case labels is a commonly employed technique when several cases share common
    code. For example, here it is used to categorize lowercase letters of the alphabet into vowels
    and consonants:
    // Categorize lowercase letters into vowels and consonants.

    ---------- Post added at 11:18 PM ---------- Previous post was at 11:17 PM ----------

    using System;
    class VowelsAndConsonants {
    static void Main() {
    char ch;
    Console.Write("Enter a letter: ");
    ch = (char) Console.Read();
    switch(ch) {
    case 'a':
    case 'e':
    case 'i':
    case 'o':
    case 'u':
    case 'y':
    Console.WriteLine("Letter is a vowel.");
    break;
    default:
    Console.WriteLine("Letter is a consonant.");
    break;
    }
    }
    }

    ---------- Post added at 11:19 PM ---------- Previous post was at 11:18 PM ----------

    Q: Under what conditions should I use an if-else-if ladder rather than a switch when
    coding a multiway branch?
    A: In general, use an if-else-if ladder when the conditions controlling the selection process do
    not rely upon a single value. For example, consider the following if-else-if sequence:
    if(x == 10) // ...
    else if(ch == 'a') // ...
    else if(done == true) // ...
    This sequence cannot be recoded into a switch because all three conditions involve
    different variables—and differing types. What variable would control the switch? Also,
    you will need to use an if-else-if ladder when testing floating-point values or when testing
    other objects that are not of types valid for use in a switch expression. Finally, the switch
    can only test for equality. If you will be testing for some other relationship, such as less
    than or not equal, you must use an if-else-if ladder. For example,
    if(x < 10) // ...
    else if(y >= 0) // ...
    else if(z != -1) // ...
    This sequence cannot be represented in a switch.

    ---------- Post added at 11:19 PM ---------- Previous post was at 11:19 PM ----------

    If this example were written without case stacking, the same WriteLine( ) statement would
    have been duplicated six times. The stacking of cases prevents this redundant duplication.
    Nested switch Statements
    It is possible to have a switch as part of the statement sequence of an outer switch. This is
    called a nested switch. The case constants of the inner and outer switch can contain common
    values, and no conflicts will arise. For example, the following code fragment is perfectly
    acceptable:
    switch(ch1) {
    case 'A': Console.WriteLine("This A is part of outer switch.");
    switch(ch2) {
    case 'A':
    Console.WriteLine("This A is part of inner switch");
    break;
    case 'B': // ...
    } // end of inner switch
    break;
    case 'B': // ...

    ---------- Post added at 11:20 PM ---------- Previous post was at 11:19 PM ----------

    Q: In C, C++, and Java, one case may continue on (that is, fall through) into the next case.
    Why is this not allowed by C#?
    A: There are two reasons that C# instituted the no fall-through rule for cases. First, it allows
    the order of the cases to be rearranged. Such a rearrangement would not be possible if one
    case could flow into the next. Second, requiring each case to explicitly end prevents
    a programmer from accidentally allowing one case to flow into the next.

    ---------- Post added at 11:20 PM ---------- Previous post was at 11:20 PM ----------

    Start Building a C# Help System
    Here you will start building a simple help system that displays the syntax for the C# control
    statements. This help system will be enhanced throughout the course of this chapter. This first
    version displays a menu containing the control statements and then waits for you to choose
    one. After one is chosen, the syntax of the statement is shown. In this first version of the
    program, help is available only for the if and switch statements. The other control statements
    are added later in subsequent Try This sections.
    Step by Step
    1. Create a file called Help.cs.
    2. The program begins by displaying the following menu:
    Help on:
    1. if
    2. switch
    Choose one:
    To accomplish this, you will use the statement sequence shown here:
    Console.WriteLine("Help on:");
    Console.WriteLine(" 1. if");
    Console.WriteLine(" 2. switch");
    Console.Write("Choose one: ");
    3. The program obtains the user’s selection by calling Console.Read( ), as shown here:
    choice = (char) Console.Read();
    4. Once the selection has been obtained, the program uses the switch statement shown here to
    display the syntax for the selected statement:
    switch(choice) {
    case '1':
    Console.WriteLine("The if:\n");

    ---------- Post added at 11:21 PM ---------- Previous post was at 11:20 PM ----------

    Console.WriteLine("if(condition) statement;");
    Console.WriteLine("else statement;");
    break;
    case '2':
    Console.WriteLine("The switch:\n");
    Console.WriteLine("switch(expression) {");
    Console.WriteLine(" case constant:");
    Console.WriteLine(" statement sequence");
    Console.WriteLine(" break;");
    Console.WriteLine(" // ...");
    Console.WriteLine("}");
    break;
    default:
    Console.Write("Selection not found.");
    break;
    }
    Notice how the default clause catches invalid choices. For example, if the user enters 3,
    no case constants will match, causing the default sequence to execute.

    ---------- Post added at 11:21 PM ---------- Previous post was at 11:21 PM ----------

    5. Here is the entire Help.cs program listing:
    // A simple help system.
    using System;
    class Help {
    static void Main() {
    char choice;
    Console.WriteLine("Help on:");
    Console.WriteLine(" 1. if");
    Console.WriteLine(" 2. switch");
    Console.Write("Choose one: ");
    choice = (char) Console.Read();
    Console.WriteLine("\n");
    switch(choice) {
    case '1':
    Console.WriteLine("The if:\n");
    Console.WriteLine("if(condition) statement;");
    Console.WriteLine("else statement;");
    break;
    case '2':
    Console.WriteLine("The switch:\n");
    Console.WriteLine("switch(expression) {");
    Console.WriteLine(" case constant:");
    Console.WriteLine(" statement sequence");

    ---------- Post added at 11:22 PM ---------- Previous post was at 11:21 PM ----------

    Console.WriteLine(" break;");
    Console.WriteLine(" // ...");
    Console.WriteLine("}");
    break;
    default:
    Console.Write("Selection not found.");
    break;
    }
    }
    }
    Here is a sample run:
    Help on:
    1. if
    2. switch
    Choose one: 1
    The if:
    if(condition) statement;
    else statement;

    ---------- Post added at 11:22 PM ---------- Previous post was at 11:22 PM ----------

    The for Loop
    You have been using a simple form of the for loop since Chapter 1. You might be surprised
    at just how powerful and flexible the for loop is. Let’s begin by reviewing the basics, starting
    with the most traditional forms of the for.
    The general form of the for loop for repeating a single statement is
    for(initialization; condition; iteration) statement;
    For repeating a block, the general form is
    for(initialization; condition; iteration)
    {
    statement sequence
    }
    The initialization is usually an assignment statement that sets the initial value of the loop
    control variable, which acts as the counter that controls the loop. The condition is a Boolean
    expression that determines whether the loop will repeat. The iteration expression defines the
    amount by which the loop control variable will change each time the loop is repeated. Notice
    that these three major sections of the loop must be separated by semicolons. The for loop will
    continue to execute as long as the condition tests true. Once the condition becomes false, the
    loop will exit, and program execution will resume on the statement following the for.

    ---------- Post added at 11:23 PM ---------- Previous post was at 11:22 PM ----------

    The following program uses a for loop to print the square roots of the numbers between
    1 and 99. It also displays the rounding error present for each square root.
    // Show square roots of 1 to 99 and the rounding error.
    using System;
    class SqrRoot {
    static void Main() {
    double num, sroot, rerr;
    for(num = 1.0; num < 100.0; num++) {
    sroot = Math.Sqrt(num);
    Console.WriteLine("Square root of " + num +
    " is " + sroot);
    // Compute rounding error.
    rerr = num - (sroot * sroot);
    Console.WriteLine("Rounding error is " + rerr);
    Console.WriteLine();
    }
    }
    }

    Though trading on financial markets involves high risk, it can still generate extra income in case you apply the right approach. By choosing a reliable broker such as InstaForex you get access to the international financial markets and open your way towards financial independence. You can sign up here.


  5. #25 Collapse post
    zied toumi is offline
    Banned Array
    Join Date
    Oct 2013
    Posts
    78
    Accrued Payments
    6 USD
    Thanks
    0
    Thanked 1 Time in 1 Post
    Notice that the rounding error is computed by squaring the square root of each number.
    This result is then subtracted from the original number, thus yielding the rounding error. Of
    course, in some cases, rounding errors occur when the square root is squared, so sometimes
    the rounding error, itself, is rounded! This example illustrates the fact that floating-point
    calculations are not always as precise as we sometimes think they should be!
    The for loop can proceed in a positive or negative fashion, and it can change the loop
    control variable by any amount. For example, the following loop prints the numbers 100 to
    –100, in decrements of 5:
    // A negatively running for loop.
    for(x = 100; x > -100; x -= 5)
    Console.WriteLine(x);
    }
    An important point about for loops is that the conditional expression is always tested at
    the top of the loop. This means that the code inside the loop may not be executed at all if the
    condition is false to begin with. Here is an example:
    for(count=10; count < 5; count++)
    x += count; // this statement will not execute
    This loop will never execute because its control variable, count, is greater than five when the
    loop is first entered. This makes the conditional expression, count<5, false from the outset;
    thus, not even one iteration of the loop will occur.

    ---------- Post added at 11:24 PM ---------- Previous post was at 11:23 PM ----------

    Some Variations on the for Loop
    The for is one of the most versatile statements in the C# language because it allows a wide
    range of variations. For example, multiple loop control variables can be used. Consider the
    following program:
    // Use commas in a for statement.
    using System;
    class Comma {
    static void Main() {
    int i, j;
    for(i=0, j=10; i < j; i++, j--)
    Console.WriteLine("i and j: " + i + " " + j);
    }
    }
    The output from the program is shown here:
    i and j: 0 10
    i and j: 1 9
    i and j: 2 8
    i and j: 3 7
    i and j: 4 6
    Here, commas separate the two initialization statements and the two iteration expressions.
    When the loop begins, both i and j are initialized. Each time the loop repeats, i is incremented
    and j is decremented. Multiple loop control variables are often convenient and can simplify
    certain algorithms. You can have any number of initialization and iteration statements, but in
    practice, more than two make the for loop unwieldy.
    The condition controlling the loop can be any valid expression that produces a bool result.
    It does not need to involve the loop control variable. In the next example, the loop continues to
    execute until the user types S at the keyboard.
    // Loop until an S is typed.

    ---------- Post added at 11:25 PM ---------- Previous post was at 11:24 PM ----------

    using System;
    class ForTest {
    static void Main() {
    int i;
    Console.WriteLine("Press S to stop.");
    for(i = 0; (char) Console.Read() != 'S'; i++)
    Console.WriteLine("Pass #" + i);
    }
    }

    ---------- Post added at 11:25 PM ---------- Previous post was at 11:25 PM ----------

    using System;
    class ForTest {
    static void Main() {
    int i;
    Console.WriteLine("Press S to stop.");
    for(i = 0; (char) Console.Read() != 'S'; i++)
    Console.WriteLine("Pass #" + i);
    }
    }

    ---------- Post added at 11:26 PM ---------- Previous post was at 11:25 PM ----------

    In the next example, the initialization portion is also moved out of the for.
    // Move more out of the for loop.
    using System;
    class Empty2 {
    static void Main() {
    int i;
    i = 0; // move initialization out of loop
    for(; i < 10; ) {

    ---------- Post added at 11:26 PM ---------- Previous post was at 11:26 PM ----------

    Console.WriteLine("Pass #" + i);
    i++; // increment loop control var
    }
    }
    }
    In this version, i is initialized before the loop begins, rather than as part of the for. Normally,
    you will want to initialize the loop control variable inside the for. Placing the initialization
    outside of the loop is generally done only when the initial value is derived through a complex
    process that does not lend itself to containment inside the for statement.
    The Infinite Loop
    You can create an infinite loop (a loop that never terminates) using the for by leaving the
    conditional expression empty. For example, the following fragment shows the way many C#
    programmers create an infinite loop:
    for(; // intentionally infinite loop
    {
    //...
    }
    This loop will run forever. Although there are some programming tasks that require an infinite
    loop, such as operating-system command processors, most “infinite loops” are really just
    loops with special termination requirements. Near the end of this chapter you will see how to
    halt a loop of this type. (Hint: It’s done using the break statement.)
    Loops with No Body
    In C#, the body associated with a for loop (or any other loop) can be empty. This is because

    ---------- Post added at 11:27 PM ---------- Previous post was at 11:26 PM ----------

    an empty statement is syntactically valid. Body-less loops are often useful. For example, the
    following program uses one to sum the numbers 1 through 5:
    // The body of a loop can be empty.
    using System;
    class Empty3 {
    static void Main() {
    int i;
    int sum = 0;
    // Sum the numbers through 5.
    for(i = 1; i <= 5; sum += i++) ;
    Console.WriteLine("Sum is " + sum);
    }
    }

    Though trading on financial markets involves high risk, it can still generate extra income in case you apply the right approach. By choosing a reliable broker such as InstaForex you get access to the international financial markets and open your way towards financial independence. You can sign up here.


  6. #26 Collapse post
    AshrafQassim is offline
    Banned Array
    Join Date
    Sep 2013
    Location
    مصر الحبيبة
    Posts
    788
    Accrued Payments
    73 USD
    Thanks
    0
    Thanked 3 Times in 3 Posts
    السلام عليكم اخوتى ف الله
    انا باعتقد ان المبتدالابد من قراءة كتب باللغة العربية
    شكرا

    Though trading on financial markets involves high risk, it can still generate extra income in case you apply the right approach. By choosing a reliable broker such as InstaForex you get access to the international financial markets and open your way towards financial independence. You can sign up here.


  7. #27 Collapse post
    zied tarhouni is offline
    Banned Array
    Join Date
    Oct 2013
    Location
    تونس
    Posts
    216
    Accrued Payments
    17 USD
    Thanks
    0
    Thanked 0 Times in 0 Posts
    السلام عليكم انا عندي 10دولار لكن فحسابي في انستا فوركس في غرفة العميل الخاصة مكتوب ان حساب لم يتفعل نو فيريفي لازم سورة نسخة من جواز سفر ?

    Though trading on financial markets involves high risk, it can still generate extra income in case you apply the right approach. By choosing a reliable broker such as InstaForex you get access to the international financial markets and open your way towards financial independence. You can sign up here.


  8. #28 Collapse post
    taqi is offline
    عضو جديد Array
    Join Date
    Oct 2013
    Location
    العراق
    Posts
    36
    Accrued Payments
    2 USD
    Thanks
    0
    Thanked 0 Times in 0 Posts
    SubscribeSubscribe
    subscribed 0
    بسم‏ ‏الله‏ ‏الرحمن‏ ‏الرحيم‏ ‏عاشت‏ ‏ايدك‏ ‏اخي‏ ‏العزيز‏ ‏استمر‏ ‏في‏ ‏مواضيعك‏ ‏الرائعة‏ ‏و‏ ‏لا‏ ‏تحرمنا‏ ‏من‏ ‏ابداعك‏ ‏في‏ ‏امان‏ ‏الله

    Though trading on financial markets involves high risk, it can still generate extra income in case you apply the right approach. By choosing a reliable broker such as InstaForex you get access to the international financial markets and open your way towards financial independence. You can sign up here.


  9. #29 Collapse post
    mkacha50055 is offline
    عضو نشيط Array
    Join Date
    Oct 2013
    Posts
    287
    Accrued Payments
    28 USD
    Thanks
    0
    Thanked 0 Times in 0 Posts
    SubscribeSubscribe
    subscribed 0
    السلام عليكم و مشكور على الموضوع
    لكن نحتاج في المنتدى الى مواضيع جديدة ليستفيد منها الجميع
    و ليست مواضيع ماخوذة من منتديات اخرى
    بالتوفيق للجميع . و السلام عليكم و رحمة الله

    Though trading on financial markets involves high risk, it can still generate extra income in case you apply the right approach. By choosing a reliable broker such as InstaForex you get access to the international financial markets and open your way towards financial independence. You can sign up here.


  10. #30 Collapse post
    zied toumi is offline
    Banned Array
    Join Date
    Oct 2013
    Posts
    78
    Accrued Payments
    6 USD
    Thanks
    0
    Thanked 1 Time in 1 Post
    The output from the program is shown here:
    Sum is 15
    Notice that the summation process is handled entirely within the for statement and no body is
    needed. *** special attention to the iteration expression:
    sum += i++
    Don’t be intimidated by statements like this. They are common in professionally written C#
    programs and are easy to understand if you break them down into their parts. In words, this
    statement says “add to sum the value of sum plus i, then increment i.” Thus, it is the same as
    this sequence of statements:
    sum = sum + i;
    i++;
    Declaring Loop Control Variables Inside the for Loop
    Often, the variable that controls a for loop is needed only for the purposes of the loop and
    is not used elsewhere. When this is the case, it is possible to declare the variable inside the
    initialization portion of the for. For example, the following program computes both the
    summation and the factorial of the numbers 1 through 5. It declares its loop control variable i
    inside the for:

    ---------- Post added at 06:48 PM ---------- Previous post was at 06:47 PM ----------

    // Declare loop control variable inside the for.
    using System;
    class ForVar {
    static void Main() {
    int sum = 0;
    int fact = 1;
    // Compute the factorial of the numbers through 5.
    for(int i = 1; i <= 5; i++) {
    sum += i; // i is known throughout the loop
    fact *= i;
    }
    // Here, i is not known.
    Console.WriteLine("Sum is " + sum);
    Console.WriteLine("Factorial is " + fact);
    }
    }
    When you declare a variable inside a for loop, there is one important point to remember:
    The scope of that variable ends when the for statement does. (That is, the scope of the variable
    is limited to the for loop.) Outside the for loop, the variable will cease to exist. Thus, in the

    ---------- Post added at 06:49 PM ---------- Previous post was at 06:48 PM ----------

    preceding example, i is not accessible outside the for loop. If you need to use the loop control
    variable elsewhere in your program, you will not be able to declare it inside the for loop.
    Before moving on, you might want to experiment with your own variations on the for
    loop. As you will find, it is a fascinating loop.
    The while Loop
    Another of C#’s loops is the while. The general form of the while loop is
    while(condition) statement;
    where statement can be a single statement or a block of statements, and condition defines the
    condition that controls the loop and may be any valid Boolean expression. The statement is
    performed while the condition is true. When the condition becomes false, program control
    passes to the line immediately following the loop.
    Here is a simple example in which a while is used to print the alphabet:
    // Demonstrate the while loop.

    ---------- Post added at 06:49 PM ---------- Previous post was at 06:49 PM ----------

    using System;
    class WhileDemo {
    static void Main() {
    char ch;
    // Print the alphabet using a while loop.
    ch = 'a';
    while(ch <= 'z') {
    Console.Write(ch);
    ch++;
    }
    }
    }
    Here, ch is initialized to the letter a. Each time through the loop, ch is output and then
    incremented. This process continues until ch is greater than z.
    As with the for loop, the while checks the conditional expression at the top of the loop,
    which means that the loop code may not execute at all. This often eliminates the need for
    performing a separate test before the loop. The following program illustrates this characteristic
    of the while loop. It computes the integer powers of 2 from 0 to 9.
    // Compute integer powers of 2.
    using System;
    class Power {
    static void Main() {

    ---------- Post added at 06:50 PM ---------- Previous post was at 06:49 PM ----------

    int e;
    int result;
    for(int i=0; i < 10; i++) {
    result = 1;
    e = i;
    while(e > 0) {
    result *= 2;
    e--;
    }
    Console.WriteLine("2 to the " + i +
    " power is " + result);
    }
    }
    }
    The output from the program is shown here:
    2 to the 0 power is 1
    2 to the 1 power is 2
    2 to the 2 power is 4
    2 to the 3 power is 8
    2 to the 4 power is 16
    2 to the 5 power is 32
    2 to the 6 power is 64
    2 to the 7 power is 128
    2 to the 8 power is 256
    2 to the 9 power is 512
    Notice that the while loop executes only when e is greater than 0. Thus, when e is zero, as it is
    in the first iteration of the for loop, the while loop is skipped.

    ---------- Post added at 06:50 PM ---------- Previous post was at 06:50 PM ----------

    Q: Given the flexibility inherent in all of C#’s loops, what criteria should I use when
    selecting a loop? That is, how do I choose the right loop for a specific job?
    A: Use a for loop when performing a known number of iterations. Use the do-while when you
    need a loop that will always perform at least one iteration. The while is best used when the
    loop will repeat an unknown number of times.

    Though trading on financial markets involves high risk, it can still generate extra income in case you apply the right approach. By choosing a reliable broker such as InstaForex you get access to the international financial markets and open your way towards financial independence. You can sign up here.


+ Reply to Thread
Page 3 of 7 1 2 3 4 5 ...

Subscribe to this Thread (2)

Tags for this Thread

Posting Permissions

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

Threads

Posts

Members