Skip to main content

Program to find prime numbers between 1 and 50

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

void main()
{
   int i, n=1, count;

   clrscr();
   printf("\nPrime numbers between 1 and 50\n");

   while(n<=50)
   {
      count=0;
      for (i=2; i<=n/2; i++)
      {
if(n%i==0)
{
    count++;
    break;
}
      }

      if (count==0)
      {
printf("\n%d",n);
      }
      n++;
   }
   getch();
}

OUTPUT

Prime numbers between 1 and 50

1
2
3
5
7
11
13
17
19
23
29
31
37
41
43
47

Comments

Popular posts from this blog

Creating a Realtime Clock using Python program

Clock from turtle import * from datetime import datetime def jump(distanz, winkel=0):     penup()     right(winkel)     forward(distanz)     left(winkel)     pendown() def hand(laenge, spitze):     fd(laenge*1.15)     rt(90)     fd(spitze/2.0)     lt(120)     fd(spitze)     lt(120)     fd(spitze)     lt(120)     fd(spitze/2.0) def make_hand_shape(name, laenge, spitze):     reset()     jump(-laenge*0.15)     begin_poly()     hand(laenge, spitze)     end_poly()     hand_form = get_poly()     register_shape(name, hand_form) def clockface(radius):     reset()     pensize(7)     for i in range(60):         jump(radius)         if i % 5 == 0:           ...

Inserting,Deleting and Updating table values in Database using Python Programming

Insert,Delete and Update import tkinter as tk from tkinter import * import mysql.connector import datetime def IsValidDate(InputDate):     day = InputDate[:2]     month = InputDate[3:5]     year = InputDate[6:]         IsValid = True         try :         datetime.datetime(int(year),int(month),int(day))     except ValueError :         IsValid = False     return IsValid def FormatDBDate(InputDate):     dt = InputDate[6:] + "-" + InputDate[3:5] + "-" + InputDate[:2]     return dt    def FormatEDDate(InputDate):     dt =  InputDate[8:] + "/" + InputDate[5:7] + "/" + InputDate[:4]     return dt  def DeleteEmployee(id, eid, ename, dob, doj, adr, cty, pcd, mob, eml, gen, dep):     conn=mysql.connector.connect(user='root',password='harsha',host='localhost', datab...

Palindrome of a given number using C

#include<stdio.h> #include<conio.h> void main() {    long n, r, ri=0, oi;    clrscr();    printf("\nEnter a number: ");    scanf("%ld",&n);    oi = n;    while(oi!=0)    {       ri = ri * 10;       ri = ri + oi % 10;       oi = oi / 10;    }    if(n==ri)    {       printf("\nThe given number is a Palindrome");    }    else    {       printf("\nThe given number is not a palindrome");    }    getch(); } Output: Enter a number: 1221 The given number is a Palindrome Output: Enter a number: 953212359 The given number is a Palindrome