+ 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!
8 Antworten
+ 17
can be possible through 1 loop also
//when i%5==0&&i%2!=0 , then U can do i-=10;
+ 16
no my friend , I am a learner like U only
//we all are on same platform and learning ☺
+ 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.
+ 5
you're welcome.
master gaurav knows better :)
+ 4
that's true. learning all life long! probably the most exciting thing to do (regarding mental satisfaction) :)
+ 3
thank you both for answering and I too believe we're here for the joy of coding and to learn something new!
+ 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
0
<?php
$j=0;
for ($i=5;$i>=1;$i--){
$j=$i*10;
for($k =0;$k<=5;$k++){
echo $j+$k;
}
echo "<br>";
}
?>