Write a program to print prime nums from 1-20 using c
programing?
Answers were Sorted based on User's Feedback
#include<stdio.h>
#include<conio.h>
int main()
{
int i,n;
for(n=2;n<=20;n++)
{
for(i=2;i<n;i++)
{if(n%i==0)
break;}
}
if(i==n)
printf("\n %d",n);
return 0;
}
Is This Answer Correct ? | 2 Yes | 5 No |
Answer / musa
#include <stdio.h>
main(){
printf("2 5 7 11 13 17 19");
}
Is This Answer Correct ? | 10 Yes | 14 No |
/* hello i am ricky dobriyal software enginear*/
#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();
}
output:-1 2 3 4 7 11 13 17 19
Is This Answer Correct ? | 18 Yes | 27 No |
What is wild pointer in c?
Write a program that takes a 5 digit number and calculates 2 power that number and prints it
5 Answers ABS, Accenture, HCL, Infosys, Infotech, SoftSolve, Software India, TCS, Vertex, Vimukti Technologies,
What is the difference between #include and #include 'file' ?
give an example of type casting by a simple c program
c program to compute Income tax and Net Salary for its employees. The company offers tax relief of Kshs. 650 for single employees and Kshs. 1,100 for married employees. The relief will be deducted from the Gross salary, to give the taxable income. This will be computed at the following rates: [10mks] Taxable Income Rate (%) <5000 0 5000-19999 6 20000-36999 9 37000 and above 16
Difference between fopen() and open()?
How can I implement opaque (abstract) data types in C? What's the difference between these two declarations? struct x1 { ... }; typedef struct { ... } x2;
I have an array of 100 elements, each of which is a random integer. I want to know which of the elements: a) are multiples of 2 b) are multiples of 2 AND 5 c) have a remainder of 3 when divided by 7
a way in which a pointer stores the address of a pointer which stores the value of the target value a) reference b) allocation c) multiple indirection d) none
Compare and contrast compilers from interpreters.
What are the general description for loop statement and available loop types in c?
How can I find the day of the week given the date?