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

Sql injection, SQL Injection includes entering SQL code into web forms, eg....

SQL Injection includes entering SQL code into web forms, eg. login fields, or into the browser address field, to access and manipulate the database across the site, application or

Differentiate between static and dynamic step loops, Differentiate between ...

Differentiate between static and dynamic step loops. Step loops fall into two classes: Static and Dynamic.  Static step loops have a fixed size that cannot be changed at runti

Arithmetic-logic section in computer system, Arithmetic-logic section in co...

Arithmetic-logic section in computer system: The   arithmetic-logic section performs arithmetic   operations, such subtraction, addition, multiplication, and division. Throug

The maximum number of dimensions an array can have in c, The maximum number...

The maximum number of dimensions an array can have in C is C permits arrays of three or more dimensions. The exact limit is examined by the compiler.

Database management system, what would be the occupancy of each leaf node o...

what would be the occupancy of each leaf node of a B+ tree

What are the elements of analysis model, What are the elements of Analysis ...

What are the elements of Analysis model? i. Data Dictionary ii. Entity Relationship Diagram iii. Data Flow Diagram iv. State Transition Diagram v. Control Specifica

Recent parallel programming models, A model for parallel programming is an ...

A model for parallel programming is an abstraction and is machine architecture independent. A model can be executed on several hardware and memory architectures. There are various

Illustrate internal organisation of ram, Q. Illustrate Internal Organisatio...

Q. Illustrate Internal Organisation of RAM? The construction displayed in Figure below is made up of one JK flip-flop and 3 AND gates. The two inputs to system are one input bi

What are the advantages and disadvantages of a smart card, What are the adv...

What are the advantages and disadvantages of a Smart Card?    Advantages of Smart Card: 1. It gives convenience & support for multiple currencies over borders. 2. Used

Trusted publisher, State the criteria which a trusted publisher should meet...

State the criteria which a trusted publisher should meet before adding him? Ans) The following criteria should be met by the publisher before adding him to the list. ? The

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