0% found this document useful (0 votes)
185 views

Assignment - C+++ - No - 01 To 16

Uploaded by

TECH ZONE
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
185 views

Assignment - C+++ - No - 01 To 16

Uploaded by

TECH ZONE
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 16
Saurabh Shukla Classes C++ Language Assignment-1 | Warm-up Write a C++ program to print Hello World on the Screen Write a C++ program to print Hello in first line and World in second line Write a C++ program to add two numbers taken from user. Write a C++ program to calculate area of circle Write a C++ program to calculate area of a rectangle Write a C++ program to calculate volume of a cuboid Write a C++ program to calculate average of three numbers. Write a C++ program to swap values of two int variables. Pp Onan rwner Write a C++ program which takes a character from user and display its ASCII code. 10. Write a C++ program to calculate simple interest. Saurabh Shukla Classes C++ Language Assignment-2 | Decision Control pena rw Write a C++ program to check whether a given number is divisible by 7 or not. Write a C++ program to check whether a triangle is right angled triangle or not. Takes lengths of the sides from the user. Write a C++ program to check whether a given number is a valid octal number or not. Write a C++ program to find nature of roots of quadratic equation Write a C++ program to compare two numbers. Write a C++ program to check whether a given number is positive, negative or zero. Write a C++ program to check whether a given number is even or odd Write a C++ program to check whether a given yearis a leap year or not. Write a C++ program to find the greater among 3 given numbers. . Write a C++ program to check whether a given character is a digit, lowercase alphabet, uppercase alphabet or a special character. Saurabh Shukla Classes C++ Language Assignment-3 | Loops PEN ansenp Write a C++ program to print first N natural numbers. Write a C++ program to print first N natural numbers in reverse order Write a C++ program to print first N even natural numbers Write a C++ program to print first N odd natural number in reverse order Write a C++ program to calculate sum of first N natural numbers Write a C++ program to print table of user’s choice Write a C++ program to calculate sum of squares of first N natural numbers. Write a C++ program to calculate factorial of a number Write a C++ program to count digits in a given number 10. Write a C++ program to calculate the sum of digits in a given number Saurabh Shukla Classes C++ Language Assignment-4 | More on Loops Write a C++ program to check whether a given number is Prime or not. Write a C++ program to print all Prime number between two given numbers Write a C++ program to print first N terms of Fibonacci series. Write a C++ program to calculate LCM of two numbers Write a C++ program to calculate HCF of two numbers Write a C++ program to find the highest value digit ina given number Write a C++ program to print binary of a given decimal number Write a C++ program to print octal of a given decimal number penny rwn Pp Write a C++ program to reverse a number 10. Write a C++ program to calculate x power y, where values of x and y are given by user. Saurabh Shukla Classes Ctt Language Assignment-5 | functions 1. Write a function to calculate area of circle. (TSRS) 2. Write a function to check whether a given number is even or odd. Return 1 if number is even, otherwise return 0. (TSRS) 3. Write a function to check whether a given number is Prime or not. Return 1 if number is Prime, otherwise return O. (TSRS) Write a function to find next Prime number of a given number. (TSRS) Write a function to print all prime numbers between two given numbers. (TSRS) Write a function to calculate factorial of a number. (TSRS) Write a function to calculate permutation of arranging r items out of n items. (TSRS) Write a function to calculate combinations of selecting r items out of n items. (TSRS) |. Write a function to print Pascal Triangle. (TSRN) 10. Write a function to calculate LCM of two numbers. (TSRS) 11. Write a function to calculate HCF of two numbers. (TSRS) 12. Write a function to print first N terms of Fibonacci series. (TSRN) PP NOP TSRS: Take Something Return Something TSRN: Take Something Returns Nothing Assignment-6 | recursion Write a recursive function to print first N natural numbers Write a recursive function to print first N natural numbers in reverse order Write a recursive function to print first N odd natural numbers Write a recursive function to print first N odd natural numbers in reverse order Write a recursive function to print first N even natural numbers Write a recursive function to print first N even natural numbers in reverse order Write a recursive function to print squares of first N natural numbers. Write a recursive function to calculate sum of first N natural numbers Write a recursive function to calculate sum of squares of first N natural numbers: . Write a recursive function to calculate sum of first n odd natural numbers . Write a recursive function to calculate sum of first N even natural numbers . Write a recursive function to calculate factorial of a number . Write a recursive function to print binary of a decimal number . Write a recursive function to print octal of a decimal number Saurabh Shukla Classes C++ Language Assignment-7 | Classes and Objects 1. Define a class Complex to represent a complex number. Declare instance member variables to store real and imaginary part of a complex number, also define instance member functions to set values of complex number and print values of complex number. 2. Define a class Time to represent Time (like 3 hr 45 min 20 sec). Declare appropriate number of instance member variables and also define instance member functions to set values for time and display values of time. 3. Define a class Box to represent a cuboid. Declare instance member variables to store dimensions of the box and also define instance member functions to set dimensions of the box and display dimensions of the Box. Define one more instance member function which returns the volume of caller object of Box. Saurabh Shukla Classes C++ Language Assignment-8 | Arrays 1. Define a class Array, which contains an int array of size 10 as instance member variable.Now define the following member functions to access this array: a. b. c d e. f. 8B. inputArrayElements() findMaxElement() findMinElement!) sort() editElement(int index, int newData) sumOfelement() averageOfElements() 2. Define a class Employee with empid, name and salary as instance member variable. Define following instance member functions in it: a. b. > oao 8B. setEmployeeld(int id) setEmployeeName(char n{]) setEmployeeSalary(float s) showEmployee() getSalary() getEmpld() getName() 3. Create an array of 10 Employees (use Employee class of que 2). Define following functions: a. b. c d. displayEmployees(Employee []) sortEmployeesBySalary(Employee []) sortEmployeeByName(Employee []) sortEmployeeByEmpld(Employee []) Saurabh Shukla Classes C++ Language Assignment-9 | static 1. Define a class Account, which contains following instance member variables a. account_no b. balance Also declare static member variable for rate of interest. Now define following member functions. (Analyze and decide which function has to be static and which has to be instance member) c. setBalance() d. setAccountNo() e. getBalance() f. getAccountNo() g. setRateOfinterest() h. getRateOfinterest() Saurabh Shukla Classes C++ Language Assignment-10 | Member Functions Define a class Complex with instance member variables to store real and imaginary part. Define member functions to set data and show deta. Also define functions to perform various mathematical operations between two objects of Complex. Following is the list of operations: a. addition b. subtraction c. mul 2. Define a class Time with instance member variables of hour min and second. Define setTime and showTime functions. Also define normalize function to make object data in standard format (min and sec should be less than 60). Also define functions for the following operations: a. Addition b. Subtraction 3. Define a class Result with instance member variables resulted, total_attempt, net_right, net_wrong, marks_for_right, marks_for_wrong. Define the following member functions: a. setResult() - it take 5 arguments for all instance variables. Set default arguments for marks_for_right and marks_for_wrong. b. showResult() 4. Define a class Operations, with static member pi with value 3.14. Define following functions a. Overloaded versions of area to calculate area of circle and area of rectangle b. Overloaded versions of add to calculate sum of two int values, sum of two float values, concatenate two strings Assignment-11 | Constructor 1. Define a class Complex with instance member variables to store real and imaginary part. Define member functions to set data and show data. Also define two constructors, one takes wo arguments to set values of real and imaginary part, second takes no argument. 2. Define a class Box with instance member variables length, breadth and height. Define instance member functions setDimensions() and showDimensions(). Also define three constructors: 2. Non-parameterized constructor. b. Takes three arguments for three dimensions ©. Take one argument which is for all three dimensions Saurabh Shula Classes G++ Language Assignment-12 | Operator Overloading, 1 Define a class Camplex with instance member variables to store real and imaginary part. Define member functions to set data and shaw data. Qverload following operators in the class a. + (binary + to add nwo complex objects) b. - (binary -to subtract complex objects) c. * (binary * to multiply complex objects) d. == (relational operator to compare two complex objects) Define a class Time with hour, min and sec as instance member variables. Define instance member functions setTime() and showTime(). Also overload following operators: a. + (binary + to add two Time objects) b. — (binary — to find difference between two Time objects) ¢. > (relational operator to compare two Time Objects) Saurabh Shukla Classes C++ Language Assignment-13 | Operator Overloading of unary operators 4 Define a class Complex with instance member variables to store real and imaginary part. Define member functions to set data and show data. Overload following operators in the class a. (unary -to negate the value of complex object) b, ++ (Pre-increment operator ++ } c. ++ (Post-increment operator ++) Define a class Time with hour, min and sec as instance member variables. Define instance member functions setTime() and showTime(). Also overload following operators: a. | (unary ! to set Time 0:0:0 if non zero time or set Time 1:0:0 if already zero) b. ++ (Pre-increment operator +4, increases 1 sec) cH (Post crement operator +4, increases 1 sec) ‘Saurabh Shukla Classes G++ Language Assignment-14 | Pointers 1. Define a class LinkedList to implement linked list data structure, Create appropriate member variables and following member functions: a. additemAtstart() additemAtLast() deleteFirstltem() deleteLastitem() viewListitems() Constructor and destructor ‘Saurabh Shukla Classes C++ Language Assignment-15 | Inheritance 1 Define a class Person with name and age as private instance member variables. Define public member functions setName() getName(), setAge(), getAge(). Now define derived class of Person, with the name Employee. Class Employee will have empid and salary as private instance member variables. Now define 8 mechanism to automatically generate empid for every new employee (define this function as protected member). Also define following pul Employee class member function: a. setémployeeData() b. showEmployeeData() c. countEmployee() Saurabh Shukla Classes Cit Language Assignment-16 | File Handling vpuNe Write a program to copy one file data and write into another file. ‘Write a program to count words in a file Write a program to search a word in a file ‘Write a program to count lines in a CPP fie rite a program of book record management, Define a class Book with booki price as instance member variables. Also define following functions: a. inputBook() b. showBook() c.storeBook!) 4. viewAllBooks() ©. searchBook() f deleteBook() & editBook()

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy