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

Answer Posted / dinesh

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

Is This Answer Correct ?    46 Yes 21 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

can anyone please tell about the nested interrupts?

1670


What is meant by inheritance?

622


What’s a signal? Explain what do I use signals for?

599


What does a derived class inherit from a base class a) Only the Public members of the base class b) Only the Protected members of the base class c) Both the Public and the Protected members of the base class d) .c file

657


What is sizeof int?

629






What are Macros? What are its advantages and disadvantages?

634


How can I direct output to the printer?

806


Find duplicates in a file containing 6 digit number (like uid) in O (n) time.

2589


What is meant by gets in c?

602


What are compound statements?

622


What is the explanation for cyclic nature of data types in c?

640


What do you mean by scope of a variable in c?

538


What are the c keywords?

742


What are lookup tables in c?

544


What is NULL pointer?

671