#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");
    printf("Enter your choice\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"

  • Stick a "return 0" in there at the end of main.
  • Count your opening and closing brackets. Make sure you don't have a bracket mismatch.
  • Get rid of the stray semicolon after the final bracket.

1- remove the semicolon from line 76
2-remove the bracket from line 16 and it will work

then please mark it as solved :)

to make menu driven program refer following page
menu driven program.

commented: The problem's already solved. Your tutorials need a lot of improvement ("break keyword is use to break the program after particular case." sounds pretty severe). And you should inform people when you use non-standard C functions. I could go on... +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.