0% found this document useful (0 votes)
26 views1 page

Program 1

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

Program 1

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

#include <stdio.

h>
int main()
{
int a;
printf("Press 1 to find divisors of a number:");
printf("\n");
printf("Press 2 to find factorial of a number:");
printf("\n");
printf("Enter your choice:");
scanf("%d",&a);
if(a<1&&a>2)
{
printf("Wrong choice entered:");
}
switch(a)
{
case 1:
int n;
printf("Enter the number whose divisor is to be found:");
scanf("%d",&n);
printf("Divisors of the given number are:");
for(int i=1;i<=n;i++)
{
if(n%i==0)
{
printf(",%d",i);
}
}
break;

case 2:
int x;
int fact=1;
printf("Enter a number whose factorial is to be found:");
scanf("%d",&x);
for(int i=1;i<=x;i++)
{
fact=fact*i;
}
printf("Factoria of given number is : %d",fact);
break;

default:
printf("wrong choice");
break;
}
return 0;
}

You might also like