write a Program to dispaly upto 100 prime numbers(without
using Arrays,Pointer)

Answer Posted / paras patel

#include <stdio.h>
#include <conio.h>

int divide(int x ,int y)
{
while(x>y)
{
x-=y;
}

if(x==y)
{
x=0;
}
return x;

}

void main()
{
int c,i,n;
scanf("%d",&n);
clrscr();
for( i=2;i<=n;i++)
{
if(divide(n,i)==0)
{
break;
}

}
if(i!=n)
{
printf("not prime");
}
else
{
printf("prime");
}




getch();
}

Is This Answer Correct ?    16 Yes 17 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain what is the difference between a string copy (strcpy) and a memory copy (memcpy)? When should each be used?

614


Given two strings S1 and S2. Delete from S2 all those characters which occur in S1 also and finally create a clean S2 with the relevant characters deleted.

844


The purpose of this exercise is to benchmark file writing and reading speed. This exercise is divided into two parts. a). Write a file character by character such that the total file size becomes approximately >10K. After writing close the file handler, open a new stream and read the file character by character. Record both times. Execute this exercise at least 4 times b). Create a buffer capable of storing 100 characters. Now after generating the characters, first store them in the buffer. Once the buffer is filled up, store all the elements in the file. Repeat the process until the total file size becomes approximately >10K.While reading read a while line, store it in buffer and once buffer gets filled up, display the whole buffer. Repeat the exercise at least 4 times with different size of buffer (50, 100, 150 …). Records the times. c). Do an analysis of the differences in times and submit it in class.

1641


What is dynamic dispatch in c++?

569


What is c variable?

563






Should I learn c before c++?

651


What is function prototype?

620


Are pointers integers in c?

619


What is nested structure in c?

622


What is the best way of making my program efficient?

575


Explain the advantages and disadvantages of macros.

634


How to write a code for implementing my own printf() and scanf().... Please hep me in this... I need a guidance... Can you give an coding for c... Please also explain about the header files used other than #include...

4914


What is table lookup in c?

641


i got 75% in all semester am i eligible for your company

1749


How can I sort a linked list?

645