Ask Question
22 July, 15:55

What are the purpose of each in c++?

if statements?

switch statements?

multiway if?

nested loops?

rand?

srand?

seed?

+1
Answers (1)
  1. 22 July, 19:31
    0
    If statements - This statement is used to check the condition.

    if (condition)

    {

    statement

    }

    If the condition is true, then statement will run, else not.

    Switch statement-This statement is used for long conditions. It is a substitute for if, else conditions

    switch (a)

    {

    case1: statement 1//if a=1

    break;

    case2: statement 2 / /if a=2

    break;

    ...

    default:statement//if a is not equal to any of the cases.

    Multiway if-In this statement, if elseif and else were there.

    if (condition1)

    {

    statement 1

    }

    elseif (condition2)

    {

    statement 2

    }

    ...

    else

    {

    statement n

    }

    Nested loops-This statements are used when we use if-else conditions in other if, else conditions.

    if (condition 1)

    {

    if (condition 2)

    {

    if (condition 3)

    {

    statement 3

    }

    else

    {

    statement 4

    }

    }

    ]

    rand () - This method is used for generating random number. The expression is

    number=rand () %50;

    It will generate a random number ranges between 0 to 50.

    srand () - This method is used to set the starting value for random number series.

    srand (time (NULL));

    seed () - It is a method for initializing the same random series, it is passed in srand ().
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “What are the purpose of each in c++? if statements? switch statements? multiway if? nested loops? rand? srand? seed? ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers