write the program for prime numbers?

Answer Posted / nandhini

#include<stdio.h>
int main()
{
int i,j,n,count=0;
printf("Enter the number:");
scanf("%d",&n);
for(i=2;i<=n;i++)
{
for(j=2;j<=i;j++)
{
if(i%j==0 && i/1==i)
{
count=count+1;
}
}
if(count==1)
{
printf("\n%d",i);
}
count=0;
}
}

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 difference between far and near ?

691


An application package has been provided to you without any documents for the following application. The application needs to be tested. How will you proceed?

676


Can we assign integer value to char in c?

619


Why static is used in c?

627


Which are low level languages?

640






List some of the dynamic data structures in C?

794


Why can’t constant values be used to define an array’s initial size?

840


Do variables need to be initialized?

623


write an interactive C program that will encode or decode a line of text.To encode a line of text,proceed as follows. 1.convert each character,including blank spaces,to its ASCII equivalent. 2.Generate a positive random integer.add this integer to the ASCII equivalent of each character.The same random integer will be used for the entire line of text. 3.Suppose that N1 represents the lowest permissible value in the ASCII code,and N2 represents the highest permissible value.If the number obtained in step 2 above(i.e.,the original ASCII equivalent plus the random integer)exceeds N2,then subtract the largest possible multiple of N2 from this number,and add the remainder to N1.Hence the encoded number will always fall between N1 and N2,and will therefore always represent some ASCII character. 4.Dislay the characters that correspond to the encoded ASCII values.  The procedure is reversed when decoding a line of text.Be certain,however,that the same random number is used in decodingas was used in encoding.

2725


What should malloc(0) do? Return a null pointer or a pointer to 0 bytes?

595


what is the different bitween abap and abap-hr?

1745


What is a dynamic array in c?

599


What is the difference between struct and typedef struct in c?

663


Is c language still used?

540


What is difference between scanf and gets?

616