You are on page 1of 4

Write a c Program to find the Prime number between 1 and 100

#include<stdio.h>
#include<conio.h>
void main ( )
{
int num, i ;

clrscr ( ) ;
printf(“Enter a Number :”) ;
scanf(“%d”, &num);
i=2;
while(i<=num-1)
{
if (num%i= = 0)
{
printf(“Not a Prime Number”) ;
Break;
}
i ++ ;
}
if (“i = = num”)
printf(“Prime Number”);
getch ( ) ;
}
Write a program which have following output :

01
101
010 1

#include <stdio.h>
#include <conio.h>
void main ( )
{
int i,j,n ;
clrscr ( ) ;
printf (“Enter any number for the output”) ;
scanf (“%d”, &n) ;
for (i = 0 ; i < 6 ; i + +)
{
for (j = 0 ; j < i ; j + +)
{
if ( i % 2 = = 0)
{

printf(“1”) ;
printf(“0”) ;
}
else

printf(“0”) ;
printf (“1”) ;
}
}

printf (“\n”) ;
getch ( ) ;
}
}
Highest Common Factor

#include <stdio.h>
#include <conio.h>
void main ( )
{
int a, b, r, hcf ;
clrscr ( ) ;
printf (“Enter the two +ve Number :”) ;
scanf (“%d%d”, &a, &b) ;
if (a<b)
{
do
{
r=a%b;
a=b;
b=r;
}
While (r !=0);
hcf = a ;
}
else
{
Do
{
r = b %a ;
b=a;
a=r;
}
while (r ! = 0);
hcf = b ;
}
printf (“hcf is %d”, hcf ) ;
getch ( ) ;
}

You might also like