Skip to content

Commit

Permalink
Added 2 problems to Operator & Expression Chapter
Browse files Browse the repository at this point in the history
  • Loading branch information
Shahriar-Seam committed Aug 17, 2024
1 parent afe3008 commit d01dc7e
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 1 deletion.
1 change: 1 addition & 0 deletions book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ mathjax-support = true
[output.html.code.hidelines]
python = "~"
c = "~"
hint = "~"
96 changes: 96 additions & 0 deletions src/Operator_and_Expression/Operator_and_Expression.md
Original file line number Diff line number Diff line change
@@ -1 +1,97 @@
# Operator & Expression


## Problems
* ***Click on the title of the problem to submit your solution before looking at our solution.***
* ***We discourage looking at our solution before attempting to solve it by yourself first.***

1. **[Simple Calculator](https://vjudge.net/problem/Gym-287306C)**

Given two numbers X and Y. Print the summation and multiplication and subtraction of these 2 numbers.

***Input***

Only one line containing two separated numbers \\(X, Y (1  ≤  X, Y  ≤  10 ^ 5)\\)

***Output***

Print 3 lines that contain the following in the same order:

1. "\\(X + Y =\\) **summation result**" without quotes.
2. "\\(X * Y =\\) **multiplication result**" without quotes.
3. "\\(X - Y =\\) **subtraction result**" without quotes.

***Examples***

Input
```
5 10
```
Output
```
5 + 10 = 15
5 * 10 = 50
5 - 10 = -5
```
***Notes***
**Be careful with spaces.**
Hint:
```hint
Press the eye icon to reveal hint.
~ Use long long int instead of int
~ Don't forget to use the designated format specifier for long long int (%lld)
```
**Solution**
```c
// Press the eye icon to reveal solution.
~#include <stdio.h>
~int main()
~{
~ long long x, y;
~
~ scanf("%lld %lld", &x, &y);
~
~ printf("%lld + %lld = %lld\n", x, y, x + y);
~ printf("%lld * %lld = %lld\n", x, y, x * y);
~ printf("%lld - %lld = %lld\n", x, y, x - y);
~
~ return 0;
~}
```
2. **[Difference](https://vjudge.net/problem/Gym-287306D)**
Hint:
```hint
Press the eye icon to reveal hint.
~ Use long long int instead of int
~ Don't forget to use the designated format specifier for long long int (%lld)
```
**Solution**
```c
// Press the eye icon to reveal solution.
~#include <stdio.h>
~int main()
~{
~ long long a, b, c, d, x;
~
~ scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
~
~ x = (a * b) - (c * d);
~
~ printf("Difference = %lld\n", x);
~
~ return 0;
~}
```
2 changes: 1 addition & 1 deletion src/Recursion/Practice_on_Recursion.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# PRACTICE Recursion

Some of the sollowing problems are directly copied from [Zobayer Hasan vai's blog post on recursion](https://zobayer.blogspot.com/2009/12/cse-102-practice-recursions.html). We are grateful to his open contributions towards learning CS.\
Some of the following problems are directly copied from [Zobayer Hasan vai's blog post on recursion](https://zobayer.blogspot.com/2009/12/cse-102-practice-recursions.html). We are grateful to his open contributions towards learning CS.\
You can use the [Competitive Programming Helper (cph)](https://marketplace.visualstudio.com/items?itemName=DivyanshuAgrawal.competitive-programming-helper) extension in VS code to make your practice easier though it wont make a big difference.

<i>ALL THE BEST FOR YOUR HARD WORK.</i>
Expand Down

0 comments on commit d01dc7e

Please sign in to comment.