Thursday, 27 March 2014

Write a C program to find the number of and sum of all integers greater than 100 and less than 200 that are divisible by a given integer x.

#include<stdio.h>
main()
{
int i,con=0,sum=0,num;
printf("Enter a number=");
scanf("%d",&num);
for(i=100;i<=200;i++)
{
if(i%num==0)
{
con++;
sum=sum+i;
}
}
printf("\nNumber of integers=%d\n",con);
printf("\nSum of integers=%d\n",sum);
}

No comments:

Post a Comment