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

1) There is a singing competition for children going to be conducted at a local club. Parents have been asked to arrive at least an hour before and register their children’s names with the Program Manager. Whenever a participant registers, the Program Manager has to position the name of the person in a list in alphabet order. Write a program to help the Program Manager do this by placing the name in the right place each time the Program Manger enters a name. The Logic should be written in Data Structures?

2149


what is a function method?give example?

2108


How are Structure passing and returning implemented by the complier?

914


What is selection sort in c?

798


why arguments can generally be passed to functions a) sending the values of the arguments b) sending the addresses of the arguments c) a & b d) none of the above

875


What is register variable in c language?

813


Can we assign string to char pointer?

796


Explain Basic concepts of C language?

821


What is call by reference in functions?

867


What is an arrays?

821


Explain the difference between the local variable and global variable in c?

821


What do you mean by Recursion Function?

845


Should a function contain a return statement if it does not return a value?

806


How do I send escape sequences to control a terminal or other device?

816


What are the 5 types of inheritance in c ++?

755