Chapter 2 Completedlet Us C Solutions



Question-An Insurance company follows following rules to calculate premium.
(1) If a person’s health is excellent and the person is between 25 and 35 years of age and lives in a city and is a male then the premium is Rs. 4 per thousand and his policy amount cannot exceed Rs. 2 lakhs.
(2) If a person satisfies all the above conditions except that the sex is female then the premium is Rs. 3 per thousand and her policy amount cannot exceed Rs. 1 lakh.
(3) If a person’s health is poor and the person is between 25 and 35 years of age and lives in a village and is a male then the premium is Rs. 6 per thousand and his policy cannot exceed Rs. 10,000.
(4) In all other cases the person is not insured.
Solution- Honestly speaking ,these type of questions are really boring. Here is the solution.
#include<stdio.h>
int main()
{
int health,age,gender,residence;
printf('Enter your info. Health(Excellent=1,poor=0),age(25-35=1 ,else=0),gender(Male=1,female=0),residense info.(Rural=1,urban=0)n');
scanf('%d%d%d%d',&health,&age,&gender,&residence);
if(health1&&age1&&gender1&&residence0)
printf(' premium is Rs. 4 per thousand and his policy amount cannot exceed Rs. 2 lakhsn');
else if (health1&&age1&&gender0&&residence0)
printf('premium is Rs. 3 per thousand and her policy amount cannot exceed Rs. 1 lakhn');
else if(health1&&age1&&gender0&&residence1)
printf('premium is Rs. 6 per thousand and his policy cannot exceed Rs. 10,000n');
else
printf('Person can not be insuredn');
return 0;
}
/* We can write all condition together using || but it would difficult to read so i prefer this way */

  1. Chapter 2 Completedlet Us C Solutions Inc
  2. Chapter 2 Completedlet Us C Solutions Pvt Ltd
  3. Chapter 2 Completedlet Us C Solutions Llc
  4. Chapter 2 Completedlet Us C Solutions Collection Agency

We hope the Kerala Plus Two Chemistry Chapter Wise Questions and Answers Chapter 2 Solutions help you. If you have any query regarding Kerala Plus Two Chemistry Chapter Wise Questions and Answers Chapter 2 Solutions, drop a comment below and we will get back to you at the earliest. Let Us C Solutions of chapter 2, C Instructions. Instructions in C programming are nothing just lines of codes that execute one by one and called instructions. Instruction or command is a very commonly used technical term in all the language, it means just telling the computer what to do. You'll learn here how to write Instructions in C and execute them to get the desired results.

In the two chapter, the Let Us C covered all the basic things we need to get started in the journey of learning C Programming. Now, let’s have a look at the solutions of the exercise of the first chapter, Getting Started from Let Us C.

Table of Contents:

[A] Point out errors, if any, in the following C statements

(a) x = ( y + 3 )

Answer: It has no errors

(b) cir = 2 * 3.141593 * r;

Answer: It has no errors

(c) char = ‘3’ ;

Answer: Keywords are not allowed as variable names

(d) 4 / 3 * 3.14 * r * r * r = vol_of_sphere;

Agency

Chapter 2 Completedlet Us C Solutions Inc

Answer: Expressions can’t be placed in the left side, its a place for variables only.

(e) volume = a3 ;

Answer: We can’t use exponents directly, It should be specified as a * a * a;

(f) area = 1 / 2 * base * height ;

Answer: It has no errors.

(g) si = p * r * n / 100 ;

Answer: It has no errors

(h) area of circle = 3.14 * r * r ;

Answer: area of circle is not a valid variable name, your variable should not contain a space.

(i) peri_of_tri = a + b + c ;

Answer: It has no errors.

(j) slope = ( y2 – y1 ) ÷ ( x2 – x1 ) ;

Answer: “÷” is not a valid operator

(k) 3 = b = 4 = a ;

Answer: Variable name should be on the left side.

(l) count = count + 1 ;

Answer: It has no errors

(m) char ch = ’25 Apr 12′ ;

Answer: char can only hold a single character, use array for entering multiple character.

[B] Evaluate the following expressions and show their hierarchy

(a) ans = 5 * b * b * x – 3 * a * y * y – 8 * b * b * x + 10 * a * y ;
(a = 3, b = 2, x = 5, y = 4 assume ans to be a int)

