To print a multiplication table any given number up to 10 multiples
Topics Covered:
- To read salary of 100 employees and counts the salary group 30000 to 45000
- To read the age of n numbers of students and find the average age
- To check whether a given number is prime or composite
- To print a multiplication table any given number up to 10 multiples
- To count number of employees whose age group is 50 to 60 on the basis of age of n numbers
//to read salary of 100 employees and counts the salary group 30000 to 45000
#include<conio.h>
#include<stdio.h>
int main()
{
int i,s,count=0;
for(i=1;i<=100;i++)
{
printf(“enter your salary\n”);
scanf(“%d”,&s);
if(s>=30000&&s<=45000)
{
count++;
}
}
printf(“required number=%d”,count);
return 0;
}
/*to read the age of n numbers of students and find the average age*/
#include<conio.h>
#include<stdio.h>
int main()
{
int i,n,sum=0,age;
float avg;
printf(“enter number of students\n”);
scanf(“%d”,&n);
for(i=1;i<=n;i++);
{
printf(“enter age\n”);
scanf(“%d”,&age);
sum=sum+age;
}
avg=(float)sum/n;
printf(“average age=%2.f”,avg);
return 0;
}
//to check whether a given number is prime or composite
#include<conio.h>
#include<stdio.h>
int main()
{
int i,n,f=0;
printf(“enter an integer number greater than 1\n”);
scanf(“%d”,&n);
for(i=1;i<=n;i++)
{
if(n%i==0)
{
f++;
}
}
if(f==2)
{
printf(“it is a prime number”);
}
else
{
printf(“it is a composite number”);
}
return 0;
}
/*to print a multiplication table any given number up to 10 multiples*/
#include<conio.h>
#include<stdio.h>
int main()
{
int i,n;
printf(“enter an integer number\n”);
scanf(“%d”,n);
for(i=1;i<=10;i++)
{
printf(“%dx%d=%d\n”,n,i,n*i);
}
return 0;
}
/*to count number of employees whose age group is
50 to 60 on the basis of age of n numbers*/
#include<conio.h>
#include<stdio.h>
int main()
{
int i,age,n,count=0;
printf(“enter number of employees\n”);
scanf(“%d”,&n);
for(i=1;i<=n;i=i+1)
{
printf(“enter age\n”);
scanf(“%d”,&age);
if(age>=50&&age<=60)
{
count ++;
}
}
printf(“required number=%d”,count);
return 0;
}