Ask Question
16 November, 12:04

What are the purpose of each in c++?

if statements?

switch statements?

multiway if?

nested loops?

rand?

srand?

seed?

+3
Answers (1)
  1. 16 November, 12:14
    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?
Find 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 the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers