Sunteți pe pagina 1din 86

ASSIGNMENT # 1

OBJECT:
Write a program to generate multiplication tables for a given number
N.
For input N = 2 and M = 15 the output will be
2X1=2
2X2=4
2X3=6
….
2 X 14 = 28
2 X 15 = 30

INPUT:
OUTPUT:

OBJECT:
Write a program to print all the ASCII values and their equivalent
characters using a while loop. The ASCII values vary from 0 to 255.

INPUT:
OUTPUT:

OBJECT:
Write a program to print out all Armstrong numbers between 1 and
500. If sum of cubes of each digit of the number is equal to the number
itself, then the number is called an Armstrong number. For example,
153 = ( 1 * 1 * 1 ) + ( 5 * 5 * 5 ) + ( 3 * 3 * 3 )

INPUT:
OUTPUT:
OBJECT:
Write a program to enter the numbers till the user wants and at the
end it should display the count of positive, negative and zeros entered.

INPUT:
OUTPUT:

OBJECT:
Write a program to add first seven terms of the following series using a
for loop:

1 / 1! + 2 /2! + 3/3! + ……

INPUT:
OUTPUT:
OBJECT:
Write a program to generate all combinations of 1, 2 and 3 using for
loop.

INPUT:
OUTPUT:

OBJECT:
Calculate the following during the input of 10 different numbers.

SUM
Average
Minimum
Maximum

INPUT:
OUTPUT:
OBJECT:
Write programs to generate following patterns:
(a) *

**

***

****

*****

******

*******

********

INPUT:
OUTPUT:

(b) 1

12

123

1234

12345

123456

INPUT:
OUTPUT:
(c)

INPUT:
OUTPUT:

(d)
********
*******
******
*****
****
***
**
*

INPUT:
OUTPUT:
(e)

**

***

****

*****

******

*******

********

INPUT:
OUTPUT:

(f)
*****
****
***
**
*

INPUT:
OUTPUT:
(g)

INPUT:
OUTPUT:

(h)

INPUT:
OUTPUT:
“Arithmetic Operators and their Precedence”
OBJECT:
Write C Sharp programs to evaluate following arithmetic expression.
(a) INPUT:

OUTPUT:
(b)INPUT:
OUTPUT:

(c)INPUT:
OUTPUT:

(d)INPUT:
OUTPUT:

OBJECT:
(a)Larib’s basic salary is input through the keyboard. His dearness
allowance is 40% of basic salary, and house rent allowance is 20% of
basic salary. Write a program to calculate his gross salary.

INPUT:
OUTPUT:
OBJECT:
(b)The distance between two cities (in km.) is input through the
keyboard. Write a program to convert and print this distance in meters,
feet, inches and centimeters.

INPUT:
OUTPUT:

OBJECT:
(c) If the marks obtained by a student in five different subjects are input through
the keyboard, find out the aggregate marks and percentage marks obtained by
the student. Assume that the maximum marks that can be obtained by a student
in each subject is 100.

INPUT:
OUTPUT:
OBJECT:
(d) Temperature of a city in Fahrenheit degrees is input through the
keyboard. Write a program to convert this temperature into Centigrade
degrees.

INPUT:
OUTPUT:
OBJECT:
(e) The length & breadth of a rectangle and radius of a circle are input
through the keyboard. Write a program to calculate the area &
perimeter of the rectangle, and the area & circumference of the circle.

INPUT:
OUTPUT:

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

INPUT:
OUTPUT:
OBJECT:
(g) 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 ‘%’)

INPUT:
OUTPUT:
OBJECT:
(h) If a five-digit number is input through the keyboard, write a
program to reverse the number.

INPUT:
OUTPUT:
OBJECT:
(i) If a four-digit number is input through the keyboard, write a
program to obtain the sum of the first and last digit of this number.

INPUT:
OUTPUT:
OBJECT:
(j) In a town, the percentage of men is 52. The percentage of total
literacy is 48. If total percentage of literate men is 35 of the total
population, write a program to find the total number of illiterate men
and women if the population of the town is 80,000.

INPUT:
OUTPUT:
OBJECT:
(k) A cashier has currency notes of denominations 10, 50 and 100. If
the amount to be withdrawn is input through the keyboard in
hundreds, find the total number of currency notes of each
denomination the cashier will have to give to the withdrawer.

INPUT:
OUTPUT:
OBJECT:
(l) If the total selling price of 15 items and the total profit earned on
them is input through the keyboard, write a program to find the cost
price of one item.

INPUT:
OUTPUT:
OBJECT:
(m) If a five-digit number is input through the keyboard, write a
program to print a new number by adding one to each of its digits. For
example if the number that is input is 12391 then the output should be
displayed as 23402.

INPUT:
OUTPUT:

Control Structures
Selection through IF/SWITCH

OBJECT:
Write a program to calculate the salary as per the following table:

& what should be taken as input and as what type?


INPUT:
OUTPUT:
OBJECT:
(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.

INPUT:
OUTPUT:

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

INPUT:
OUTPUT:
OBJECT:
(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)

INPUT:
OUTPUT:
OBJECT:
(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.

INPUT:
OUTPUT:
OBJECT:
(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.

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

INPUT:
OUTPUT:
OBJECT:
(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.

INPUT:
OUTPUT:
OBJECT:
(h) Find the absolute value of a number entered through the keyboard.

INPUT:
OUTPUT:
OBJECT:
(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.

INPUT:
OUTPUT:

OBJECT:
(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.

INPUT:
OUTPUT:
OBJECT:
(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)

INPUT:
OUTPUT:

OBJECT:
(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).

INPUT:
OUTPUT:
“IF with Logical Operators”
OBJECT:
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.

INPUT:
OUTPUT:

OBJECT:
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.

INPUT:
OUTPUT:

OBJECT:
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.

INPUT:
OUTPUT:
OBJECT:
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.

INPUT:
OUTPUT:

OBJECT:
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.

INPUT:
OUTPUT:

OBJECT:
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 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.
INPUT:

OUTPUT:

S-ar putea să vă placă și