Sunday 24 July 2011

[chapter 2 part 2]let us c [SOLVED]


[F]([G] in 4th edition ) Attempt the following:
(a) Any year is entered through the keyboard, write a program to determine whether the year is leap or not. Use the logical operators && and ||.

click here for Answer!!!



(b) Any character is entered through the keyboard, write a program to determine whether the character entered is a capital letter, a small case letter, a digit or a special symbol. The following table shows the range of ASCII values for various characters.
characters ascii values
A-Z 65 – 90
a-z 97 – 122
0-9 48 – 57
special symbols 0 - 47, 58 - 64, 91 - 96, 123 - 127

click here for Answer!!!


(c) 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.
Write a program to output whether the person should be insured or not, his/her premium rate and maximum amount for which he/she can be insured.



click here for Answer!!!


(d) A certain grade of steel is graded according to the following conditions:
(i) Hardness must be greater than 50
(ii) Carbon content must be less than 0.7
(iii) Tensile strength must be greater than 5600
The grades are as follows:
Grade is 10 if all three conditions are met
Grade is 9 if conditions (i) and (ii) are met
Grade is 8 if conditions (ii) and (iii) are met
Grade is 7 if conditions (i) and (iii) are met
Grade is 6 if only one condition is met
Grade is 5 if none of the conditions are met
Write a program, which will require the user to give values of hardness, carbon content and tensile strength of the steel under consideration and output the grade of the steel.


click here for Answer!!!


(e)A library charges a fine for every book returned late. For first 5 days the fine is 50 paise, for 6-10 days fine is one rupee and above 10 days fine is 5 rupees. If you return the book after 30 days your membership will be cancelled. Write a program to accept the number of days the member is late to return the book and display the fine or the appropriate message.

click here for Answer!!!


(f)If the three sides of a triangle are entered through the keyboard, write a program to check whether the triangle is valid or not. The triangle is valid if the sum of two sides is greater than the largest of the three sides.

click here for Answer!!!


(g)If the three sides of a triangle are entered through the keyboard, write a program to check whether the triangle is isosceles, equilateral, scalene or right angled triangle.

click here for Answer!!!


(h) In a company, worker efficiency is determined on the basis of the time required for a worker to complete a particular job. If the time taken by the worker is between 2 – 3 hours, then the worker is said to be highly efficient. If the time required by the worker is between 3 – 4 hours, then the worker is ordered to improve speed. If the time taken is between 4 – 5 hours, the worker is given training to improve his speed, and if the time taken by the worker is more than 5 hours, then the worker has to leave the company. If the time taken by the worker is input through the keyboard, find the efficiency of the worker.

click here for Answer!!!


(i) A university has the following rules for a student to qualify for a degree with A as the main subject and B as the subsidiary subject:

(a) He should get 55 percent or more in A and 45 percent or more in B.
(b) If he gets less than 55 percent in A he should get 55 percent or more in B. However, he should get at least 45 percent in A.
(c) If he gets less than 45 percent in B and 65 percent or more in A he is allowed to reappear in an examination in B to qualify.
(d) In all other cases he is declared to have failed.
Write a program to receive marks in A and B and Output whether the student has passed, failed or is allowed to reappear in B.



click here for Answer!!!


(j) The policy followed by a company to process customer orders is given by the following rules:
(a) If a customer order is less than or equal to that in stock and has credit is OK, supply has requirement.
(b) If has credit is not OK do not supply. Send him intimation.
(c) If has credit is Ok but the item in stock is less than has order, supply what is in stock. Intimate to him data the balance will be shipped.

Write a C program to implement the company policy


click here for Answer!!!

