Divide Number

Problem 1:

You have been given 3 integers - l, r and k. Find how many numbers between l and r (both inclusive) are divisible by k. You do not need to print these numbers, you just have to find their count.

Input Format
The first and only line of input contains 3 space separated integers
lr and k.

Output Format
Print the required answer on a single line.

SAMPLE INPUT
1 10 1
SAMPLE OUTPUT
10
Source Code:
#include <stdio.h>  
 int main()  
 {int l,r,k,i,count;  
   scanf("%d ",&l);  
   scanf("%d ",&r);  
   scanf("%d ",&k);  
  for (i=l;i<=r;i++){  
       if(i%k==0){  
       count++;       
       }   
       else count = count;  
  }  
  printf("%d",count);  
 }  

Comments

Popular posts from this blog

Find Product ! Hacker Earth

Seating Arrangement

Roy and Profile picture