Can anyone think of answer for this question? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Can anyone think of answer for this question?

Write a program to print the sequence 50 51 52 53 54 55 40 41 ...14 15. I am trying to solve this but couldn't get exactly what was expected here!

20th Mar 2018, 7:19 AM
Ketan Shukla
Ketan Shukla - avatar
8 Answers
+ 17
can be possible through 1 loop also //when i%5==0&&i%2!=0 , then U can do i-=10;
20th Mar 2018, 10:12 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 16
no my friend , I am a learner like U only //we all are on same platform and learning ☺
20th Mar 2018, 10:31 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 5
the pattern seems to be 50 51 52 53 54 55 40 41 42 43 44 45 . . 10 11 12 13 14 15 maybe a good idea would be to use 2 loops, one for the multiples of 10 (like for I=5; I <=1; I--) and then using that number to construct the series 51 52 53 54 55. something like j=1; j <=5; j++ the number to be printed would be something like num = (I*10)+j I hope that helped.
20th Mar 2018, 8:26 AM
storm
storm - avatar
+ 5
you're welcome. master gaurav knows better :)
20th Mar 2018, 10:29 AM
storm
storm - avatar
+ 4
that's true. learning all life long! probably the most exciting thing to do (regarding mental satisfaction) :)
20th Mar 2018, 10:47 AM
storm
storm - avatar
+ 3
thank you both for answering and I too believe we're here for the joy of coding and to learn something new!
20th Mar 2018, 11:06 AM
Ketan Shukla
Ketan Shukla - avatar
+ 2
#include <stdio.h> int main() { int j=0; for (int i=5;i>=1;i--){ j=i*10; for(int k =0;k<=5;k++){ printf("%d",j+k); } printf("\n"); } return 0; } yes i got it! thank you for answering! above code code gives output as below: 505152535455 404142434445 303132333435 202122232425 101112131415
20th Mar 2018, 8:42 AM
Ketan Shukla
Ketan Shukla - avatar
0
<?php $j=0; for ($i=5;$i>=1;$i--){ $j=$i*10; for($k =0;$k<=5;$k++){ echo $j+$k; } echo "<br>"; } ?>
4th Oct 2019, 11:13 AM
Pooja Patil
Pooja Patil - avatar