Sunday 24 July 2011

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


[C]ATTEMPT THE FOLLOWING

(a) If cost price and selling price of an item is input through the keyboard, write a program to determine whether the seller has made profit or incurred loss. Also determine how much profit he made or loss he incurred.


click here for Answer!!!



(b) Any integer is input through the keyboard. Write a program to find out whether it is an odd number or even number.

click here for Answer!!!


(c)Any year is input through the keyboard. Write a program to determine whether the year is a leap year or not.
(Hint: Use the % (modulus) operator)

click here for Answer!!!


(d)According to the Gregorian calendar, it was Monday on the date 01/01/1900. If any year is input through the keyboard write a program to find out what is the day on 1st January of this year.

click here for Answer!!!


(e)A five-digit number is entered through the keyboard. Write a program to obtain the reversed number and to determine whether the original and reversed numbers are equal or not.


click here for Answer!!!


(f)If the ages of Ram, Shyam and Ajay are input through the keyboard, write a program to determine the youngest of the three.

click here for Answer!!!


(g)Write a program to check whether a triangle is valid or not, when the three angles of the triangle are entered through the keyboard. A triangle is valid if the sum of all the three angles is equal to 180 degrees.

click here for Answer!!!


(h) Find the absolute value of a number entered through the
keyboard.


click here for Answer!!!


(i)Given the length and breadth of a rectangle, write a program to find whether the area of the rectangle is greater than its perimeter. For example, the area of the rectangle with length = 5 and breadth = 4 is greater than its perimeter.

click here for Answer!!!


(j)Given three points (x1, y1), (x2, y2) and (x3, y3), write a program to check if all the three points fall on one straight line.

click here for Answer!!!


(k) Given the coordinates (x, y) of a center of a circle and it’s radius, write a program which will determine whether a point lies inside the circle, on the circle or outside the circle. (Hint: Use sqrt( ) and pow( ) functions)


click here for Answer!!!


(l) Given a point (x, y), write a program to find out if it lies on the x-axis, y-axis or at the origin, viz. (0, 0).


click here for Answer!!!

5 comments:

  1. Excellent work . . . .. :)

    ReplyDelete
  2. hey...can you post the program code of this question
    1.Given a circle x2 +y2 =r2 .WAP to determine whether a point(x1,y1) lies inside, outside or on the circle.

    ReplyDelete
  3. Chapter 2 [C] K part solution is not correct as there is center point not mentioned here to compare value and find out the result according to quadrant geometry, please share correct answer

    ReplyDelete
  4. Try this for question K
    #include
    #include
    #include
    main()
    {
    float x,y,r,d;
    printf("\nEnter the value of x and y:");
    scanf("%f %f",&x,&y);
    printf("Enter the radius:");
    scanf("%f",&r);
    d=sqrt(x*x+y*y);
    if(d>r)
    printf("\nPoint is outside");
    else if(d==r)
    printf("\nPoint is on the circle");
    else if(d<r)
    printf("\nPoint lies inside the circle");
    getch();
    return 0;
    }

    ReplyDelete