i don't have a clue what is wrong here....
the program is supposed to add, subtract, multiply and divide two real numbers.

``````#include<stdio.h>

float subtract(float x, float y);
float multiply(float x, float y);
float divide(float x, float y);

int main (void)
{

int choice;
float x, y;

while(1)
{
printf("\nPress 1 to add two  numbers.\n");
printf("Press 2 to subtract two numbers.\n");
printf("Press 3 to multiply two numbers.\n");
printf("Press 4 to divide two numbers.\n");
printf("Press 5 to exit the program.\n");
scanf("%d",&choice);

if(choice==5)
{
return 0;
}

if(choice >= 1 && choice <= 4)

{
scanf("%f", &x);

scanf("%f", &y);

if (choice==1)
{
printf("The sum of both values inputted: % f\n", add(x, y));
}

{
return x+y;
}

else if (choice==2)
{
printf("The difference of both values inputted: % f\n", subtract(x, y));
}

float subtract(float x, float y)

{
return x-y;
}

else if (choice==3)
{
printf("The difference of both values inputted: % f\n", multiply(x, y));
}

float multiply(float x, float y)

{
return x*y;
}

else if (choice==4)
{
printf("The difference of both values inputted: % f\n", divide(x, y));
scanf("%f",x/y)
}

float divide(float x, float y)

{
return x/y;
}

}
}``````

fixed, thanks :)

Yeah, i fixed it :) thanks guys for all your help, especially Jake :D <3

``````#include<stdio.h>
#include<stdlib.h>

struct complex

{
int real,imag;
};

int main()

{
int choice;
struct complex x, y, z;

{
printf("Press 1 to add two complex numbers.\n");
printf("Press 2 to subtract two complex numbers.\n");
printf("Press 3 to multiply two complex numbers.\n");
printf("Press 4 to divide two complex numbers.\n");
scanf("%d",&choice);

if(choice >= 1 && choice <= 4)

{
printf("Please enter the two real and imaginary complex numbers (a+jb) :\n");
printf("\nReal Number:");
scanf("%d", &x.real);
printf("\nImaginary Number:");
scanf("%d", &x.imag);

printf("\nPlease enter the next two real and imaginary complex numbers (c+jd) :\n");
printf("\nReal Number:");
scanf("%d", &y.real);
printf("\nImaginary Number:");
scanf("%d", &y.imag);

printf("\nFirst Complex Number:%d+j%d",x.real, x.imag);
printf("\nSecond Complex Number:%d+j%d\n",y.real, y.imag);
}

if (choice==1)
{
z.real=x.real+y.real;
z.imag=x.imag+y.imag;
printf("\nThe result of the addition of the two complex numbers:%d+j%d\n",z.real, z.imag);
}

else if (choice==2)
{
z.real=x.real-y.real;
z.imag=x.imag-y.imag;
printf("\nThe result of the subtraction of the two complex numbers:%d+j%d\n",z.real, z.imag);
}

else if (choice==3)
{
z.real=x.real*y.real-x.imag*y.imag;
z.imag=x.imag*y.real+x.real*y.imag;
printf("\nThe result of the multiplication of the two complex numbers:%d+j%d\n",z.real, z.imag);
}

else if (choice==4)
{   z.real=x.real/y.real-x.imag/y.imag;
z.imag=x.imag/y.real+x.real/y.imag;
printf("\nThe result of the division of the two complex numbers:%d+j%d\n",z.real, z.imag);
}

else
{
printf("Invalid Choice");
}``````

76 };

the problem is it says 76: "expected declaration or statment at end of input"

i have tried all the codes suggested...

okay so i was wrong, i have to do a menu driven program...basically i have to press 1 to add two complex numbers press 2 to subtract, press 3 to multiply and 4 to divide

ok so i tried the code above and it didn't work...all i need is a way to press Q to end the program!

erm i'm using the compiler in quincy 2005?

Ok so now i have been able to write the code for adding and subtracting two complex numbers in rectangular form but now need to do the same for multiplication and division in polar form.

``````#include<stdio.h>
#include<stdlib.h>

struct complex

{
int real,imag;
};

int main()
{
struct complex x, y, z;
printf("Please enter the two real and imaginary complex numbers (a+jb) :\n");
printf("\nReal Number:");
scanf("%d", &x.real);
printf("\nImaginary Number:");
scanf("%d", &x.imag);

printf("\nPlease enter the next two real and imaginary complex numbers (c+jd) :\n");
printf("\nReal Number:");
scanf("%d", &y.real);
printf("\nImaginary Number:");
scanf("%d", &y.imag);

printf("\nFrist Complex Number:%d+j%d",x.real, x.imag);
printf("\nSecond Complex Number:%d+j%d\n",y.real, y.imag);

z.real=x.real+y.real;
z.imag=x.imag+y.imag;

printf("\nThe result of the addition of the two complex numbers:%d+j%d\n",z.real, z.imag);

return 0;
} ``````

The above is the code to add two complex numbers in rectangular form.

i have to make the multiplication and division in polar form but i'll try and figure it out on my own :')

end of the program... as stated in the title..and i tihnk you mean quit* :P

i need to somehow do a while loop for this i think!?

ooopsss i was posting in the wrong discussion D: i feel stupid now.
i don't mean return 0;

i basically need to end the program by pressing Q in the command prompt

OMFG!!!!! thank you SO much...i am actually going to cry i've been trying to do this the past 3 days haaaa!! :)

kind of... more like this?

``````#include<stdio.h>
#include<stdlib.h>

struct complex

{
int real,imag;
};

int main()
{
struct complex x, y, z;
printf("Please enter the two real and imaginary complex numbers (a+jb) :\n");
printf("\nReal Number:");
scanf("%d", &x.real);
printf("\nImaginary Number:");
scanf("%d", &x.imag);

printf("\nPlease enter the next two real and imaginary complex numbers (c+jd) :\n");
printf("\nReal Number:");
scanf("%d", &y.real);
printf("\nImaginary Number:");
scanf("%d", &y.imag);

printf("\nFrist Complex Number:%d+i%d",x.real, x.imag);
printf("\nSecond Complex Number:%d+i%d\n",y.real, y.imag);

z.real=x.real+y.real;
z.imag=x.imag+y.imag;

printf("\nThe result of the addition of the two complex numbers:\n",z.real, z.imag);

return 0;``````

i'm having difficulty showing the result though?

i'm wanting to do separate programs for each (aka one program for adding one for subtracting) is this possible?

I have no idea hw to approach this... i need to end my program, shown below by the user pressing the letter Q on the keyboard. Help?

``````#include <stdio.h>
#include <stdlib.h>

float subtract(float x, float y);

int main (void)
{
float x, y;

scanf("%f", &x);

scanf("%f", &y);

printf("The difference of both values inputted: % f\n", subtract(x, y));
}

float subtract (float x, float y)

{
return x-y;
}``````

I have an assignment in which i have to add, subtract, multiply and divide two complex numbers and i am very confused as to how to create the program.
This is what i have got so far..

``````#include <stdio.h>
#include <complex.h>

int main (void)

int real, imag;

{
complex a, b, c, d;

printf("Please enter the two real and imaginary complex numbers (a+jb) :\n")
printf("a = \n");
scanf("%d", &a.real);
printf("b = \n");
scanf("%d", &b.imag);

printf("Please enter the next two real and imaginary complex numbers (c+jd) :\n")
printf("c = \n");
scanf("%d", &c.real);
printf("d = \\n");
scanf("%d", &d.imag);

}``````

obviously i don't know if this is right but i am hoping so, now i don't know how to write the expression for adding the two complex numbers or outputting the end value.