hi folks
write a c program that will accept 10 integers("99, 80, 50.. something like that...that ranged from 1-100 only, then the machine should determine the value if it is divisible by 3 or not, the program should also determine how many integers were divisible by 3 use for statement.
here's what ive done please help me continue it hehe
#include %26lt;stdio.h%26gt;
main()
{
int a,b,c;
clrscr();
printf("Divisible or not divisible by 3");
printf("Input an integer: ");
scanf("%d", a);
for(a=1;a%26lt;=10;a++)
C Programming "for" statement?
#include %26lt;stdio.h%26gt;
main()
{
int a[10], i, count;
count=0;
clrscr();
printf("Divisible or not divisible by 3");
printf("Input 10 integers: ");
for (i=0;i%26lt;10;i++)
{
scanf("%d", a[i]);
while(a[i]%26lt;=0 || a[i] %26gt;=100)
{
printf("Please enter number 1-100 only\n");
scanf("%d", a[i]);
}
}
for(i=0;i%26lt;10;a++)
{
if(a[i]%3==0)
{
printf("%d is divisble by 3\n", a[i]);
count++;
}
else
printf("%d is divisble by 3\n", a[i]);
}
printf("%d numbers are divisble by 3", count);
Reply:just looking at yours and the 1st answer, scanf()
requires an %26amp;.. scanf("%d",%26amp;a) or scanf("%d",%26amp;a[i])
geranium
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment