#include <stdio.h> void main() { int n,i=1,j,c; clrscr(); printf("Enter Number Of Terms"); scanf("%d",&n);
printf("Prime Numbers Are Following");
for(i=1;i<=n;i++)
{ c=0; for(j=1;j<=i;j++) { if(i%j==0) c++; } if(c==2) printf("%d",i); } getch(); }
#include <stdio.h>
int main(int, char*) {
int i, j, breakflag;
for (i = 2; i <= 100; ++i) {
breakflag = 0;
for (j = 2; j < i; ++j) {
if (i % j == 0) {
breakflag = 1;
break;
}
}
if (!breakflag) printf ("%d ", i);
}
printf ("\n");
return 0;
}
It is type-dependent:
for 'int': printf ("%d", prime);
for 'long': printf ("%ld", prime);
for 'long long': printf ("%lld", prime);
PRINT 2,3,5,7,11,13,17,19,23,29,31,37
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.
Without seeing the program, I can only say: 'zero or more times'
#include
find even number in array
Prime numbers are numbers that are only divisible by themselves and the number 1. You can write a program to print all prime numbers from 1 to 100 in FoxPro.
PRINT 2,3,5,7,11,13,17,19,23,29,31,37
This would require some computer knowledge. It can make it easier to find out the prime numbers without figuring it out in your head.
Use a counted loop in the closed range [1:100]. If the count is in the closed range [40:50], print the number. For all other numbers outwith this range, only print the number if it is prime.
c the book mastering c
write a program to print A to Z on screen in c?
You can use int i; for (i = 10; i <= 50; i += 2) {//print i} as a program to print even numbers between 10 and 50.
question clarity
First, create a for loop from a,1 to 50. Inside of that create another for loop b,2 to a-1. If a/b=int(a/b) then you know it is not prime
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.
/*the program to print prime no from 1 to 300*/ #include<stdio.h> #include<conio.h> void main() { int i,j; clrscr(); printf("The prime numbers from 1 to 300 are\n"); for(j=2;j<=300;j++) { for(i=2;i<=j/2;i++) if(j%i==0) break; if(i>j/2) { printf("%d ",j); } } }
Without seeing the program, I can only say: 'zero or more times'