Write a program to print prime nums from 1-20 using c
programing?

Answer Posted / rupamrox

#include<stdio.h>
#include<conio.h>
main()
{
int i,j,prime;
clrscr();
for(i=2;i<20;i++)
{
prime=1;
for(j=2;j<i;j++)
{
if(i%j==0)
prime=0;
}
if(prime==1)
printf("%d",i);
}
getch();
}

Is This Answer Correct ?    9 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

If fflush wont work, what can I use to flush input?

836


Write a program to generate the Fibinocci Series

861


Can you please explain the difference between syntax vs logical error?

905


what do u mean by Direct access files? then can u explain about Direct Access Files?

1830


write a progrmm in c language take user interface generate table using for loop?

1784


Explain the advantages of using macro in c language?

756


Is there anything like an ifdef for typedefs?

880


c language interview questions & answer

1681


if a is an integer variable, a=5/2; will return a value a) 2.5 b) 3 c) 2 d) 0

1692


Explain the concept and use of type void.

851


how is the examination pattern?

1783


What is c token?

824


What is the heap in c?

834


What is the default value of local and global variables in c?

752


What tq means in chat?

830