practical 1 4

Upload: priyanka-naik

Post on 06-Apr-2018

213 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/3/2019 Practical 1 4

    1/2

    Practical : 1

    a) Write a program that accept two double type no. from the user and display the

    addition, subtraction, multiplication, division and modulus of those two no.b) Write a program using break statement to display the following output:

    1

    22

    3334444

    55555

    Number of lines to be displayed must be accepted from the user.

    Practical: 2

    a. Write a method that compute the sum of digits of a given integer number.

    b. Write a program to print the following Pascals triangle

    1

    1 11 2 1

    1 3 3 1

    1 4 6 4 1

    1 5 10 10 5 1If we denote rows by I and the columns by j, then any element (except the

    boundry elements) in the triangle is given byPij = Pi1 j1 + Pi1j

    c. Write a C# program to illustrate the following methods of Array List :

    (i) Add (ii) CopyTo (iii) RemoveRange (iv) Insert

    d. Create a class named Integer to hold two integer values. Design a method Swap

    that could take two Integer objects as parameters and swap their contents. Write a mainprogram to implement class Integer and method Swap.

    Practical: 3

    a. Develop a program that prompts the user to input the name, door number, street,

    city and pincode and store them in the address record designed as a structure(withname, door number, street, city and pincode as its members) and display them inan appropriate manner.

    b. Write a C# program to illustrate the following methods of String Builder class(i) Append format (ii) Insert

    (iii) Remove (iv) Replace

  • 8/3/2019 Practical 1 4

    2/2

    Practical : 4

    a. Define a Time class containing the following members:

    a. Two integer data members minutes and hours

    b. Two overloaded constructorsc. One method to display the class data member

    One of the constructors take two integer parameters to assign values to two datamembers and the other constructor takes one integer parameter representing total numberof minutes and converts it into hours and minutes.

    b. Define a class named Employee that contains the following members :

    Data members to store information of employee (name, id, dept, salary)

    A method to calculate and display salary of given employee

    Define properties for the data members to access their values.

    Write a program to implement the class Employee.c. Define a base class called animal with following members

    a. A string type data member to store the name of the animal

    b. An integer member to store the age of animal in years

    c. A method to display the name and age of the animalDerive 2 classes named cat and dog. Display the content of the object by calling the

    display method on the derived objects.