answersLogoWhite

0

there are two types of selection statements in c-language they are if-else and switch case.these two are known as selection statements,because their syntax is like this,

if-else syntax:-if(condition)

{

statements

}

else

{

statement

}

in the abow syntax it contains two blocks first one is if and second one is else in 'if' it fills with required condition if the condition is satisfied then it execute the if block,whether it is false it execute the else statements.

switch case syntax:-

switch(condition)

{

case.1:statements;

case.2:statements;

case.3:statements;

.

.

.

case.n:statements;

default:statement;

}

in abow switch case we can select any case and execute,in this selection statement gives the fiexibulity to the user.it contains default statement it shows the wrong selection in these cases.

examples programs to these statements:-

1.biggest of two numbers program?

main()

{

int a,b,c;

printf("enter a,b values");

scanf(&a);

scanf(&b);

scanf(&c);

if(a>b)

{

printf("a is big");

}

else

{

printf("b is big");

}

}

out put:-

enter a,b values 8,5

a is big

enter a,b values 3,9

b is big

2.perform arithmetic operation intwo numbers?

main()

{

int a,b,c,d;

printf("enter a,b values");

scanf(&a);

scanf(&b);

scanf(&c);

printf("enter your choice"&c);

switch(c)

{

case.1:d=a+b;

printf("d value is"&d);

case.2:d=a-b;

printf("d value is"&d);

case.3:d=a*b;

printf("d value is"&d);

default:printf("wrong selection");

}

}

out put:-

enter a,b values 6,5

enter your choice 1

d=11

enter your choice 2

d=1

enter your choice 3

d=30

User Avatar

Wiki User

14y ago

What else can I help you with?

Continue Learning about Engineering
Related Questions

How many language processors are there?

there are three types of language processors namely interpreter,compiler and assembler


How many types special communication are there eg silent language?

British sign language Makaton and Braille


When you're composing a piece of communication in the professional world there are many types of language to avoid what are they?

Informal and casual language


Does the shopping channel sell products for children?

Yes they do. They offer a large selection of many different types of products for kids. They have a large selection of children's clothes and toys as well.


How many types of c language files are there?

ASCII and BINARY are the basic classifications of files


What is the Difference between assembler and macro?

I am not sure about the answer but think so, Assembler: Its a program that converts a low level language into machine code, and there is a one-to-one correspondence between the source language statements and machine instructions Macro- Assembler: It performs the same task as does the assembler but there is some times a one-to-many correspondence between the source language statements and machine instructions. Please discuss further...


What language is You Tube De in?

YouTube De is in the German language. They have many of the same types of videos on the regular YouTube but the vast majority of them are in German made by Germans.


How many types of barriers of communication are there?

There are many types of barriers of communication for example; language barrier, physical barrier, emotional barrier, listening barrier, cultural barrier, gender barrier etc


Are there any sites that sell cheap office equipment?

There are many websites which provide office equipment. Amazon.com actually has a large selection of these types of items.


Why do many practices send out remainder statements than standard statements?

Whay is the difference between remainder statement and standard statements?


how many languages are there?

there are three types of language processors namely interpreter,compiler and assembler


How many figurative languages are there?

There are many types of figurative language, such as similes, metaphors, personification, hyperbole, and idioms, among others. The exact number can vary depending on how specific you want to get with different types and variations.