C++ Program to perform all arithmetic calculation using switch case

#include<iostream.h> #include<conio.h> void main() { clrscr(); float a,b,res; int ch,q; cout<<“Arithmetic Operatios”; cout<<“nn1.Additionn2.Subtractionn3.Multiplicationn4.Divisionn5.Mode”; cout<<“n  Enter your choice:”; cin>>ch; switch(ch) { case 1: { cout<<“nnEnter two variables:”; cin>>a>>b; res=a+b; cout<<“n  Result=”<<res; } break; case 2: { cout<<“nnEnter two variables:”; cin>>a>>b; res=a-b; cout<<“n  Result=”<<res; } break; case 3: { cout<<“nnEnter two variables:”; cin>>a>>b; res=a*b; cout<<“n  Result=”<<res; } …

C++ Program to perform all arithmetic calculation using switch case Read More »

Prime Number in C++

Here you learn how to check prime number in C++. Prime number is a number which is only divided by 1 or itself. Below is the C++ program to check whether a number is prime of not.   Prime Number in C++ #include<iostream> using namespace std; int main() { int n,i,flag=1; cout<<“Enter any number:”; cin>>n; …

Prime Number in C++ Read More »

C++ Program to Find Roots of Quadratic Equation

Here you will get simple C++ program to find roots of quadratic equation ax2+bx+c=0. #include<iostream> #include<math.h> //to calculate square root using namespace std; int main() { float root1,root2,a,b,c,d,imaginaryPart,realPart; cout<<“Quadratic Equation is ax^2+bx+c=0”; cout<<“\nEnter values of a,b and c:”; cin>>a>>b>>c; d=(b*b)-(4*a*c); if(d>0) { cout<<“\nTwo real and distinct roots”; root1=(-b+sqrt(d))/(2*a); root2=(-b-sqrt(d))/(2*a); cout<<“\nRoots are “<<root1<<” and “<<root2; } …

C++ Program to Find Roots of Quadratic Equation Read More »

C++ Program for temperature conversion which converts fahrenheit to celcius or celcius to fahrenheit depending upon user's choice

#include<iostream.h>#include<conio.h> void main(){ clrscr(); //to clear the screen float temp,res; int choice; cout<<“Temperature Conversion”<<“nn   1.Fahrenheit to Celcius”; cout<<“n   2.Celcius to FahrenheitnnEnter your choice:”; cin>>choice; switch(choice){ case 1: {     cout<<“nEnter temperature in Fahrenheit:”;     cin>>temp;     res=(temp-32)/1.8;} break; case 2: {     cout<<“nEnter temperature in Celcius:”;     cin>>temp;     res=(temp*1.8)+32;} break; } cout<<“nConverted Temperature=”<<res; getch(); …

C++ Program for temperature conversion which converts fahrenheit to celcius or celcius to fahrenheit depending upon user's choice Read More »