Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions C/Program-61/program.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
This Program calulates all the prime between the range of numbers
includes the numbers which is provided.

For e.g: 2 7
Prime Numbers are : 2 3 5 7
*/

#include <stdio.h>
#include <stdlib.h>

char primecheck(int);

int main()
{
int i,num1,num2,cases;
char ans;
printf("Enter Number of Test Cases: ");
scanf("%d",&cases);
while (cases--)
{
printf("Enter First Number: ");
scanf("%d",&num1);
printf("Enter Second Number: ");
scanf("%d",&num2);

printf("Answer: ");
for(i=num1;i<=num2;i++)
{
ans = primecheck(i);
if (ans == 'y')
printf("%d ",i);
}
printf("\n");
}
return 0;
}

char primecheck(int num)
{
int i;
if (num == 0 || num == 1)
return 'n';
else
{
for(i=(num-1);i>1;i--)
{
if(num%i == 0)
{
return 'n';
}
else
continue;
}
return 'y';
}

}
1 change: 1 addition & 0 deletions C/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
| Program-58 | Program to find the sum of elements between indexes |
| Program-59 | Program to Search Students details in a list |
| Program-60 | Program to print kaprekar number in a given range |
| Program-61 | Program to find the all the prime numbers between the numbers |