I need help with #3 the last picture. it's just a bunch of if statements(only c programming). its A-H
Lab 5 Objectives are to design functions based on description (specification) to test and evaluation function with various test cases e e 1. Program "ake Using user-defined header files and separate compilation are tedious works because you have to remember and manually typewrite a lot of options. Good News! There is a good solution helping you to avoid this tedious work flows. The program "make" is a tool that controls the generation of executables and other non-source files of a program from the program's source files by automatically check dependency and timestamp. For example, consider the following separate compilation process $gcc -c -o smaller.o smaller.c $ gcc-c-o larger . o larger, c $ gcc -c -I../include -o foo1.o foo1.c s gcc -L../lib fool.o smaller.o larger.o -1rx32 -o foo1 To automate the compilation process, create a text file named "makefile" at the same folder of source codes as below: = gcc # this is comment in makefile CFLAGS I. ./include LDLIBS1rx32 LDFLAGS = -L,./lib fool: foo1.o smaller.o larger.o # the sixth line PHONY: clean clean: $(RM) # be careful, it needs invisible
character at the beginning *.0 *~ *.exe That is it. You are now ready to compile. $ make It will automatically executable program. If you change compile the sources to intermediate objects code and then link them together into an one of the source codes, simply type "make" again. It will compile only code that has been modified since it was compile and link. You need not remember anything, If you want to compile them all again, just type "make clean". It will delete the intermediate object files just type "make" whenever change any source code. the executable program. To build everything, simply type "make". To customize the makefile to our project, simply modify the sixth line at the file, which is called a dependency. If you want to kmow the detail of "make", simply type "man make" This section is to give information and you need not submit anything for this section. Instead, yot will indude mabefile for the follong sections. A single makefile i enough for everything. Just add dependency lines similar to the sixth line. . Complex Number Cog supports complex data types. To include ccomplex.h> makes it easy, readable and consistent. For example, double complex x 3 + 4I where I is a constant representing V-1 in mathematics. Electrical and Computer Engineering has a huge number of theories and applications utilizing the complex number (communication, signal and control). The complex plane or z-plane is a geometric representation of the complex numbers established by the real axis and the perpendicular imaginary axis. It can be thought of as a modified Cartesian plane, with the real part of a complex number represented by a displacement along the x-axis, and the imaginary part by a displacement along the y-axis. [from https://en.wikipedia.org/wiki/Complex plane You will write a program To get a real number (says, r) and a positive integer (says, n), where the real number is the radius of circle, and the integer is the number of equally spaced points on the circle. To write a function that takes arguments of complex array, number of points, radius, and a starting angle(e). . . The function finds n equally-angle-spaced complex points at the radius, starting from at the counter-clockwise. The function stores those points in the complex array. o o To print n points from the function by giving e as either zero (0) or . Make this function as a separate source file. The figures below are points when the radius is 1 and n is 4. The first figure is when 0, the other is when . Note that these figures are just illustration. You are not required to make these kind of figures Instead, print those points as values. Use creal() and cimag() functions to obtain real and imaginary parts of a complex number . , respectively. Also note that math.h header file contains gonom RE 3. Print a Complex Number How did you print a complex number in the previous section? In mathematical convention, we use plus or minus binary symbol between real part and imaginary part, where the imaginary part has a case- insensitive suffix J or T. For example, all of the following is valid complex notations in math: 1 +j, j, I, 0.5+0.2 J, 3.4E-11 + 0.27E+1 j You will write a function to print a complex number in the mathematical convention as a separate source file. The function takes two arguments: a complex number and a format string, and returns the number of characters printed. So, the function (says, func_alpha function) has the prototype as int func, alpha (double complex v, char *fmt); The fmt argument is a format specifier as like printf() standard 1O function for printing each of real an imaginary part. For example, func-alpha (0.71-0.421, "% . 4f") prints as 0.7100 0.4200 j If the fmt is given as NULL, the function uses its own default format. The convention wi general mathematical convention as below: ll follow the a. If the real part is zero, print only the imaginary part (eg. "0.41 j" but not "e 0.41 j") b. If the imaginary part is zero, print only the real part. (eg"0.71" but not"0.71 + 0 j") c. If the complex number is zero (both real and imaginary parts are zero), print a simple "e. d. If the imaginary part is one, the coefficient 1 is omitted (eg. "1 + j"but not "1 + 1 j") A unary positive sign is always omitted. (eg. "1" but not "+1") (eg. "2 j" but not "+2 j", and "j" but not "+j") e. f. The suffix (either j or T) will have a preceding space for better readibility (eg. "e.41 j" but not "0.41j") g. A binary operator (either'or) will have both a preceding space and a succeeding space, but unary operator has no such space. (eg. "2.71 3.41 j" but not "2.71+3.41j") 3.41 i or h. A binary operator and a unary operator do not appear back to back. (eg. "2.71 3.41 j" but not "2.71 + -3.41 j") Make a driver function to test all features. Also, use this function for section 1 program. You are welcomed to announce your test cases in discussion forum to share with others. 4. Submission Guide Same as Lab 1, and makefile