ONLINE SUMMER TRAINING Online Courses Free Tutorials 
 Placement Preparation 
Artificial Intelligence(AI) & Machine Learning(ML) Training in Jaipur
0 like 0 dislike
329 views
in JNTU BTech (CSE-I-Sem) C PROGRAMMING AND DATA STRUCTURES LAB by Goeduhub's Expert (7.1k points)

Write a C program, which takes two integer operands and one operator from the user, performs the operation and then prints the result. (Consider the operators +,-,*, /, % and use Switch Statement)

Goeduhub's Online Courses @Udemy

For Indian Students- INR 570/- || For International Students- $12.99/-

S.No.

Course Name

Apply Coupon

1.

Tensorflow 2 & Keras:Deep Learning & Artificial Intelligence

Apply Coupon

2.

Computer Vision with OpenCV | Deep Learning CNN Projects

Apply Coupon

3.

Complete Machine Learning & Data Science with Python Apply Coupon

4.

Natural Language Processing-NLP with Deep Learning in Python Apply Coupon

5.

Computer Vision OpenCV Python | YOLO| Deep Learning in Colab Apply Coupon

6.

Complete Python Programming from scratch with Projects Apply Coupon

1 Answer

0 like 0 dislike
by Goeduhub's Expert (7.1k points)
edited by
 
Best answer

Arithmetic Operations Using Switch

In this program we are going to perform arithmetic operations on operands provided by user along with operators.

Example :

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
int a,b;
int ch;
printf("\nEnter a and b :");
scanf("%d%d",&a,&b);
printf("\nEnter operation to be performed\n1. +\n2. -\n3. *\n4. /\n5. %\n");
scanf("%d",&ch);
switch(ch)
{
case 1:printf(" %d + %d = %d",a,b,a+b);
break;
case 2:printf(" %d - %d = %d",a,b,a-b);
break;
case 3:printf(" %d * %d = %d",a,b,a*b);
break;
case 4:printf(" %d / %d = %.2f",a,b,a/b);
break;
case 5:printf(" %d",a%b);
break;
default:printf("\nEnter valid numbers or operator");
}
getch();
}

Output :

Output of above program showing arithmatic operations


For More JNTU C Programming Lab Experiments Click Here

Our Mentors(For AI-ML)


Sharda Godara Chaudhary

Mrs. Sharda Godara Chaudhary

An alumna of MNIT-Jaipur and ACCENTURE, Pune

NISHA (IIT BHU)

Ms. Nisha

An alumna of IIT-BHU

Related questions

 Goeduhub:

About Us | Contact Us || Terms & Conditions | Privacy Policy || Youtube Channel || Telegram Channel © goeduhub.com Social::   |  | 
...