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
Write a program to identify if a given binary tree is balanced or not.
How was c created?
What is #pragma statements?
What is calloc()?
What is adt in c programming?
What are register variables in c?
Ow can I insert or delete a line (or record) in the middle of a file?
Explain what are binary trees?
What are qualifiers in c?
What’s a signal? Explain what do I use signals for?
How can I implement sets or arrays of bits?
explain how do you use macro?
What is the default value of local and global variables in c?
How can I swap two values without using a temporary?
What is wrong in this statement?