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
What is the scope of static variable in c?
Explain is it valid to address one element beyond the end of an array?
What is a wrapper function in c?
What is d scanf?
What is actual argument?
What is the purpose of main() function?
Explain continue keyword in c
Explain the difference between getch() and getche() in c?
Write a program to print all permutations of a given string.
You are to write your own versions of strcpy() and strlen (). Call them mystrcpy() and mystrlen(). Write them first as code within main(), not as functions, then, convert them to functions. You will pass two arrays to the function in the case of mystrcpy(), the source and target array.
What is the difference between formatted&unformatted i/o functions?
What is the difference between array_name and &array_name?
What is meant by type specifiers?
What functions are used for dynamic memory allocation in c language?
Hai sir, I had planned to write the NIC scientific engineer exam , plz post the sample question......