Ok, so I have no programming experience and I started using "Let Us C" by Yashavant Kanetkar to teach myself C a few days ago. Unfortunately, I don't have the solutions to the exercises in the book, so I was wondering if I could get a little help from y'all. Here's the exercise, with each statement followed by my answer:
Point out the errors, if any, in the following C statements:
1.
no errorCode:int = 314.562 * 150;
2.
both quotes should point to the left (i can't show this on my computer, but one quote is pointing one way and the other is pointing the opposite way)Code:name = 'Ajay';
3.
both quotes should point to the left (i can't show this on my computer, but one quote is pointing one way and the other is pointing the opposite way)Code:varchar = '3';
4.
variable should be on the left, constant on the rightCode:3.14 * r * r * h = vol_of_cyl;
5.
* must be used for multiplicationCode:k = (a * b)(c + (2.5a + b)(d + e);
6.
variable names can't have spaces in themCode:m_inst = rate of interest * amount in rs;
7.
no errorsCode:si = principal * rateofinterest * numberofyears/100;
8.
should be re2, not r**2Code:area = 3.14 * r**2;
9.
should be re2, not r^2Code:volume = 3.14 * r^2 * h;
10.
must use * for multiplication. can't have parenthesis within parenthesisCode:k = ((a * b)+c)(2.5 * a + b);
11.
3 and 4 aren't the same? that's about all i can come up with.Code:a=b=3=4;
12.
count isn't definedCode:count = count + 1;
13.
variables can't have spaces in themCode:date = '2 Mar 04';
Ok, as you can see, I'm pretty sorely in need of help. I really appreciate any assistance.



LinkBack URL
About LinkBacks


