Hello can you help me how to program in c (loop) that the given number is 1-100 but not divisible by 5 thanks | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Hello can you help me how to program in c (loop) that the given number is 1-100 but not divisible by 5 thanks

1st May 2018, 5:29 AM
Rise
Rise - avatar
4 Answers
+ 1
1) for (i=1;i<n;++i) if (i%5){ .... } 2) for (q=0;q<(n/5);q+=5){ m=n-q>4?5:n-q; for (r=1;r<m;++r){ n=q+r; ..... }}
1st May 2018, 6:45 AM
VcC
VcC - avatar
+ 1
Since VcC is giving away answers, here's what I was talking about. for ( int i = 1; i <= 100; ++i) { if (i % 5 != 0) printf(i); }
1st May 2018, 1:19 PM
Zeke Williams
Zeke Williams - avatar
0
Here's a hint. If a number IS divisible by 5, the remainder of that number divided by 5 should be zero. See if you can get it using the % operator and the ! operator.
1st May 2018, 5:42 AM
Zeke Williams
Zeke Williams - avatar
0
can anyone give a sample program thanks
1st May 2018, 5:48 AM
Rise
Rise - avatar