Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Lesson-1/examples/helloworld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ int main()
{
//Hello World Demo
cout << "Hello, World!";
return 0;
}
48 changes: 38 additions & 10 deletions Lesson-2/solutions/calculator.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,40 @@
#include <iostream>
# include <iostream>
using namespace std;

int main()
{
int num1, num2, num3;
std::cout << "Enter any 3 numbers" << std::endl << "Number 1: ";
std::cin >> num1;
std::cout << "Number 2 ";
std::cin >> num2;
std::cout << "Number 3 ";
std::cin >> num3;
std::cout << num1 + num2 + num3;
}
char op;
float num1, num2;

cout << "Enter operator either + or - or * or /: ";
cin >> op;

cout << "Enter two operands: ";
cin >> num1 >> num2;

switch(op)
{
case '+':
cout << num1+num2;
break;

case '-':
cout << num1-num2;
break;

case '*':
cout << num1*num2;
break;

case '/':
cout << num1/num2;
break;

default:
// If the operator is other than +, -, * or /, error message is shown
cout << "Error! operator is not correct";
break;
}

return 0;
}