To find factors of a number
Topics Covered:
- To find whether a number is divisible by 2 or 3 or both or non
- To count numbers of employee whose age group is 50 to 60
- To find factors of a number
- to find greatest number among four numbers
//to find whether a number is divisible by 2 or 3 or both or non
#include<conio.h>
#include<stdio.h>
int main()
{
int n;
printf(“enter an integer number\n”);
scanf(“%d”,&n);
if(n%2==0&&n%3==0)
{
printf(“the number is divisible of 2 and 3”);
}
else if(n%2==0)
{
printf(“the number is divisible of 2”);
}
else if(n%3==0)
{
printf(“the number is divisible of 3”);
}
else
{
printf(“the number is not divisible by 2 and 3”);
}
return 0;
}
//to count numbers of employee whose age group is 50 to 60
#include<conio.h>
#include<stdio.h>
int main()
{
int i,n,age,count=0;
printf(“enter no of employees\n”);
scanf(“%d”,&n);
for(i=1;i<=n;i++)
{
printf(“enter age\n”);
scanf(“%d”,&age);
if(age>=50&&age<=60)
{
count++;
}
}
printf(“required no=%d\t”,count);
return 0;
}
//to find factors of a number
#include<conio.h>
#include<stdio.h>
int main()
{
int i,n,f=0;
printf(“enter an integer number\n”);
scanf(“%d”,&n);
for(i=1;i<=n;i++)
{
if(n%i==0)
{
f++;
}
}
printf(“factors=%d”,f);
return 0;
}
//to find greatest number among four numbers
#include<conio.h>
#include<stdio.h>
int main()
{
int g,a,b,c,d;
printf(“enter any four numbers\n”);
scanf(“%d%d%d%d”,&a,&b,&c,&d);
if(a>b&&a>c&&a>d)
{
g=a;
}
else if(b>a&&b>c&&b>d)
{
g=b;
}
else if(c>a&&c>b&&c>d)
{
g=c;
}
else
{
g=d;
}
printf(“greatest number=%d”,g);
return 0;
}