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
Explain the difference between null pointer and void pointer.
Write a factorial program using C.
can any one provide me the notes of data structure for ignou cs-62 paper
Describe the modifier in c?
what is a function method?give example?
What are bitwise shift operators in c programming?
Can you explain what keyboard debouncing is, and where and why we us it? please give some examples
What are structural members?
write a c program to do the following: a) To find the area of a triangle. b) To convert the temperature from Fahrenheit to Celsius. c) To convert the time in hours : minutes : seconds to seconds.
Which is better pointer or array?
Explain can static variables be declared in a header file?
What is the difference between far and near in c?
What are variables and it what way is it different from constants?
What is a 'null pointer assignment' error?
List at least 10 sorting methods indicating their average case complexity, worst case complexity and best case complexity.