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

What does c in a circle mean?

601


What does sizeof int return?

606


What are the keywords in c?

659


what are the program that using a two dimensional array that list the odd numbers and even numbers separately in a given 10 inputs values

1276


how to build a exercise findig min number of e heap with list imlemented?

1630






How can I display a percentage-done indication that updates itself in place, or show one of those twirling baton progress indicators?

603


Why static variable is used in c?

580


What tq means in chat?

607


why we wont use '&' sing in aceesing the string using scanf

1797


Explain argument and its types.

624


the process of defining something in terms of itself is called (or) in C it is possible for the functions to call themselves. A function called a) nested function b) void function c) recursive function d) indifinite function

787


What kind of structure is a house?

574


What does a derived class inherit from a base class a) Only the Public members of the base class b) Only the Protected members of the base class c) Both the Public and the Protected members of the base class d) .c file

679


write a c program for swapping two strings using pointer

2112


How to write c functions that modify head pointer of a linked list?

558