Hello Everyone
I'm AhsanSharif From Pakistan
Greetings you all, hope you all are well and enjoying a happy moment of life with steem. I'm also good Alhamdulillah. |
---|
Made in Canva
Online Compiler IDE (Online IDE Beta) |
---|
There are many online compilers that we can use to start our coding. For this, you must begin with C Plus Plus which is a simple language and after that, you have to search on Google for the online compiler. There are many different types of online compilers that you can choose from. Whichever you think is easy to understand and do.
I use an online compilation tool called Online IDE BETA.
In the image above I have marked each item separately. The first thing I mentioned is the language. In this, we will select the language in which language we want to run our program. And then secondly I have shown our data entry field where our code is written. And thirdly I have mentioned our input field from where we can run our next program. On the fourth number I have mentioned the run button where we will run our code. And the fifth thing we need is our output feed where the output of our program will show.
There are many compilers where we give the input field on a separate page and we show the output on a separate page, but the best online compiler is the one that shows both the input field and the output field on the same page.
Finding your way to act, from 1 to 100 effective or not in this task is not important. |
---|
1+1+1=3*2=6*2=12*2=24*2=48+1+1=50*2=100
Since we have to reach 100 using only two operations, we will try to use minimum steps. So that we can reach our goal quickly, I will edit first for that. I will do the edition three times, one plus one plus one. In this case, we will have answer three.
In the next step, we will multiply three by two, in which case we will have an answer of six. Then multiply six by two and the answer will be 12. Then multiply 12 by two and the answer will be 24. Then multiply 24 by two and the answer will be 48.
The next step will be our then addition where we have to add the one twice. In which case we will get the answer 50.
Our next step is multiplication, where we multiply 50 by two and our answer becomes 100.
By following these steps we can reach from one to 100 easily.
Find the best, shortest way. No one found it in the last lesson. Search! |
---|
1*2=2+1=3*2=6*2=12*2=24+1=25*2=50*2=100
In this task, we have to find the shortest way in which we have to get our approach to 100. For this, we will try to shorten our steps to reach 100 easily. The steps I found are as follows.
First, we will start with one. After starting with one, we will multiply that one by two in the second step, in which case we will have the answer two. When we get the answer two, then in this two we have to add one, in which case we will get the answer three.
In the next step, we will multiply three by two, in which case we will have an answer of six. And then multiply six by two to get the answer 12. Then multiply 12 by two and the answer will be 24.
After multiplying to 24 we will then add plus one to it. In which case we will get the answer 25.
Here again, we'll multiply 25 by two, which gives us the answer of 50.
This is our final step to get to 100 where we have to multiply 50 by two and our answer will be 100.
Here's what I've tried to get to 100 in a shortcut I've used nine steps.
If in addition to +1and x2it is possible to create an additional variable int k; how many steps will it save, you cannotk=n put a certain number in the variable, for example, 7 or 23. You can only fix the value of the variable at a certain step n. |
---|
1*2=2*2=4+1=5
K=5
5*k=25*2=50*2=100
This is a complex task in which we have to use variable k and thereby shorten our steps even more. So that we can easily reach our goal and our main goal is 100. To reach 100 we will use the k variable of this int.
For this too, first of all, we will start with one. The first step will be our one. In the second step, we have to multiply one by two, in which case we will have two.
In the next step, we have to multiply these two again by two, in which case we get the answer four. When the answer is four, we will add one to it, in which case the answer will be five.
Now we have to use the variable, so our answer is five, we have to set it in the variable k.
Now our answer was five, so with this five, we have to multiply this variable. This variable is k but has a value of five. This means that five times five will give us the answer of 25.
Now the next step will be our multiplication. We have to multiply 25 by two, in which case we get the answer 50. When the answer comes to 50, in the next step we will multiply it by two, in which case the answer will come to 100.
Using this variable we have two more steps reduced. In this case, we have solved our problem using seven steps and achieved our goal.
In my profile, you can see that I have a total of 180 followers of which I have to use the first two digits which is 18. When I add 21 to this 18, the answer comes to 39. Now to reach 39 I have to find my shortcut so that I can reach my goal using fewer steps.
To reach my goal, I have started from one and the first step is one. In the second step, I multiplied one by two and the answer was two. Then multiply two by two again and the answer will be four. Then I have multiplied four again by two and the answer will be eight.
Now in answer eight, I have added one so my answer will become nine. Now multiply nine again by two and the answer will be 18. In 18 I will add one again and the answer will come 19.
Now I will multiply 19 by two again which will answer 38. And 38 I will add one more answer 39 will come.
Below is the C++ code I used to solve this.
This is the final output of the code which tells us which and how many steps we can follow to reach our main goal.
Take your number, I take my 49 and add its digits and also add 7: 4+9+7=16. We need to write a program to raise the number to the 16th power - all of you will have different numbers. |
---|
My number is 39 so I will add it to each other and it will become 12. And to 12 we will add seven more which will become 19.
In the calculation of this number, I will do it in the C++ program, in which 2^¹⁹ and 2 will be base and 19 will be its power.
Here is the code:
The output of my program is 524288 after executing it.
So 2^19 = 524288
Write a program to divide it into numbers. And now how to collect it from numbers back into a number? How to reverse a number. In other words, unfold. for example, how to get 39 from 93. |
---|
Here is the code:
Explanation:
Extract last Num:
digit=num % 10
First of all we extract the last num.
Build Reverse Num:
reversedNumber = reversedNumber * 10 + digit
shifts the digits of reverse num. to left by multiplying 10 and then adding a new digit.
Remove Last Digit From Num:
num/=10
removing the last digit from the original num.
Repeat:
Repeat the process until the original number becomes zero.
Example of my number 39:
If the user enters 93, the steps will be:
digit = 93 % 10 = 3
reversedNumber = 0 * 10 + 3 = 3
num = 93 / 10 = 9
digit = 9 % 10 = 9
reversedNumber = 3 * 10 + 9 = 39
num = 9 / 10 = 0 (end loop)
Here is the output:
Take the first three numbers from your profile (the number of followers or posts) - divide them into numbers. |
---|
I have a total of 180 followers. So I store 180
in below program.
Here is the code:
Explanation:
Hundreds digit: num / 100
For example, 180 / 100 = 1
.
Tens digit: (num % 100) / 10
For example, (180 % 100) / 10 = 80 / 10 = 8
.
Units digit: num % 10
For example, 180 % 10 = 0
.
Here is the output:
Find a four-digit number in your profile (by writing out the first digits, or combining it with others, the first two of one and the first two of another.) Or a random number - the main thing is that it is not in other homework. Divide it into numbers - the first number is X, the second number is X, the third number is X, the fourth number is X |
---|
I choose four digits including the first two digits from my followers and the last two digits from my post.
Explanation:
Thousands:
thousands = num / 1000;
Hundreds:
hundreds = (num % 1000) / 100;
Tens:
tens = (num % 100) / 10;
Units:
units = num % 10;
The numbers have been separated and printed individually on the screen.
Here is the output:
That's all about my task. Thank you so much for staying here. I invite my friends @bossj23, @aviral123, @rumaisha to join the challenge.
X:
https://x.com/AhsanGu58401302/status/1840460059090039238
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Upvoted! Thank you for supporting witness @jswit.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit