Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

4. [10 points] Write a program which will do the following: a) Show how to declare a tag named complex for a structure with two

image text in transcribed

4. [10 points] Write a program which will do the following: a) Show how to declare a tag named complex for a structure with two members, real and imaginary of type double. b) Use the complex tag to declare variables named cl, c2, and c3. c) Write a function named make_complex that stores its two arguments (both of type double) in a complex structure, then returns the structure. Note: The function declaration for the make_complex function looks like struct complex make_complex(double real, double imaginary); d) Write a function named add_complex that adds the corresponding members of its arguments (both complex structures), then returns the result (another complex structure). Note: The function declaration for the add_complex function looks like struct complex add _complex(double real, double imaginary); 5. [8 points] Write a program that reads a message, then checks whether it is a palindrome (the letters in the message are the same from left to right or right to left) or not. You must use dereferencing of pointers to read the input message stored in a character array. Ignore all characters that are not letters. Use integer variables to keep track of positions in the array. 6. 4 points] Suppose that the direction variable is declared in the following way: enum (NORTH, SOUTH, WEST, EAST) direction; Let x and y be int variables. Write a program which declares an enumeration type data structure as given above, and then declares variables x and y of type enum. Then write a switch statement that tests the value of direction, incrementing x if direction is EAST, decrementing x if direction is WEST, incrementing y if direction is SOUTH, and decrementing y if direction is NORTH

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Readings In Database Systems

Authors: Michael Stonebraker

2nd Edition

0934613656, 9780934613651

More Books

Students also viewed these Databases questions

Question

Why do HCMSs exist? Do they change over time?

Answered: 1 week ago