Answer:

(b) res = 4 * a * y / c – a * y / c ;
(a = 4, y = 1, c = 3, assume res to be an int)

Answer:

(c) s = c + a * y * y / b ;
(a = 2.2, b = 0.0, c = 4.1, y = 3.0, assume s to be an float)

Answer:

(d) R = x * x + 2 * x + 1 / 2 * x * x + x + 1 ;
(x = 3.5, assume R to be an float)

Answer:

Chapter 2 completedlet us c solutions inc

[C] Indicate the order in which the following expressions would be evaluated.

(a) g = 10 / 5 / 2 / 1 ;

Evaluation order would be:

(b) b = 3 / 2 + 5 * 4 / 3 ;

Evaluation order would be:

(c) a = b = c = 3 + 4 ;

Evaluation order would be:

(d) x = 2 – 3 + 5 * 2 / 8 % 3 ;

Evaluation order would be:

(e) z = 5 % 3 / 8 * 3 + 4 ;

Evaluation order would be:

(f) y = z = -3 % -8 / 2 + 7 ;

Evaluation order would be:

[D] Convert the following algebraic expressions into equivalent C statements.

Answer:

[E] What will be the output of the following programs:

(a)

Output:

Solutions

(b)

Output:

(c)

Output:

(d)

Answer:

(e)

Output:

[F] State whether the following statements are True or False:

(a) * or /, + or – represents the correct hierarchy of arithmetic
operators in C.

Answer: True

(b) [ ] and { } can be used in Arithmetic instructions.

Answer: False

(c) Hierarchy decides which operator is used first.

Answer: True

(d) In C, Arithmetic instruction cannot contain constants on left
side of =

Answer: True

(e) In C ** operator is used for exponentiation operation.

Answer: False

(f) % operator cannot be used on floats.

Answer: True

[G] Fill in the blanks:

(a) In y = 10 * x / 2 + z ; 10 * x operation will be performed first.

(b) If a is an integer variable, a = 11 / 2 ; will store 5 in a.

(c) The expression, a = 22 / 7 * 5 / 3 ; would evaluate to 5.

(d) The expression x = -7 % 2 – 8 would evaluate to -9.

(e) If d is a float the operation d = 2 / 7.0 would store 0.285714
in d.

Chapter 2 Completedlet Us C Solutions Pvt Ltd

[H] Attempt the following:

(a) If a five-digit number is input through the keyboard, write a
program to calculate the sum of its digits. (Hint: Use the
modulus operator ‘%’)

Program:

(b) If a five-digit number is input through the keyboard, write a
program to reverse the number

Program:

(c) If lengths of three sides of a triangle are input through the
keyboard, write a program to find the area of the triangle.

Program:

(d) Write a program to receive Cartesian co-ordinates (x, y) of a
point and convert them into polar co-ordinates

Program:

(e) Write a program to receive values of latitude (L1, L2) and
longitude (G1, G2), in degrees, of two places on the earth and
outputs the distance between them in nautical miles. The
formula for distance in nautical miles is:
D = 3963 acos ( sin L1 sin L2 + cos L1cos L2 * cos ( G2 – G1 )

Chapter 2 Completedlet Us C Solutions Llc

Program:

(f) Wind chill factor is the felt air temperature on exposed skin
due to wind. The wind chill temperature is always lower than
the air temperature, and is calculated as per the following
formula:
wcf = 35.74 + 0.6215t + ( 0.4275t – 35.75 ) * v0.16
where t is the temperature and v is the wind velocity. Write a
program to receive values of t and v and calculate wind chill
factor.

Program:

Chapter 2 Completedlet Us C Solutions

(g) If value of an angle is input through the keyboard, write a
program to print all its Trigonometric ratios.

Program:

(h) Two numbers are input through the keyboard into two
locations C and D. Write a program to interchange the
contents of C and D.

Program:

(i) Consider a currency system in which there are notes of seven
denominations, namely, Re. 1, Rs. 2, Rs. 5, Rs. 10, Rs. 50, Rs. 100. If a sum of Rs. N is entered through the keyboard, write a program to compute the smallest number of notes that will combine to give Rs. N.

Chapter 2 Completedlet Us C Solutions Collection Agency

Program:

These were the solutions of Chapter 2: C Instructions of Let Us C Book by Yashvant Kanetkar.