write a program to perform addition,subtraction,multiplication,division with switch statement

Asked by Last Modified  

9 Answers

Follow 0
Answer

Please enter your answer

The tutor

U can just Google it. It's very simple one
Comments

MathWorks Certified MATLAB Associate

Switch case Syntax in MATLAB is switch switch_expression case case_expression statements case case_expression statements ... otherwise statements end
Comments

MathWorks Certified MATLAB Associate

switch switch_expression case case_expression statements case case_expression statements ... otherwise statements end
Comments

int main() { char o; float num1,num2; printf("Enter operator either + or - or * or divide : "); scanf("%c",&o); printf("Enter two operands: "); scanf("%f%f",&num1,&num2); switch(o) { case '+': printf("%.1f + %.1f = %.1f",num1, num2, num1+num2); ...
read more
int main() { char o; float num1,num2; printf("Enter operator either + or - or * or divide : "); scanf("%c",&o); printf("Enter two operands: "); scanf("%f%f",&num1,&num2); switch(o) { case '+': printf("%.1f + %.1f = %.1f",num1, num2, num1+num2); break; case '-': printf("%.1f - %.1f = %.1f",num1, num2, num1-num2); break; case '*': printf("%.1f * %.1f = %.1f",num1, num2, num1*num2); break; case '/': printf("%.1f / %.1f = %.1f",num1, num2, num1/num2); break; default: /* If operator is other than +, -, * or /, error message is shown */ printf("Error! operator is not correct"); break; } return 0; } o/p Enter operator either + or - or * or divide : - Enter two operands: 3.4 8.4 3.4 - 8.4 = -5.0 read less
Comments

Tutor

in which language you want to write the program
Comments

Life Scientist

Not related to my expertise
Comments

Trainer

simple u can even get from 1000 program from web
Comments

switch(op) { case '+': c=a+b; break; case '-':c=a-b; break; case '*':c=a*b; break; case '/':c=a/b; break; default: printf("Please check the operator"); } Here op is a character for the operation you r going to perform. Instead you can send a string like add sub etc in double quotes.
Comments

Phd In Electrical Engineering

if you are an hardware engineer and know verilog or vhdl or systemc you can do this by refering to various computer arithmetic books which gives algorithm using logic gates and that can be implement with cas switch statements
Comments

View 7 more Answers

Related Questions

Is B.Sc. option better than B.Tech. after Class 12?
This entirely depends upon your choice, ambition and your past academic performance all taken together commensurating with your own aptitude.While doing B.Sc. one thing should be kept in mind that after...
Avinash
I CAN TEACH B.TECH. CLASSES FOR ENGINEERING ECE STUDENTS , IS THERE ANY CHANCE FOR ME ?
Definitely. But prior to that, I would expect you to brush up your technical knowledge so that you can teach the undergrads with ease. Also, do revise the subjects on a regular basis. Last but not the...
Koppula
0 0
6
On what basis the materials of the universe can be classified as insulators, conductors, semi conductors? Is it the unique method to classify or is there any other method for that?
All these materials are classified on the basis of forbidden energy gap between conduction band and valence band. In conductor ,conduction band is fully filled with electrons. In insulator ,valence band...
Saikrishna
0 0
7
What is the use of scanf() operator?
Operator is also function hiding the name with a operator.
Kiran

Now ask question in any of the 1000+ Categories, and get Answers from Tutors and Trainers on UrbanPro.com

Ask a Question

Related Lessons

Chapter 1: Introduction part 1
Hello, first chapter is an Introduction. So, Let's start with introducing our subject. Name of our subject is BASIC MECHNICAL ENGINEERING. so if we divide the name what we'll get..? First word is...
N

Facebook Analytics
Assume how the Facebook application will store the millions of customer's record in real-time: facebook = { 'jose': { 'name': 'jose', 'age': 33, 'hobby': , # cricket,football 'mobile': 1111111111, 'email':...

DUCTILE DETAILING AND ITS SIGNIFICANCE + HOW TO ACHIEVE DUCTILITY
Ductility of Buildings is a key virtue. Ductility is the ability to prolong yielding or in simple words, prolonging deformation and failure.Why should we prolong yielding of steel?As we know, we design...

Master the Object-Oriented Mindset via Coding
Master the Object-Oriented Mindset via Coding It's time to make objects work for you. You will learn Object-Oriented perspective by example, in the context of simple applications of your programming...

How u can explain Ohm's law to a layman who is not knowing any thing about voltage, current or resistance?
Consider a tank which is filled with water and placed at some heights. This tank has a pipe connection that is going downwards to another tank in the ground level. The height difference between the 2 tanks...

Recommended Articles

MBA, Medicine and engineering are the three main professional courses in India. Engineering is still one of the highly sorted after professional courses in the under graduate level, while MBA is favoured as a preferred post graduate course. To shine in these courses, one needs to work and study hard. Engineering as a...

Read full article >

According to a recent survey conducted by the NCAER (National Council of Advanced Economic Research), engineering is the most sought after course in India. Some engineering courses are offered as BE or Bachelor of Engineering while some as Bachelor in Technology or B.Tech. Since engineering is a professional course, the...

Read full article >

Appearing for exams could be stressful for students. Even though they might have prepared well, they could suffer from anxiety, tension etc. These are not good for their health and mind. However, following a few exam preparation tips can save them from all these and help them to score good marks. Let’s find out all...

Read full article >

With the mushrooming of international and private schools, it may seem that the education system of India is healthy. In reality, only 29% of children are sent to the private schools, while the remaining head for government or state funded education. So, to check the reality of Indian education system it is better to look...

Read full article >

Looking for BTech Tuition ?

Learn from the Best Tutors on UrbanPro

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you