Programming & Computer Science Answers

C++ 9913
Python 5288
Java | JSP | JSF 3611
C 1680
C# 1362
Computer Networks 989
Algorithms 652
Databases | SQL | Oracle | MS Access 641
HTML/JavaScript Web Application 588
Other 537
Visual Basic 358
Assembler 209
Software Engineering 202
AJAX | JavaScript | HTML | PHP 166
MatLAB 150
MatLAB | Mathematica | MathCAD | Maple 124
Action Script | Flash | Flex | ColdFusion 112
UNIX/Linux Programming 89
Web Development 73
Excel 36
ASP | ASP.NET 23
Delphi | Pascal 21
Perl 16
Prolog 9
Functional Programming 9
MathCAD 5
Wolfram Mathematica 4
WPF 4
Ruby | Ruby on Rails 3
NodeJS Web Application 2

Questions answered by Experts: 26 876

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search

Elements of Anti Diagonal
Write a program to print the anti-diagonal elements in the given matrix.
Input
The first line of input will contain an integer N, denoting the number of rows and columns of the input matrix.
The next N following lines will contain N space-separated integers, denoting the elements of each row of the matrix.
Output
The output should be a list containing the anti-diagonal elements.
Explanation
For example, if the given N is 3, and the given matrix is
1 2 3
4 5 6
7 8 9
The anti diagonal elements of the above matrix are 3, 5, 7. So the output should be the list
[3, 5, 7]
Sample Input 1
3
1 2 3
4 5 6
7 8 9
Sample Output 1
[3, 5, 7]
Sample Input 2
5
44 71 46 2 15
97 21 41 69 18
78 62 77 46 63
16 92 86 21 52
71 90 86 17 96
Sample Output 2
[15, 69, 77, 92, 71]
Max Contiguous Subarray
Given a list of integers, write a program to identify the contiguous sub-list that has the largest sum and print the sum. Any non-empty slice of the list with step size 1 can be considered as a contiguous sub-list.
Input
The input will contain space-separated integers, denoting the elements of the list.
Output
The output should be an integer.
Explanation
For example, if the given list is [2, -4, 5, -1, 2, -3], then all the possible contiguous sub-lists will be,
[2]
[2, -4]
[2, -4, 5]
[2, -4, 5, -1]
[2, -4, 5, -1, 2]
[-4]
[-4, 5]
[-4, 5, -1]
[-4, 5, -1, 2]
[5]
[5, -1]
[5, -1, 2]
[-1]
[-1, 2]
[2]
Among the above contiguous sub-lists, the contiguous sub-list [5, -1, 2] has the largest sum which is 6.
Sample Input 1
2 -4 5 -1 2 -3
Sample Output 1
6
Sample Input 2
-2 -3 4 -1 -2 1 5 -3
Sample Output 2
7
First and Last Digits
Given two integers M and N, write a program to count of the numbers which have the same first and last digits in the given range M to N (inclusive of M and N).
Input

The first line of input will contain a positive integer M.
The second line of input will contain a positive integer N.
Output

The output should be an integer denoting the count of the numbers in the range which meet the given condition.
Explanation

For example, if the given numbers are M is 5 and N is 30, the numbers which have the first and last digit equal in the given range (5, 6, ..., 29, 30) are 5, 6, 7, 8, 9, 11 and 22. So the output should be 7.
Sample Input 1
5
30
Sample Output 1
7

Sample Input 2
1
10
Sample Output 2
9
First and Last Digits
Given two integers M and N, write a program to count of the numbers which have the same first and last digits in the given range M to N (inclusive of M and N).
Input

The first line of input will contain a positive integer M.
The second line of input will contain a positive integer N.
Output

The output should be an integer denoting the count of the numbers in the range which meet the given condition.
Explanation

For example, if the given numbers are M is 5 and N is 30, the numbers which have the first and last digit equal in the given range (5, 6, ..., 29, 30) are 5, 6, 7, 8, 9, 11 and 22. So the output should be 7.
Sample Input 1
5
30
Sample Output 1
7

Sample Input 2
1
10
Sample Output 2
9

Create a class Account with the following members

protected data members:

integer accno,name as char array ,float balance

public member functions:

empty constructor- It initialize the accno as zero,name as "NIL" and balance as 0.

parameterized constructor-It initialize the class members using input parameters.

copy constructor-It is used to copy the content from one object(received as argument) to another object.

void display()-This function is used to display the details such as accno, name & balance which are separated by a space.

destructor- It display the string "object destruction,".

Main method:

Create an object A1 of type Account(it should call empty constructor).

Get three inputs from user such as accno, name & balance.

Create an object A2 of type Account and pass parameters to parameterized constructor. i.e. A2(accno,name,balance).

Create an object A3 and assign value of object A2 into A3 by using copy constructor.

Finally call display method for objects A1,A2,A3.


Design a C++ program having a base class Student with data member rollno and member functions getnum() to input rollno and putnum() to display rollno. The class Test is derived from class Student with data member marks (Three subject marks) and member functions getmarks() to input marks and putmarks() to display marks. The class Sports is also derived from class Student with data member score (range between 100) and member functions getscore() to input score and putscore() to display score. The class Result is inherited from two base classes, class Test and class Sports with data member total and a member function display() to display rollno, marks, score and the total (marks + score).


The postage for ordinary post is Rs. 2.00 for the first 15 grams and Rs. 1.00 for each additional 10 grams. Write a C++ program to calculate the charge of postage for a post weighting N grams. Read the weights of N packets and display the total amount of postage using multiple inheritance.


* Base class-1: Member variables are name, source and destination.


* Base class-2: Member variables are no. of packets and weight.


* Derived class: Member functions display(), displays the name, source, destination, total weight and total amount.


Develop a code for the multiple inheritance diagram given below


· The experience details class consisting of data members such as name and total experience.


· The salary details class consisting of data members such as salary.


· The education details class consisting of data members such as degree.


· The promotion class consisting of member function promote() to find the employee promotion for higher grade on satisfying the condition total experience to be greater than 10 and salary to be greater than Rs. 20,000 and the degree qualification to be “PG”, print "PROMOTED FOR HIGHER GRADE". otherwise the employee is not eligible for promotion, print "PROMOTION IS NOT ELIGIBLE


create a class Customer with the following members:

Member variables: cid(integers) and cbalance (float).

Member functions:

Default(empty) constructor: It assigns cid and cbalance value as zero(0). Finally it print "Default Assignment".

Parameterized constructor: It receives two arguments and assign it to cid and cbalance.

void display(): This method display the values of cid and cbalance which are separated by a space.

Main method:

Implement the below code in main method and check your program output.

int main()

{

int cid;

float cbalance;

cin>>cid>>cbalance;

Customer obj1;

Customer obj2(cid,cbalance);

obj1.display();cout<<endl;

obj2.display();

return 0;

}


An automobile financier claims to be lending money at simple interest where the Principle and Year are the input and Rate of Interest is 12%. Write a C++ program to calculate it using default arguments.


LATEST TUTORIALS
APPROVED BY CLIENTS