0% found this document useful (0 votes)
27 views5 pages

Output-Enter Number-2 Even No Is-2

The document contains code for 3 programs: 1) A program to check if a number is odd or even. It takes user input, uses the modulo operator to check for evenness, and prints the result. 2) A program to calculate the factorial of a given number. It takes input, initializes variables, uses a while loop and multiplication to calculate the factorial, and prints the result. 3) A program to check if a number is prime. It takes input, initializes variables, uses a while loop and modulo to check for factors, and prints if the number is prime or not.

Uploaded by

Kundan Tiwary
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views5 pages

Output-Enter Number-2 Even No Is-2

The document contains code for 3 programs: 1) A program to check if a number is odd or even. It takes user input, uses the modulo operator to check for evenness, and prints the result. 2) A program to calculate the factorial of a given number. It takes input, initializes variables, uses a while loop and multiplication to calculate the factorial, and prints the result. 3) A program to check if a number is prime. It takes input, initializes variables, uses a while loop and modulo to check for factors, and prints if the number is prime or not.

Uploaded by

Kundan Tiwary
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

10)PROGARAM TO CHECK WHETHER A

NUMBER IS ODD OR EVEN


#include<stdio.h>

#include<conio.h>

void main()

clrscr();

int num;

printf(enter number);

scanf(%d,&num);

if(num%2==0)

printf(even num is %d,num);

else

printf(odd num is %d,num);

getch();

OUTPUT-
Enter number-2
Even no is-2
11)PROGRAM TO FIND FACTORIAL OF A
GIVEN NUMBER
#include<stdio.h>

#include<conio.h>

void main()

clrscr();

int a,i=1,f=1;

printf( Enter a number);

scanf(%d,&a);

while(i<=a)

f=f*i;

i++;

printf( the factorial is %d,f);

getch();

OUTPUT-
Enter number-
Factorial is-
12)PROGRAM TO CHECK WHETHER THE
NUMBER IS PRIME OR NOT
#include<stdio.h>

#include<conio.h>

void main()

clrscr();

int num,i=2,count=0;

printf(Enter a number);

scanf(%d,&num);

while(i<num)

if(num%i==0)

count++;

i++;

break;

if(count=0)

printf(the number is prime);

else

printf(the number is not prime);

getch();

OUTPUT-
Enter number-

You might also like