Divisible Numbers in given Range coderinme

Divisible Numbers in given Range coderinme

Divisible Numbers in given Range coderinme
Finding all the numbers in a given range manually would be very hectic, frustrating as well as a time taking process. To make it simple Let us now write a program in C that reads read 3 integers namely start, end and number in the main program. The main program will pass these 3 three integers to a function sub program that uses for loop to find those integers between start and end that are divisible by the given number. If it finds the numbers it prints them in the function only. Here the function is not returning anything. Please Make note that here Divisibility means means giving a remainder of zero .

#include<stdio.h>
int func(int a,int b,int c)
{
int i;
for(i = a ; i <= b ; i++)
{
if(i % c == 0)
{
printf("%d,",i);
}
}
}
int main()
{
int start,end,number;
printf("\nEnter the START number: ");
scanf("%d",&start);
printf("Enter the END number: ");
scanf("%d",&end);
printf("Please input the NUMBER: ");
scanf("%d",&number);
printf("\nNumbers starting with %d and ending with %d and divisible by %d are: \n",start,end,number);
func(start,end,number);
getch();
return 0;
}

For more programs in C, visit our C Coder Archives

Divisible Numbers in given Range coderinme

All rights reserved. No part of this Post may be copied, distributed, or transmitted in any form or by any means, without the prior written permission of the website admin, except in the case of brief quotations embodied in critical reviews and certain other noncommercial uses permitted by copyright law. For permission requests, write to the owner, addressed “Attention: Permissions Coordinator,” to the admin @coderinme

Leave a reply:

Your email address will not be published.