C language - Struct - TechRepublic
General discussion
October 15, 2001 at 03:52 AM
nt259

C language – Struct

by nt259 . Updated 24 years, 7 months ago

How to do this question:
#include

/* A complex number to be represented by a structure of two members */
struct cmplx {
int real;
int imaginary;
};

/*The purpose of the main() is to test the correctness of the function Complex_Add()*/
void main(void)
{
cmplx source = { 3, 4 };
cmplx addem = { 5, 6 };

Complex_Add( ____________ , ____________ ); /* Fill in the blanks */

printf( ?The solution: \n?);

printf( ?The real-part is %d\n?, __________________ ); /* Fill in the blanks */

printf( ?The imaginary-part is %d?, _________________ ); /* Fill in the blanks */

}

void Complex_Add( cmplx *first, cmplx *second)
{
/* Write your code here.
Add the complex number (pointed to by) second to that of first, and store
the result in first. */

}

This discussion is locked

All Comments