#include<stdio.h>
int main()
{
int i=1,j,count,n;
printf("enter number range\n");
scanf("%d", &n);
printf("following numbers are prime numbers:\t");
while(i<=n)
{
j=1;
count=0;
while(j<=n)
{
if(i%j==0)
{
count++;
}
j++;
}
if(count==2)
{
printf("%d\t", i);
}
i++;
}
return 0;
}
Oh, what a lovely request! In FoxPro, you can create a program to print all prime numbers from 1 to 100 by using a loop to check each number for divisibility only by 1 and itself. If it meets this criteria, you can print it out on the screen. Remember, every number is unique and special, just like a happy little tree in a vast forest.
I suggest you write an outer loop, that loops through all the numbers from 1 to 50. Call the variable that controls the loop something like "number".Then, initially assume the number is a prime (with a variable such as "isprime"); and write another loop that compares whether the number is divisible by any number from 2 to number-1. Call the controlling variable "factor". If number is divisible by factor, then it is not a prime, and you can exit the loop. At the end of the inner loop, if the variable "isprime" is still true, then you print the number.
To write a BASIC program that checks if an input number is prime or composite, you can use a loop to test divisibility. First, prompt the user for a number and then check if it's less than 2 (which is neither prime nor composite). For numbers greater than 1, iterate from 2 to the square root of the number, checking if it divides evenly (using the modulus operator). If you find a divisor, the number is composite; otherwise, it's prime. Here's a simple example: INPUT "Enter a number: ", N IF N < 2 THEN PRINT "Neither prime nor composite": END IS_PRIME = TRUE FOR I = 2 TO SQR(N) IF N MOD I = 0 THEN IS_PRIME = FALSE EXIT FOR END IF NEXT I IF IS_PRIME THEN PRINT N; " is prime" ELSE PRINT N; " is composite"
Private Sub Command1_Click() Dim I, N As Integer N = Val(Text1.Text) For I = 2 To N - 1 If N Mod I = 0 Then Print "THE NUMBER IS NOT A PRIME NUMBER" Exit Sub End If Next I Print "THE NUMBER IS A PRIME NUMBER" End Sub Private Sub Command2_Click() Text1.Text = "" Text1.SetFocus End Sub Private Sub Command3_Click() End End Sub
This would require some computer knowledge. It can make it easier to find out the prime numbers without figuring it out in your head.
Oh, what a lovely request! In FoxPro, you can create a program to print all prime numbers from 1 to 100 by using a loop to check each number for divisibility only by 1 and itself. If it meets this criteria, you can print it out on the screen. Remember, every number is unique and special, just like a happy little tree in a vast forest.
Q.1 Write a program to print first ten odd natural numbers. Q.2 Write a program to input a number. Print their table. Q.3 Write a function to print a factorial value.
I suggest you write an outer loop, that loops through all the numbers from 1 to 50. Call the variable that controls the loop something like "number".Then, initially assume the number is a prime (with a variable such as "isprime"); and write another loop that compares whether the number is divisible by any number from 2 to number-1. Call the controlling variable "factor". If number is divisible by factor, then it is not a prime, and you can exit the loop. At the end of the inner loop, if the variable "isprime" is still true, then you print the number.
write a program to print A to Z on screen in c?
To write a BASIC program that checks if an input number is prime or composite, you can use a loop to test divisibility. First, prompt the user for a number and then check if it's less than 2 (which is neither prime nor composite). For numbers greater than 1, iterate from 2 to the square root of the number, checking if it divides evenly (using the modulus operator). If you find a divisor, the number is composite; otherwise, it's prime. Here's a simple example: INPUT "Enter a number: ", N IF N < 2 THEN PRINT "Neither prime nor composite": END IS_PRIME = TRUE FOR I = 2 TO SQR(N) IF N MOD I = 0 THEN IS_PRIME = FALSE EXIT FOR END IF NEXT I IF IS_PRIME THEN PRINT N; " is prime" ELSE PRINT N; " is composite"
write a program that reads a phrase and prints the number of lowercase latters in it using a function for counting? in C program
echo 'print a pattern'
i want to write a simple without using pointer or array c program which will print greatest number when i give 20 number .........How far have you gotten so far?
Private Sub Command1_Click() Dim I, N As Integer N = Val(Text1.Text) For I = 2 To N - 1 If N Mod I = 0 Then Print "THE NUMBER IS NOT A PRIME NUMBER" Exit Sub End If Next I Print "THE NUMBER IS A PRIME NUMBER" End Sub Private Sub Command2_Click() Text1.Text = "" Text1.SetFocus End Sub Private Sub Command3_Click() End End Sub
10 input "enter a no."; n 20 for i = 1 to n 30 if n mod i = 0 then c = c +1 40 next i 50 if c = 2 then print "prime number" else print "not a prime number" 60 end
This would require some computer knowledge. It can make it easier to find out the prime numbers without figuring it out in your head.
Begin Read num for(i=2; i<num; i++) if(num%2==0) then print "the number is not a prime no."; else if print "the number is prime"; end if Stop