using typedef and structures creating a complex number program
#include <stdio.h>
typedef struct complex{
int real;
int imaginary;
}com;
void display(com c)
{
printf("The real part of number is %d\n",c.real);
printf("The imaginary part of number is %d\n",c.imaginary);
}
int main(){
com c[5];
for(int i=0;i<5;i++)
{
printf("Enter the real part of %d num\n",i+1 );
scanf("%d",&c[i].real);
printf("Enter the imaginary part of %d num\n",i+1);
scanf("%d",&c[i].imaginary);
}
for(int i=0;i<5;i++)
{
display(c[i]);
}
return 0;
}
Comments
Post a Comment