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

How is recursion handled internally, How is recursion handled internally? ...

How is recursion handled internally? Internally, every recursive call to a function requires storing the intermediate values of the parameters and local variables in a run time

Which one memory requires refreshing, Which of following requires refreshin...

Which of following requires refreshing SRAM., DRAM., ROM. or EPROM. ? Ans. DRAM. requires refreshing.

Implemented in a program developed for sorting , A student counted up the n...

A student counted up the number of statements implemented in a program developed for sorting n integers and came up with a recurrence of the form: T(n) = a * n + b + 2T(n/2), an

Network, Give an intuitive explanation of why the maximum throughput, for s...

Give an intuitive explanation of why the maximum throughput, for small beta, is approximately the same for CSMA slotted Aloha and FCFS splitting with CSMA. Show the optimal expecte

Fitness function - canonical genetic algorithm, Fitness function - canonica...

Fitness function - canonical genetic algorithm: Conversely the fitness function will use an evaluation function to calculate a value of worth for the individual accordingly th

Intel architecture – 64, IA-64 (Intel Architecture-64) is a 64-bit processo...

IA-64 (Intel Architecture-64) is a 64-bit processor architecture created in cooperation by Hewlett-Packard and Intel applied by processors like Itanium. The objective of Itanium wa

Towers of hanoi problem, The Towers of Hanoi Problem Towers of Hanoi pro...

The Towers of Hanoi Problem Towers of Hanoi problem is described. There are three pegs on which disks are "threaded" (there are holes in the disks to allow them to be placed on

Describe about second generation computers, Q. Describe about Second Genera...

Q. Describe about Second Generation Computers? Silicon brought advent of second generation computers. A two state device termed as a transistor was created from silicon. Transi

Explain the working of a weighted register d/a converter, With the help of ...

With the help of a neat diagram, explain the working of a weighted-resistor D/A converter. Ans Weighted Register D/A Converter:   Digital input that has 4 bits

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