Some homework problems taken directly from the textbook: 1, Given the following
ID: 3687794 • Letter: S
Question
Some homework problems taken directly from the textbook: 1, Given the following declaration: int 11; int 12; float f1; char c1; char c2; char c3; and the following line of data 14 23 76 CD what would be the value of 1 l,12,fl,cl,c2, and c3 after the following statement? scanf("%d %d %f %c %c", &il;, &i2;, &fl;, &cl;, &c2;, &c3;); Given the following declaration: int 11; int 12; float fl; char c 1; char c2; char c3; and the following line of data 14.2 67 67.9 what would be the value of 1 l,12,fl,cl,c2, and c3 after the following statement? scanf("%d %c %c %i %f", &il;, &cl;, &c2;, &i2;, &fl;); Write a single statement to accomplish each of the following. Assume that each of these statements applies to the same program. Write a statement that opens the file "oldmast.dat" for reading and assigns the returned file pointer to ofPtr. Write a statement that opens the file "trans.dat" for reading and assigns the returned file pointer to tfPtr. Write a statement that opens the fileExplanation / Answer
1. scanf("%d%d%f%c%c", &I1, &I2, &f1, &c1, &c2, &c3); In this statement, the first value I1 will read the integer 14. I2 will read the integer 23. f1 will read the integer 76, and will be stored in a float point format as 76.000000. And coming to characters, c1 will read the character C. c2 will read the character D. And note that, you didn't gave the type specifier for the next variable, which means even, if you supply the value, don't take it in. And therefore c3 is not assigned any value as of now.
2. scanf("%d%c%c%i%f", &I1, &c1, &c2, &I2, &f1); In this statement, the first value I1 will read the integer 14. Then the character . will be read into c1, and then the other digit 2 will be read as a character into c2. Then the value 67 is read into the variable I2, and finally the value 67.9 will be read into the variable f1. And ofcourse, c3 is not assigned a value in this statement.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.