Write a program to print prime nums from 1-20 using c
programing?
Answer Posted / ricky dobriyal
/* hello i am ricky dobriyal software enginear*/
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,s;
printf("prime number 1 to 20 :\n");
for(i=1;i<=20;i++)
{
s=0;
for(j=2;j<i;j++)
{
if(i==1)
s=0;
else if(i%j==0)
s=1;
}
if(s==0)
printf("%d\t",i);
}
getch();
}
output:-1 2 3 4 7 11 13 17 19
| Is This Answer Correct ? | 18 Yes | 27 No |
Post New Answer View All Answers
main() { printf("hello"); fork(); }
Explain the advantages of using macro in c language?
Q.1 write aprogram to stack using linklist o insert 40 items? Q.2 write a program to implement circular queue with help of linklist?
How many identifiers are there in c?
Can we access the array using a pointer in c language?
A character flag or control mechanism that delineates one data item from another a) variable b) constant c) delimiter d) call by reference
Why & is used in c?
What is a good way to implement complex numbers in c?
Is a house a mass structure?
Should a function contain a return statement if it does not return a value?
What is #line in c?
Explain how can type-insensitive macros be created?
What are runtime error?
What are # preprocessor operator in c?
What is the sizeof () operator?