Professional Documents
Culture Documents
Programming (Sample Code Tutorial 6), Department of Biomedical Engineering, University of Malaya
Programming (Sample Code Tutorial 6), Department of Biomedical Engineering, University of Malaya
Programming (Sample Code Tutorial 6), Department of Biomedical Engineering, University of Malaya
void fx()
{
int a[99],x1,x2,x3,x4,x5,x6,x7;
x1=1; x2=3;
for (x1=1;x1<=x2;x1++)
{
printf("enter two integers: ");
scanf("%d %d",&a[0],&a[1]);
a[2]=a[0]%a[1];
a[3]=a[1]%a[0];
if (a[2] == 0)
{
printf("%d is a multiple of %d\n",a[0],a[1]);
}
else if (a[3] == 0)
{
printf("%d is a multiple of %d\n",a[1],a[0]);
}
else
{
if (a[0] >= a[1])
{
printf("%d is not a multiple of %d\n",a[0],a[1]);
}
else if (a[1] >= a[0])
{
printf("%d is not a multiple of %d\n",a[1],a[0]);
}
else
{}
}
printf("\n\n");
}
//return fx(g);
}
#include<stdio.h>
#include<math.h>
void fx(void);
int main (void)
{
fx();
return 0;
}
void fx()
{
int a[99], x1,x2,x3,x4,x5;
x2=3;
for (x1=1;x1<=x2;x1++)
{
printf("enter an integer: ");
scanf("%d",&a[x1]);
x3=a[x1]%2;
if (x3 == 0)
{
printf("%d is an even integer",a[x1]);
}
else if (x3 ==1)
{
printf("%d is an odd integer",a[x1]);
}
else
{}
printf("\n\n");
}
printf("\n");
//return 0;
}
#include<stdio.h>
#include<math.h>
void fx();
int main (void)
{
fx();
return 0;
}
void fx()
{
//int x,y;
//x=1; y=1;
double x1, y1, x0, y0, z[9];
printf("enter the first point: ");
scanf("%lf %lf",&x0 ,&y0);
printf("enter the second point: ");
scanf("%lf %lf",&x1 ,&y1);
z[0]=x0-x1; z[1]=pow(z[0],2);
z[2]=y0-y1; z[3]=pow(z[2],2);
z[4]=z[1]+z[3]; z[5]=pow(z[4],0.5);
printf("distance between <%.2lf,%.2lf> and <%.2lf,%.2lf> is
%.2lf\n",x0,y0,x1,y1,z[5]);
//return 0;
}
#include<stdio.h>
#include<math.h>
int main ()
{
int i[99], j[99], c, t;
t=100;
c=0;