Code:
#include <stdio.h>
#include <math.h>
int main()
{
int testOne, testTwo, testThree, testFour;
double c_reOne = 2.0, c_reTwo = 0.0, c_reThree = -1.0, c_reFour = 1.0;
double c_imOne = 2.0, c_imTwo = 0.0, c_imThree = -1.0, c_imFour = 1.0;
testOne = mSetTest(c_reOne, c_imOne);
/*
[Info 718] Symbol 'mSetTest' undeclared, assumed to return int
[Info 746] call to function 'mSetTest()' not made in the presence of a prototype
Warning W8065: Call to function 'mSetTest' with no prototype in function main
*/
printf("Test One\n");
printf("Z = %lf + %lfi\n", c_reOne, c_imOne);
printf("The real part is\t %lf\n", c_reOne);
printf("The imaginary part is\t %lf\n", c_imOne);
printf("The result is\t\t %d\n\n", testOne);
testTwo = mSetTest(c_reTwo, c_imTwo);
/*
Warning W8065: Call to function 'mSetTest' with no prototype in function main
*/
printf("Test Two\n");
printf("Z = %lf + %lfi\n", c_reTwo, c_imTwo);
printf("The real part is\t %lf\n", c_reTwo);
printf("The imaginary part is\t %lf\n", c_imTwo);
printf("The result is\t\t %d\n\n", testTwo);
testThree = mSetTest(c_reThree, c_imThree);
/*
Warning W8065: Call to function 'mSetTest' with no prototype in function main
*/
printf("Test Three\n");
printf("Z = %lf + %lfi\n", c_reThree, c_imThree);
printf("The real part is\t %lf\n", c_reThree);
printf("The imaginary part is\t %lf\n", c_imThree);
printf("The result is\t\t %d\n\n", testThree);
testFour = mSetTest(c_reFour, c_imFour);
/*
Warning W8065: Call to function 'mSetTest' with no prototype in function main
*/
printf("Test Four\n");
printf("Z = %lf + %lfi\n", c_reFour, c_imFour);
printf("The real part is\t %lf\n", c_reFour);
printf("The imaginary part is\t %lf\n", c_imFour);
printf("The result is\t\t %d\n", testFour);
return(0);
}
int mSetTest(double c_re, double c_im)
{
double new_re = 0.0, new_im = 0.0, mod_z = 0.0;
int loop = 0.0;
/*
[Warning 524] Loss of precision (initialization) (double to int)
*/
while (loop < 200 && mod_z < 4)
{
new_re = ((new_re * new_re) - (new_im * new_im)) + c_re;
new_im = ((2 * new_re * new_im) + c_im);
mod_z = ((new_re * new_re) + (new_im * new_im));
loop++;
if (loop >= 200 && mod_z >=4)
{
loop = 0.0;
/*
[Warning 524] Loss of precision (assignment) (double to int)
Warning W8004: 'loop' is assigned a value that is never used in function mSetTest
*/
return(0);
}
}
printf("%lf %lf %d\n", new_re, new_im, loop);
}
/*
[Warning 533] function 'mSetTest(double, double)' should return a value
Warning W8070: Function should return a value in function mSetTest
*/
/*
[Info 766] Header file 'math.h' not used
*/
Use