Write an algorithm to accept the length and breadth of a rectangle and display the area and perimeter
Answers
Answer:
AnswEr :
⠀⠀⠀⌬ Let the Unit's place digit = M
⠀⠀⠀⌬ And the ten's place digit = N
⠀⠀⠀⌬ Then, Original Number = 10(M + N)
⠀⠀⠀⌬ Also, Interchaged Number = 10(N + M)
⠀
• F i r s t⠀C o n d i t i o n :
Sum of the two digits (M + N) number is 9.
\begin{gathered}\twoheadrightarrow\sf M + N = 9 \qquad\quad\qquad\quad\Bigg\lgroup\sf eq^{n}\;(1)\Bigg\rgroup\\\\\end{gathered}
↠M+N=9
⎩
⎪
⎪
⎪
⎪
⎪
⎧
eq
n
(1)
⎭
⎪
⎪
⎪
⎪
⎪
⎫
• S e c o n d⠀C o n d i t i o n :
⠀
After Interchanging the digits, the new number is greater than the original number by 27.
⠀
\begin{gathered}\longrightarrow\sf (10N + M) - (10M + N) = 27\\\\\\\end{gathered}
⟶(10N+M)−(10M+N)=27
\begin{gathered}\longrightarrow\sf 9N - 9M = 27\\\\\\\end{gathered}
⟶9N−9M=27
\begin{gathered}\longrightarrow\sf N - M = 3\\\\\\\end{gathered}
⟶N−M=3
\begin{gathered}\longrightarrow\sf N = 3 + M \qquad\quad\qquad\quad\Bigg\lgroup\sf eq^{n}\;(2)\Bigg\rgroup\\\\\end{gathered}
⟶N=3+M
⎩
⎪
⎪
⎪
⎪
⎪
⎧
eq
n
(2)
⎭
⎪
⎪
⎪
⎪
⎪
⎫
\begin{gathered}\underline{\bigstar\:\sf{Substitue \: the \: value \: of \: N \: from \: eq^n \: (2) \: to \: eq^n \: (1) : }} \\ \\ \\ \end{gathered}
★SubstituethevalueofNfromeq
n
(2)toeq
n
(1):
\begin{gathered}\longrightarrow\sf M + N = 9\\\\\\\end{gathered}
⟶M+N=9
\begin{gathered}\longrightarrow\sf M + 3 + M = 9\\\\\\\end{gathered}
⟶M+3+M=9
\begin{gathered}\longrightarrow\sf 2M = 9 - 3 \\\\\\\end{gathered}
⟶2M=9−3
\begin{gathered}\longrightarrow\sf 2M = 6\\\\\\\end{gathered}
⟶2M=6
\begin{gathered}\longrightarrow\sf M = \cancel\dfrac{6}{2}\\\\\\\end{gathered}
⟶M=
2
6
\begin{gathered}\longrightarrow\sf M = 3\\\\\end{gathered}
⟶M=3
\begin{gathered}\underline{\bigstar\:\sf{Substituting\;value\;of\;M\;in\;\;eq^n\;(1)\;: }} \\ \\ \\ \end{gathered}
★SubstitutingvalueofMineq
n
(1):
\begin{gathered}\longrightarrow\sf M + N = 9\\\\\\\end{gathered}
⟶M+N=9
\begin{gathered}\longrightarrow\sf 3 + N = 9\\\\\\\end{gathered}
⟶3+N=9
\begin{gathered}\longrightarrow\sf N = 9 - 3\\\\\\\end{gathered}
⟶N=9−3
\begin{gathered}\longrightarrow\sf N = 6\\\\\end{gathered}
⟶N=6
\begin{gathered}\underline{\bigstar\:\textsf{Now,\;Original\; Number\; :}}\\\\\end{gathered}
★Now,OriginalNumber:
\begin{gathered}\twoheadrightarrow\sf Original\; Number = 10(M + N)\\\\\\\end{gathered}
↠OriginalNumber=10(M+N)
\begin{gathered}\twoheadrightarrow\sf Original\; Number = 10(3) + 6\\\\\\\end{gathered}
↠OriginalNumber=10(3)+6
\begin{gathered}\twoheadrightarrow\sf Original\; Number = 30 + 6\\\\\\\end{gathered}
↠OriginalNumber=30+6
\begin{gathered}\twoheadrightarrow\underline{\boxed{\pmb{\sf{ Original\; Number =36}}}}\\\\\end{gathered}
↠
OriginalNumber=36
OriginalNumber=36
\;\;\;\;\;\qquad\therefore{\underline{\textsf{Hence, the Original number is \textbf{36}.}}}∴
Hence, the Original number is 36.
Answer:
- Take the input length(l).
- Take the input breadth(b).
- Apply the formula of area (l b).
- store it in variable ( Area= l b).
- Perimeter formula (2 (l+b)).
- Store it in variable(Perimeter=2 (l+b)).
- Print Area.
- Print Perimeter.
Explanation: