Write a program to print prime nums from 1-20 using c
programing?
Answer Posted / rupamrox
#include<stdio.h>
#include<conio.h>
main()
{
int i,j,prime;
clrscr();
for(i=2;i<20;i++)
{
prime=1;
for(j=2;j<i;j++)
{
if(i%j==0)
prime=0;
}
if(prime==1)
printf("%d",i);
}
getch();
}
| Is This Answer Correct ? | 9 Yes | 7 No |
Post New Answer View All Answers
Is there any demerits of using pointer?
any restrictions have on the number of 'return' statements that may be present in a function. a) no restriction b) only 2 return statements c) only 1 return statements d) none of the above
What is difference between Structure and Unions?
What is the difference between printf and scanf in c?
Is the exit() function same as the return statement? Explain.
What does a function declared as pascal do differently?
What is double pointer?
what is the height of tree if leaf node is at level 3. please explain
What is external variable in c?
What is the advantage of an array over individual variables?
How do we make a global variable accessible across files? Explain the extern keyword?
Write a program to replace n bits from the position p of the bit representation of an inputted character x with the one's complement. Method invertBit takes 3 parameters x as input character, p as position and n as the number of positions from p. Replace n bits from pth position in 8 bit character x. Then return the characters by inverting the bits.
What is p in text message?
Why is c so powerful?
How do you redirect a standard stream?