Code
Code
#include<iostream>
int main()
int choice;
float temperature,fahreheit,Celsius;
cout<<"---Display Menu---"<<endl;
cin>>choice;
if(choice ==1)
cin>>temperature;
Celsius=(temperature-32)*5.0/9.0;
cout<<"Celsius"<<Celsius<<endl;
else if(choice==2)
cin>>temperature;
fahreheit=(temperature+32)*9.0/5.0;
cout<<"Fahrenheit"<<fahreheit<<endl;
else
return 0;
//case study 3
#include<iostream>
#include<iomanip>
int main()
int years;
cin>>principal amount;
cin>>years;
cin>>interestRate;
return 0;
//case study 4
#include<iostream>
void Displaynumbers(int n)
for(int i=0;i<=n;i++){
cout<<i<<" ";
cout<<endl;
int main()
int n;
cout<<"Enter a positive integer:";
cin>>n;
if(n<1){
}else{
Displaynumbers(n);
return 0;
//case study 5
#include<iostream>
class Product
string productname;
int productid;
int price;
public:
Product()
productname="wafer";
productid=20;
price=230;
void discount()
int discountamount=(discountamount/100)*price;
price -=discountamount;
void display()
{
cout<<"productname:" <<productname<<endl;
cout<<"productid:" <<productid<<endl;
cout<<"price:" <<price<<endl;
};
int main()
Product pro1;
int discountamount;
cin>>discountamount;
pro1.discount();
pro1.display();
return 0;
//case study 6
#include<iostream>
class Employee
string empname;
int empid;
public:
empname=empname;
empid=empid;
empcount++;
}
void display()
cout<<"Total Employee:"<<empcount<<endl;
};
int Employee::empcount=0;
int main ()
Employee emp1("aryan",101);
Employee emp2("Raj",103);
Employee emp3("smit",104);
emp1.display();
emp2.display();
emp3.display();
Employee emp4("virat",18);
emp4.display();
return 0;
//case study 7
#include<iostream>
class BankAccount
string accholder;
string accname;
int accnumber;
public:
{
accholder=accholder;
accname=accname;
accnumber=accnumber;
accountCount++;
void display()
};
int BankAccount::accountCount=0;
int main()
BankAccount ba1("icici","aryan",123);
ba1.display();
BankAccount ba2("bob","harsh",1245);
ba2.display();
BankAccount ba3("pnb","prachi",24353);
ba3.display();
BankAccount ba4("sbi","raj",5677);
ba4.display();
return 0;
#include<iostream>
#include<fstream>
int main()
char ch;
ofstream outfile("textfile.txt");
if(!outfile.is_open()){
return 1;
outfile<<ch;
outfile.close();
ifstream infile("textfile.txt");
if(!infile){
return 1;
while(infile>>ch){
cout<<ch;
infile.close();
#include<iostream>
class Person
protected:
string name;
int age;
public:
Person(string n,int a)
{
name=n;
age=a;
void displaydetails()
cout<<"name:"<<name<<endl;
cout<<"age:"<<age<<endl;
};
private:
char grade;
public:
grade=g;
void displaygrade()
cout<<"grade:"<<grade<<endl;
};
int main()
Student s("aryan",18,'A');
s.displaydetails();
s.displaygrade();
return 0;
#include<iostream>
#include<fstream>
using namespace std;
int main()
int num1,num2;
cin>>num1;
cin>>num2;
try{
if(num2!=0)
cout<<"Result:"<<res;
else{
throw(num2);
catch(int num2)
cout<<"Divide by zero"<<endl;
cout<<"existing main()...";
return 0;
//string program
#include<iostream>
int main()
string str;
cout<<"Enter a string:";
cin>>str;
cout<<"Uppercase:";
for(int i=0;i<str.length();i++){
cout<<char(toupper(str[i]));
return 0;
#include<stdio.h>
#include<conio.h>
void main()
clrscr();
printf("\n\t\t\t ------------");
printf("\n\t\t\t -----------------");
getch();
Output
--------------
Roll no: 02
City: Ahmedabad
----------------
// Write a Program For Area and Perimeter of Rectangle.
#include<iostream>
int main()
cin>>length;
cin>>width;
area=length*width;
perimeter=2*(length+width);
cout<<"area of a rectangle:"<<area<<endl;
cout<<"perimeter of a rectangle:"<<perimeter<<endl;
return 0;
#include<iostream>
int main()
int n,i;
cout<<"Enter n:";
cin>>n;
if(i%2==0)
cout<<n<<" is even"<<endl;
else{
cout<<n<<" is odd"<<endl;
return 0;
#include<iostream>
int main()
int a=34,b=67,c=89;
if(a>=b)
if(a>=c)
cout<<a;
else
cout<<c;
else{
if(b>=c)
cout<<b;
else
cout<<c;
return 0;
#include<iostream>
int main()
int num,i;
cout<<"enter number:";
cin>>num;
if(i%2==0)
else{
return 0;
//Write a program that displays the sum of the n terms of even natural numbers.
#include<iostream>
#include<cmath>
int main()
int base;
int exponent,result;
cout<<"Enter base:";
cin>>base;
cout<<"Enter exponent:";
cin>>exponent;
result= pow(base,exponent);
cout<<base<<" is raised to the power " <<exponent <<" is: " <<result <<endl;
return 0;
//Write a program in to display a pattern like a right angle triangle using an asterisk.
#include<iostream>
int main()
int rows;
cout<<"input number of rows:";
cin>>rows;
for(int i=0;i<=5;i++){
for(int j=1;j<=i;j++){
cout<<"*";
cout<<endl;
return 0;
#include <iostream>
int main() {
if (i % 2 == 0)
continue;
return 0;
//Overload a function to find the maximum of two, three, and four numbers.
#include <iostream>
return (a > b) ? a : b;
int main() {
cout << "Max of 2 numbers (20, 30): " << max(20, 30) << endl;
cout << "Max of 3 numbers (3, 55, 16): " << max(3, 55, 16) << endl;
cout << "Max of 4 numbers (34, 100, 89, 99): " << max(34, 100, 89, 99) << endl;
return 0;