Saturday, 5 March 2022

11. Write a program to print all the prime numbers ranging from 50 to 100.


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

void main()
{
    int i,j,prime=0;
    clrscr();

    printf("all the prime numbers raning from 50 to 100\n\n");

    for(i=50; i<=100; i++)
    {
        prime = 0;
        for(j=1; j<=i; j++)
        {
            if(i % j == 0)
            {
                prime++;
            }
        }
        if(prime == 2)
        {
            printf("%d ",i);
        }
    }
    getch();
}

/*      output:

all the prime numbers raning from 50 to 100

53 59 61 67 71 73 79 83 89 97

*/ 

No comments:

Post a Comment

python programs

1. sum of two number