14 comments:

  1. exellent solutions are available

    ReplyDelete
  2. thank you its very nice and too helpfull

    ReplyDelete
  3. Write a program that can fill an array of type integer size 8 with numbers in Binary format and then generates the output in Decimal, i.e. If the input is 00001110 the out put will be 14.how i do this

    ReplyDelete
    Replies
    1. #include
      #include
      #include
      void main(void)
      {clrscr();
      int num,n=1,last_digit=0,sum=0;
      cout<<"\nEnter Binary Number : ";
      cin>>num;
      while(num>0)
      {last_digit=num%10;
      sum=sum+last_digit*n;
      num=num/10;
      n=n*2;
      }
      cout<<"\nDecimal Number : "<<sum;
      getch();
      }

      Delete
  4. Programme 1 in JAVA============


    public class LeapuseOperater {

    public static void main(String[] args)
    {

    int year = 1989;

    if (year%400 == 0 || (year%100 != 0 && year%4 == 0))
    {
    System.out.println("This year is a leap year");
    }

    else
    {
    System.out.println("This is not a leap year");
    }

    }
    }

    ReplyDelete
  5. Programe 2 in java===========



    public class DemoPrint {

    public static void main(String[] args)
    {

    char ch = '7';
    int position= ch;
    if((ch>=0 && ch<=47) || (ch>=58 && ch<=64) ||(ch>=91 && ch<=96) || (ch>=123 && ch<=127))
    {
    System.out.print("Special Symbol: "+position);
    }

    if(ch>=48 && ch<=57)
    {
    System.out.print("Digit: "+position);
    }

    if(ch>=65 && ch<=90)
    {
    System.out.print("Capital: "+position);
    }

    if(ch>=97 && ch<=122)
    {
    System.out.print("Small: "+position);
    }

    }
    }

    ReplyDelete
  6. Programe 3 in JAva........===========



    public class Insurence {

    public static void main(String[] args)
    {
    int age = 25;
    int premamt ,policyamt;

    char loc = 'c';
    char sex = 'f';
    char health = 'g';

    if((age>=25 && age<=35)&&(health=='g')&&(loc=='c')&&(sex=='m'))
    {
    premamt = 4;
    policyamt = 2;
    System.out.println("Person is Insured"+"\nPayble Premium: "+premamt+" /Thousands"+"\nPolicy Ammount is: "+policyamt+" Lakh");
    }

    else if((age>=25 && age<=35)&&(health=='g')&&(loc=='c')&&(sex=='f'))
    {
    premamt = 3;
    policyamt = 1;

    System.out.println("Person is Insured"+"\nPayble Premium: "+premamt+" /Thousands"+"\nPolicy Ammount is: "+policyamt+" Lakh");
    }

    else if((age>=25 && age<=35)&&(health=='b')&&(loc=='v')&&(sex=='m'))
    {
    premamt = 6;
    policyamt = 10;

    System.out.println("Person is Insured"+"\nPayble Premium: "+premamt+" /Thousands"+"\nPolicy Ammount is: "+policyamt+" Thousands");
    }

    else
    System.out.println("Person is not Insured");

    }
    }

    ReplyDelete
  7. Programme 5 in java==



    public class LibraryDemo {

    public static void main(String[] args)
    {

    int days = 21;
    int late = days;

    if(days>=1 && days<=5)
    {
    System.out.println("Your fine is: 50 paisa because you are late: "+late+" Days");
    }

    if(days>=6 && days<=10)
    {
    System.out.println("Your fine is: 1 Rs because you are late: "+late+" Days");
    }

    if(days>=11 && days<=30)
    {
    System.out.println("Your fine is: 5 Rs because you are late: "+late+" Days");
    }

    if(days>30)
    {
    System.out.println("Your membership cancled because you are late after 30 days and Your late days are: "+late+" Days");
    }

    }
    }

    ReplyDelete
  8. Programe h in Java=======


    public class Worker {

    public static void main(String[] args)
    {

    int hour = 1;
    int takenhour = hour;

    if(hour>=1 &&hour<=3)
    {
    System.out.println("This worker is highly Efficient,"+" Your taken Hour is: "+takenhour+"hr");
    }

    else if(hour>3 &&hour<=4)
    {
    System.out.println("This worker is ordered to improve Speed,"+" Your taken Hour is: "+takenhour+"hr");
    }

    else if(hour>4 &&hour<=5)
    {
    System.out.println("This worker is given training to improve Speed,"+" Your taken Hour is: "+takenhour+"hr");
    }

    else

    System.out.println("This worker has to leave the company,"+" Your taken Hour is: "+takenhour+"hr");
    }

    }

    ReplyDelete
  9. import java.io.*;

    class ch2_22
    {
    public static void main(String args[])
    throws java.io.IOException
    {
    char ch;
    ch=(char)System.in.read();


    if(ch>=65 && ch<=90)
    System.out.println("Character Is Capital" );

    else if(ch>=97 && ch<=122)
    System.out.println("Character Is small" );

    else if(ch>=48 && ch<=57)
    System.out.println("Character Is Digit" );

    else
    System.out.println("Character Is Special Symbols");



    }
    }

    ReplyDelete