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
Tell us bitwise shift operators?
What is %s and %d in c?
What is typedef?
Explain what is the most efficient way to store flag values?
Write a program to maintain student’s record. Record should
not be available to any unauthorized user. There are three
(3) categories of users. Each user has its own type. It
depends upon user’s type that which kind of operations user
can perform. Their types and options are mentioned below:
1. Admin
(Search Record [by Reg. No or Name], View All Records,
Insert New Record, Modify Existing Record)
2. Super Admin
(Search Record [by Reg. No or Name], View All Records,
Insert New Record, Modify Existing Record, Delete Single Record)
3. Guest
(Search Record [by Reg. No or Name], View All Records)
When first time program runs, it asks to create accounts.
Each user type has only 1 account (which means that there
can be maximum 3 accounts). In account creation, following
options are required:
Login Name: <6-10 alphabets long, should be unique>
Password: <6-10 alphabets long, should not display
characters when user type>
Confirm Password:
What is the function of this pointer?
How do I determine whether a character is numeric, alphabetic, and so on?
What are the advantages of using Unions?
What is difference between static and global variable in c?
What language is lisp written in?
Why we use void main in c?
What is a scope resolution operator in c?
What does c mean in standard form?
What is a null string in c?
Explain why can’t constant values be used to define an array’s initial size?