1. Invalid constant
0X10.5 0x0g1 98.7u 17777 s 0996 1.2Fe-7 15,000.
2.
// only need to list expressions can
int F = 27; // F is set Fahrenheit, assignment 27
float C; // set of floating type C to degrees Celsius, type
C = (F-32) /1.8;
NSLog (@ "% 1f.", C); //% .1f to one decimal place can
// output
2014-09-17 14: 58: 48.259 prog1 [6058: 303] -2.8
Program ended with exit code: 0
3. The output result is D.
4.
float x = 2.55, result;
result = 3 * (x * x * x) - 5 * (x * x) + 6;
NSLog (@ "result is% f", result);
// The result is as follows
2014-09-17 15: 11: 11.064 prog1 [6196: 303] result is 23.231621
5.
// This question does not know what the test is listed expression had passed
double result;
result = (3.31e-8 + 2.01e-7) / (7.16e-6 + 2.01e-8);
NSLog (@ "result is% e", result);
// output
2014-09-17 15: 29: 31.547 prog1 [6274: 303] result is 3.260400
6.
// ------------- Interface part -----------
@interface Complex: NSObject
- (void) setReal: (double) a; // set real number
- (void) setImaginary: (double) b; // set the imaginary
- (void) print; // print results
-(double) real;
-(double) imaginary;
@end
// -------------- implementation part ----------------
@implementation Complex
{
double real;
double imaginary;
}
- (void) setReal: (double) a
{
real = a;
}
- (void) setImaginary: (double) b
{
imaginary = b;
}
- (void) print
{
NSLog (@ "The complex is% .f +% .fi", real, imaginary);
}
- (double) real
{
return real;
}
- (double) imaginary
{
return imaginary;
}
@end
// ---------------- program part -------------
int main (int argc, const char * argv [])
{
@autoreleasepool {
Complex * newComplex = [[Complex alloc] init];
[newComplex setReal: 11];
[newComplex setImaginary: 22];
// The following two methods can be, respectively, and the test print method real, imaginary methods; (subject to be required)
[newComplex print];
// NSLog (@ "The complex is% .f +% .fi", [newComplex real], [newComplex imaginary]);
}
return 0;
}
// The result is as follows
2014-09-17 17: 27: 59.830 prog1 [6678: 303] The complex is 11 + 22i
Program ended with exit code: 0
7.
Mobile phone problems get mobile phone first
Objective-C Programming (Sixth Edition) Chapter 4 answers to exercises