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

Answer Posted / r@m$

#include<stdio.h>
void main(){
int x;
for(x=2;x<=20;x++){
if(x<4)
printf("%d\t",x);
else
if(x%2!=0 && x%3!=0)
printf("%d\t",x);
}
}

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the benefit of using #define to declare a constant?

601


Why does everyone say not to use scanf? What should I use instead?

678


How can I make sure that my program is the only one accessing a file?

674


What is an lvalue?

632


Is sizeof a keyword in c?

574






Why c is called top down?

626


Explain what’s a signal? Explain what do I use signals for?

606


Describe explain how arrays can be passed to a user defined function

599


What is the code in while loop that returns the output of given code?

1305


Explain what standard functions are available to manipulate strings?

610


Is using exit() the same as using return?

671


What is 1f in c?

1833


What's the total generic pointer type?

610


How was c created?

586


the factorial of non-negative integer n is written n! and is defined as follows: n!=n*(n-1)*(n-2)........1(for values of n greater than or equal to 1 and n!=1(for n=0) Perform the following 1.write a c program that reads a non-negative integer and computes and prints its factorial. 2. write a C program that estimates the value of the mathematical constant e by using the formula: e=1+1/!+1/2!+1/3!+.... 3. write a c program the computes the value ex by using the formula ex=1+x/1!+xsquare/2!+xcube/3!+....

22203