To find prime numbers from 1 to 100
Topics Covered:
- To reads the cost of a pen in paisa and convert it into rupees and paisa
- To read number of days and convert those days into month and day
- To read five digits integer number and finds sum and average
- To find smallest number among three integer numbers
- To find prime numbers from 1 to 100
/*to reads the cost of a pen in paisa and convert it into rupees and paisa*/
#include<conio.h>
#include<stdio.h>
int main()
{
int p,r,c;
printf(“enter the cost of a pen in paisa\n”);
scanf(“%d”,&c);
r=c/100;
p=c%100;
printf(“rupees=%d\n”,r);
printf(“paisa=%d”,p);
return 0;
}
//to read number of days and convert those days into month and day
#include<conio.h>
#include<stdio.h>
int main()
{
int nd,m,d;
printf(“enter the number of days\n”);
scanf(“%d”,nd);
m=nd/30;
d=nd/30;
printf(“month=%d\n”,m);
printf(“days=%d”,d);
return 0;
}
//to read five digits integer number and finds sum and average
#include<conio.h>
#include<stdio.h>
int main()
{
int n,d,s=0;
float a;
printf(“enter a five digit number\n”);
scanf(“%d”,n);
d=n%10;
s=s+d;
n=n/10;
d=n%10;
s=s+d;
n=n/10;
d=n%10;
s=s+d;
n=n/10;
d=n%10;
s=s+d;
n=n/10;
s=s+n;
a=(float)s/5;
printf(“sum of five digits=%d\n”,s);
printf(“average=%f”,a);
return 0;
}
//to find smallest number among three integer numbers
#include<conio.h>
#include<stdio.h>
int main()
{
int a,b,c,s;
printf(“enter any three integer numbers\n”);
scanf(“%d%d%d”,&a,&b,&c);
if(a<b)
{
if(a<c)
{
s=a;
}
else
{
s=c;
}
if(b<c)
{
s=b;
}
else
{
s=c;
}
}
printf(“the smallest number=%d”,s);
return 0;
}
//to find prime numbers from 1 to 100
#include<conio.h>
#include<stdio.h>
int main()
{
int i,j,f;
for(i=2;i<=100;i++)
{
f=0;
for(j=1;j<=i;j++)
if(i%j==0)
{
f++;
}
}
if(i==2)
{
printf(“%d\t”,i);
}
return 0;
}