Kann jemand mir bitte helfen:)

  • Themenstarter Themenstarter putzihung
  • Beginndatum Beginndatum
P

putzihung

Hello,
Ich kann nicht so gut in Deutsch schreiben, weil ich nur voruebergehend hier studiere. Ich have eine Aufgabe, die ich loesen muss. Seid jemand so nett und help me to solve it. I appreciate you guys a lot:


1. Complex numbers are numbers which have both a real part and an imaginary part. Complex numbers are used extensively in Electrical Engineering for representing impedance, voltage, and current in AC circuits.



Complex numbers are represented in two ways:



Rectangular Form: X = a + bj <--- (real) + (imaginary) j

Polar Form: X = M / f



Create a structure to store a complex number in Rectangular Form. Both the real and imaginary parts should be of type float.



Next write the following functions:


  • Write a “show” function that displays the complex number in rectangular form. In other words, this function should accept the complex number as an argument and then display the number showing the ‘+/-‘ and the ‘j’.

For example the function “show” should print like: 5 + 10j or 5 - 10j


  • Write an “add” function that adds two complex numbers together. This function should accept two complex numbers as arguments and return the complex sum.

Your main() function should prompt the user to enter two complex numbers. The user will have to enter four floats. Test the two function, show() and add().




2. Write a function that computes the length of a string. Do not just use the strlen() function that exist in the library to do this.



ex. char name[] = “Cindy Lou Who”;



If your function is called str_length(), then

str_length(name); will return the integer 13, since there are 13 characters in the string “Cindy Lou Who”.
 
hi,
to the 2. problem:
Code:
int str_length(char * str)
{
int i=0;
while (str[i] != '\0') i++;
return i+1;
}

Col.Blake
 
Hi,

I think it is no problem to write your questions in english, most of us can speak english...

But now to your post here, what is your question ? Or do you think we write your programm as well ?


The structure you can realize with :

struct structname {
float real, imag;
};

structname a; //only in c++ in normal c you must write a struct before structname a;

To handle it, your can write a.real or a.imag


If you need more help, use the F1 key in your developer tool, then you get the help for the word the pointer is on, or come back with a real question, than it is easier to help you.

Good Luck
 
Zurück