Write a program to print prime nums from 1-20 using c
programing?
Answer Posted / ruth
#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();
}
| Is This Answer Correct ? | 18 Yes | 3 No |
Post New Answer View All Answers
Explain what is the concatenation operator?
What is a pointer value and address in c?
How can I prevent another program from modifying part of a file that I am modifying?
Subtract Two Number Without Using Subtraction Operator
Why pointers are used in c?
How can you return multiple values from a function?
Why #include is used in c language?
What is the purpose of the following code? Is there any problem with the code? void send(int count, short *to, short *from) { /* count > 0 assumed */ register n = (count + 7) / 8; switch (count % 8) { case 0: do { *to = *from++; case 7: *to = *from++; case 6: *to = *from++; case 5: *to = *from++; case 4: *to = *from++; case 3: *to = *from++; case 2: *to = *from++; case 1: *to = *from++; } while (--n > 0); } }
explain what is an endless loop?
Describe static function with its usage?
What is meant by int main ()?
What is the difference between exit() and _exit() function in c?
I have seen function declarations that look like this
Find duplicates in a file containing 6 digit number (like uid) in O (n) time.
Explain what are global variables and explain how do you declare them?