GeekInterview.com
Series: Subject: Topic:
Question: 297 of 587

how to make a progarm using switch case statement?

Asked by: Interview Candidate | Asked on: Sep 8th, 2006
Showing Answers 1 - 4 of 4 Answers
karthik

Answered On : Sep 15th, 2006

#include<stdio.h>

main()

{

int  n;

printf("Enter 1 or 2");

scanf("%d",&n);

switch(n)

{

case 1:

{

printf("hai");

break;

}

case 2:

{

printf("hello");

break;

}

default:

{

printf("enter 1 0r 2");

break;

}

}

}

  
Login to rate this answer.
milind patil

Answered On : Sep 26th, 2006

#include<stdio.h>

#include<conio.h>

main()

{

int  a=15,b=7,r,no;

printf("1.addition  2.subraction 3.exit");

scanf("%d",&no);

switch(no)

{

case 1: //for addition

{

r=a+c;

printf("%d",r);

break;

}

case 2:

{

r=a-c;

printf("%d",r);

break;

}

default:

{

break;

}

}

}

  
Login to rate this answer.
praveen tiwari vaishnav mcm

Answered On : Oct 14th, 2006

#include#includevoid main(){int ch;printf("enter the no");scanf("%d",&ch);switch(ch){case 1: printf(" amerika" ); break;case 1: printf("indore"); break;defoult : printf("no value"); }

  
Login to rate this answer.
Riquelme

Answered On : Mar 12th, 2007

Brankets "{}" are not necessary in case branches, since switch-case is straight flow structure. Thanks.

  
Login to rate this answer.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.