Give the syntax switch statement, Computer Engineering

Assignment Help:

Give the syntax  switch statements

Consider the following example. This is a function which converts an integer into a vague description. It is useful where we are only concerned in measuring a quantity when it is quite small.

estimate(number)

int number;

/* Estimate a number as none, one, two, several, many */

{      switch(number) {

case 0 : printf("None\n"); break;

case 1 : printf("One\n"); break;

case 2 : printf("Two\n"); break;

case 3 : case 4 : case 5 :

printf("Several\n");

break;

default :

printf("Many\n");

break;

}

}

Each interesting case is listed with a corresponding action. The break statement prevents any further statements from being executed by leaving the switch. Since case 3 and case 4 have no following break, they continue on allowing the same action for several values of number.

Both if and switch constructs allow the programmer to make a selection from a number ofpossible actions.

 


Related Discussions:- Give the syntax switch statement

Find farthest distance from exchange where subscriber locate, An exchange u...

An exchange uses a -40 V battery to drive subscriber lines. A resistance of 250 ohms is placed in series with the battery to protect it from short circuits. The subscribers are req

Subscript and an index in a table definition, What is the difference betwee...

What is the difference between a subscript and an index in a table definition? Ans) A subscript is a working storage data definition item, typically a PIC (999) where a value mu

Explain the disadvantages off-the-shelf, Explain the disadvantages Off-the...

Explain the disadvantages Off-the-shelf -  can be over-complex since it tries to cover as many characteristics as possible (for example most users of Word only utilise about

Can we call reports from interactive reporting lists, Can we call reports ...

Can we call reports and transactions from interactive reporting lists? Yes.  It also permits you to call transactions or other reports from lists.  These programs then use val

What is managed bean or mbean, A managed bean - sometimes simply referred t...

A managed bean - sometimes simply referred to as an MBean - is a type of JavaBean, developed with dependency injection. Managed Beans are particularly used in the Java Management E

Explain fundamental models of inter process communication, Explain the two ...

Explain the two fundamental models of inter process communication. Two kinds of message passing system are given as: (a) Direct Communication : Along with direct communicat

Algorithm and pseudocodes, develop an algorithm using pseudocode for comput...

develop an algorithm using pseudocode for computing cos(x) and sin(x). use a sentinel controlled while loop. use the series definition of e^+-jx

Explain the matlab language, This is a high-level matrix/array language wit...

This is a high-level matrix/array language with control flow statements, functions, data structures, input/output, and object-oriented programming features. It permits both "progra

Standards used for development of a system, Q. Standards used for developme...

Q. Standards used for development of a system? Documentation standards: It must be an ongoing activity at the time of system development life cycle.  Quality Standards:

Compare the memory devices ram and rom, Compare the memory devices RAM and ...

Compare the memory devices RAM and ROM. Ans. Comparison of Semi-conductor Memories RAM ands ROM The advantages of ROM are: 1. This is cheaper than RAM. 2. This is non-volatil

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd