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

Answer Posted / sreejesh1987

//Ha Ha I'm the creator of shortest code
//for prime numbers
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j;
clrscr();
printf("\t\t\tPRIME NUMBERS 1-20\n");
printf("\n\t2");
for(i=3;i<=20;i++)
for(j=2;j<i,i%j!=0;j++)
if(i-1==j)
printf("\n\t%d",i);
getch();
}

Is This Answer Correct ?    6 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain what is meant by 'bit masking'?

638


What is the time and space complexities of merge sort and when is it preferred over quick sort?

668


Write a c program to demonstrate character and string constants?

1676


What are types of structure?

600


What is the purpose of scanf() and printf() functions?

711






What are header files and explain what are its uses in c programming?

603


What are operators in c?

575


What are header files in c?

610


How can I get the current date or time of day in a c program?

647


What is the auto keyword good for?

616


Why malloc is faster than calloc?

583


What is the difference between constant pointer and constant variable?

741


Write a program to identify if a given binary tree is balanced or not.

678


write a program in C that prompts the user for today's date,tomorrow's date and display the results.Use structures for today's date,tomorrow's date and an array to hold the days for each month of the year.

4975


What is %d used for?

580