TRENDING NEWS

POPULAR NEWS

C Program Help On Number Divisibility

Where can I find help for coding a program for a poly divisible number in C?

Polydivisible number program is easy. I can tell you how to make it in C++. You can check its logic.#includevoid main(){  int n,m,orig;  POLY:  cout<<"enter 2 digit no. to begin with and no. of digits in the poly digit     no. for n and m respectively";  cin>>n>>m;  if (n%2==0)  {       for (int j=3;j<=m;j++)      {         for (int i=0;i<=9;i++)         {           orig=n;           n=(10*n)+i;           if (n%j==0)           { break;            }           else            {              n=orig;             }         }     }  }cout<<"the result of your polydivisible no. is"<

A c program to print all the numbers divisible by 5 and 7 between 0 to 100.?

#include

int main(int argc, char *argv[])

{

printf("35\n");
printf("70\n");

}



Do you mean "divisible by 5 and 7" or divisible by either 5 or 7?

When you say "between 0 to 100" are you including 0 and 100?

JAVA Program help...Divisible by 5 or 6 but not both?

I need to write a program that displays all numbers from 100 - 200 (10 per line), that are divisible by 5 or 6 but not both. Here is my code, although, I've been hacking away at it for so long, it doesn't even produce results. Any help is appreciated:

import java.util.Scanner;

public class mul56 {
public static void main( String [ ] args ) {

int x = 100;
int y = 200;

int count = 0;

while (x < y) {

int j;
while (count < 10) {
for (j=0; j % 5 == 0 ^ j % 6 == 0; j++) {


System.out.print(x + " ");
count++;
}
}
x++;
}
System.out.println(count);
System.out.println(x);


}

}

Write a program to determine the total numbers divisible by 6 between 1 and 100.?

Try this...

Dim intCount As Integer = 0

For i As Integer = 1 To 100
If i Mod 6 = 0 Then
intCount += 1
End If
Next
Console.WriteLine(intCount)

You didn't say what language so Its VB.net coz that's what i am using today... is easy to rewrite (Mod in VB is the same as % in C++ C# and Java)

What is a 3-digit number not divisible by 2,3,5 or 10?

101 103 107 109 113 127 131 137 139 149 151 157 163 167 173
179 181 191 193 197 199 211 223 227 229 233 239 241 251 257 263 269 271 277 281
283 293 307 311 313 317 331 337 347 349 353 359 367 373 379 383 389 397 401 409
419 421 431 433 439 443 449 457 461 463 467 479 487 491 499 503 509 521 523 541
547 557 563 569 571 577 587 593 599 601 607 613 617 619 631 641 643 647 653 659
661 673 677 683 691 701 709 719 727 733 739 743 751 757 761 769 773 787 797 809
811 821 823 827 829 839 853 857 859 863 877 881 883 887 907 911 919 929 937 941
947 953 967 971 977 983 991 997

Just pick one ; )

Can anyone help me write a C program that can find prime numbers between 1 and 100?

If you simply google your question without the Could anyone help me write a part you would get multiple answers.Some of them:Prime numbers between 1 to 100 in C Programming Language#include
int main(void)
{
for (int i=2; i<100; i++)
{
for (int j=2; j<=i; j++) // Changed upper bound
{
if (i == j) // Changed condition and reversed order of if:s
printf("%d\n",i);
else if (i%j == 0)
break;
}
}
}
C program to print all prime numbers between 1 to n #include int main(){ int i, j, n, isPrime; //isPrime is used as flag variable /* Reads upper limit to print prime */ printf("Find prime numbers between 1 to : "); scanf("%d", &n); printf("\nAll prime numbers between 1 to %d are:\n", n); /* Finds all Prime numbers between 1 to n */ for(i=2; i<=n; i++) { /* Assume that the current number is Prime */ isPrime = 1; /* Check if the current number i is prime or not */ for(j=2; j<=i/2; j++) { /* * If i is divisible by any number other than 1 and self * then it is not prime number */ if(i%j==0) { isPrime = 0; break; } } /* If the number is prime then print */ if(isPrime==1) { printf("%d is Prime number\n", i); } } return 0;}Let this be your homework ;)

Which code in C# should I write to count numbers that are divisible by two?

This question is tricky.Are the numbers generated randomly, or they are always like this: 0 1 2 3 4 5 6… n, with n given? Are they taken from a file, or passed as a parameter in a List, or int[]?All those will change the way you look at the problem.So, if they are 1 2 3 4… n, just return n/2, that’s how many even numbers are.If they are random, you have to verify each number in part.int CountEvenNumbers(List Nums)
{
int counter=0;
for (int i=0;i {
if(Nums[i]%2==0)
{
counter++;
}
}
return counter;
}
This is the example that works every time. With more particular sequences, you can make more optimised algorithms

How do I write a C program that generates odd numbers from 250 to 1000 using the for statement. test to determine, then print (list) each odd number divisible by 5 and compute the average of those odd numbers divisible by 5?

Set a number that is the sum of the number of integers evenly divisible by 5 to zero. Set a number that is equal to the count of integers evenly divisible by 5 to zero. Make a for loop with indices ranging from 251 to 999, with an increment of 2. Inside the for loop, put a statement that indicates the index is an odd integer. Put an if statement inside the for loop that checks if the mod (remainder) of the index divided by 5 is 0. If it is, print the number with a message that it is evenly divisible by 5, set the new sum of the integers evenly divisible by 5 to the previous sum plus this index. Also increment by 1 the variable that is counting the number of such integers evenly divisible by 5. After you close the for loop, divide the number that is the sum of the integers evenly divisible by 5 by the number of these occurrences. This is the average of the integers evenly divisible by 5 in the for loop’s range. Put a print statement that returns this value.Hope this helps and does not mislead or confuse you.

How do I write a C program to check whether a number is even or odd?

The basic idea to check whether the given number is even or odd is whether the given number is divisible by 2 or not.So, let's apply this:void main(){int x;printf("Enter the number: "); scanf("%d",x);if(x%2==0)printf("\n%d is even",x);elseprintf("\n%d is odd",x);}Output:Enter the number: 44 is even

TRENDING NEWS