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

Answers were Sorted based on User's Feedback



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

Answer / ankur mohan sharma

#include<stdio.h>
#include<conio.h>
int main()
{
int i,n;
for(n=2;n<=20;n++)
{
for(i=2;i<n;i++)
{if(n%i==0)
break;}
}
if(i==n)
printf("\n %d",n);
return 0;

}

Is This Answer Correct ?    2 Yes 5 No

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

Answer / musa

#include <stdio.h>
main(){
printf("2 5 7 11 13 17 19");
}

Is This Answer Correct ?    10 Yes 14 No

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

Answer / 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

More C Interview Questions

What is the difference between realloc() and free()

1 Answers  


write a program fibonacci series and palindrome program in c

0 Answers   Aditi Placement Service,


how to compare two strings without using strcmp() function??

1 Answers  


what type of questions arrive in interview over c programming?

0 Answers  


What is a c token and types of c tokens?

0 Answers  






Which are low level languages?

0 Answers  


in any language the sound structure of that language depends on its a) character set, input/output function, its control structures b) character set, library functions, input/output functions its control structures c) character set, library functions, control sturctures d) character set, operators, its control structures

0 Answers  


Go through the following code sinippet char a[20]; a="Hello Orcale Test"; will this compile?

4 Answers   Oracle,


What is the difference between fread buffer() and fwrite buffer()?

0 Answers  


What are actual arguments?

0 Answers  


#include<stdio.h> void main() { int =1; printf("%d%d%d",a++,++a,++a); }

3 Answers   VB,


Is c functional or procedural?

1 Answers  


Categories