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 |
Define function pointers?
Array is an lvalue or not?
What are types of structure?
Why do we need functions in c?
What is meant by initialization and how we initialize a variable?
What's the best way of making my program efficient?
how can i get the string which is having two spaces at the end.suppose the string is "Hello World ".Now at the end i have two spaces.i need to print with that spaces .
Write a C program to perform some of the operation which can be performed using Single linked list
"%u" unsigned integer print the a) address of variable b) value of variable c) name of a variable d) none of the above
Explain setjmp()?
Discuss the function of conditional operator, size of operator and comma operator with examples.
what is the difference between char * const and const char *?