Write a program to compute and display the sum of all integers that are divisible by 6 but not divisible by 4 and lie between 0 and 100. The program should also count and display the number of such values.
#include <stdio.h>
void main()
{
int i,count=0,sum=0;
clrscr();
for(i=0;i<=100;i++)
{
if(i%6==0&&i%4!=0)
{
count++;
sum=sum+i;
}
}
printf("Sum = %d\nTotal number = %d",sum,count);
getch();
}
#include <stdio.h>
void main()
{
int i,count=0,sum=0;
clrscr();
for(i=0;i<=100;i++)
{
if(i%6==0&&i%4!=0)
{
count++;
sum=sum+i;
}
}
printf("Sum = %d\nTotal number = %d",sum,count);
getch();
}
No comments:
Post a Comment