Skip to content

Commit

Permalink
Add C++ Programs
Browse files Browse the repository at this point in the history
Added New C++ Programs
  • Loading branch information
adi-075 committed Apr 11, 2021
1 parent a881b60 commit 786305c
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
31 changes: 31 additions & 0 deletions Board Paper Programs/Programs/prog2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include <iostream>
using namespace std;
class temperature
{
double cel;
double fah;
public:
temperature(); // Constructor
void convert();
void print();
};
temperature::temperature()
{
cout << "Enter temperature in degree celsius: \n";
cin >> cel;
}
void temperature::convert()
{
fah = cel*1.8000+32.00;
}
void temperature::print()
{
cout<< "\nThe degree Fahrenheit Temperature is: \n";
cout << fah;
}
int main()
{
temperature obj;
obj.convert();
obj.print();
}
30 changes: 30 additions & 0 deletions Board Paper Programs/Programs/prog3.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include <iostream>
using namespace std;
class avg
{
float a, b, c, average; // Variable for 3 subjects
public:
avg(); //Constructor
void calculate();
void print();
};
avg::avg()
{
cout << "Enter marks of 3 subjects:\t";
cin >> a >> b >> c;
cout << "Calculating...."<<endl;
}
void avg::calculate()
{
average = (a+b+c)/3;
}
void avg::print()
{
cout << "The average of 3 numbers is: "<<average;
}
int main()
{
avg obj;
obj.calculate();
obj.print();
}

0 comments on commit 786305c

Please sign in to comment.