Write a program to print prime nums from 1-20 using c
programing?
Answers were Sorted based on User's Feedback
#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 |
Answer / musa
#include <stdio.h>
main(){
printf("2 5 7 11 13 17 19");
}
Is This Answer Correct ? | 10 Yes | 14 No |
/* 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 |
to convert a string without using decrement operater and string functions
Explain can you assign a different address to an array tag?
how can I convert a string to a number?
In C, What is the #line used for?
a value that does not change during program execution a) variabe b) argument c) parameter d) none
what are the advantage and disadvantage of recursion
can we access one file to one directory?
wap in c to accept n number display the highest and lowest value
Convert a distance from miles to kilometers .there are 5280 feets per mile,12 inches per foot .2.54 centimeters per inch and 100000centimeters per kilometer
#include <stdio.h> void main() { int i=-1,j=1,k,l; k=!i&&j; l=!i||j; printf ("%d%d",k,l) ; }
Why c is a mother language?
what would be the output of the following program main() { int a[] = {1,2,3,4,5}; int *ptr = {a,a+1,a+2,a+3,a+4}; printf("%d %d %d %d",a,*ptr,**ptr,ptr); } }