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

Matrix Diagonal Sum

Given a square matrix, print the sum all diagonal elements of the matrix.

Input

The first line of input will be an integer N, denoting the no. of rows in the matrix. The following N lines will contain space-separated integers denoting the elements of each row of the matrix.

Output

The output should be a single integer denoting the sum of all the 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 diagonal and anti-diagonal elements of the above matrix are 1, 3, 5, 7, 9. So the output should be 25


Sample Input

3

1 2 3

4 5 6

7 8 9

Sample Output

25




Create a class: “Question 1” with data members: 1D integer array of maximum size: 100, n (int). Create a dynamic constructor which takes input of n and n no. of array elements. Apart from taking input this class also displays the maximum and minimum elements from the given array elements.


given x = 27 ;
y = 4 ;
s = 3 ;

evaluate the given expression:

a) y*3%x

b) x + y / s

Create a class named as Recruitment which is derived from two base classes named as 

Basic qualification and interview. Basic qualification contains the Name, marks in last 

qualification, Interview class contains the marks obtained in interview. Recruitment class 

will display the message as recruited or not recruited. Criteria for recruitment is if the 

marks in last qualification is more than 80 and interview marks are greater than equal to 6 

out of 10 for interview marks. Make sure that negative marks are not allowed.


Given a square matrix, print the sum all diagonal elements of the matrix.


Rearrange Numbers in String

Given a string, write a program to re-arrange all the numbers appearing in the string in decreasing order. Note: There will not be any negative numbers or numbers with decimal part.

Input

The input will be a single line containing a string.

Output

The output should be a single line containing the modified string with all the numbers in string re-ordered in decreasing order.

Explanation

For example, if the given string is "I am 5 years and 11 months old", the numbers are 5, 11. Your code should print the sentence after re-ordering the numbers as "I am 11 years and 5 months old".

Sample Input 
I am 5 years and 11 months old
Sample Output 
I am 11 years and 5 months old


Vowel Sound

Given a sentence, write a program rotate all the words left, so that every word starts with a vowel.
Note: If there is no vowel in the word, do not rotate it.

Input

The input will be a single line containing a string.

Output

The output should be a single line containing the modified sentence with rotated words.

Explanation

For example, if the given string is "I saw a DRAGON flying in the sky", rotating each word towards left in this way "I aws a AGONDR and ingfly in eth sky", makes every word start with a vowel letter. The word "sky" is not rotated as it does not have any vowel in it. The words "I", "a", "and", "in" are not rotated as they already start with a vowel.

Sample Input 
I saw a DRAGON flying in the sky
Sample Output 
I aws a AGONDR ingfly in eth sky


Matrix Diagonal Sum

Given a square matrix, print the sum all diagonal elements of the matrix.

Input

The first line of input will be an integer N, denoting the no. of rows in the matrix. The following N lines will contain space-separated integers denoting the elements of each row of the matrix.

Output

The output should be a single integer denoting the sum of all the 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 diagonal and anti-diagonal elements of the above matrix are 1, 3, 5, 7, 9. So the output should be 25

Sample Input 
3
1 2 3
4 5 6
7 8 9
Sample Output 
25


Repeating & Non-Repeating Numbers

Given a list of numbers, find and print, the first number that occurs only once in the list and the first number that occurs more than once in the list.

Input

The input will be a single line containing space-separated integers.

Output

The first line of the output should contain the first non-repeating number. The second line of output should contain first repeating number. If there is no number fitting the given criteria, print "None" instead.

Explanation

For example, if the given list of integers are 5, 5, 4, 7, 4, 1, 11 , the first non-repeating number is 7 and the first repeating number is 5.

Sample Input 1
5 5 4 7 4 1 11
Sample Output 1
7
5

Sample Input 2
1 2 3 4 5 6 7 8 9
Sample Output 2
1
None


You are given the temperature T of an object in one of Celsius, Fahrenheit, and Kelvin scales.

Write a program to print T in all scales viz Celsius, Fahrenheit, and Kelvin.

Formula to convert from Fahrenheit F to Celsius C is C = (F - 32) * 5 / 9.

Formula to convert from Kelvin K to Celsius C is C = K - 273.

Here "C", "F", "K" represent that the temperature scale is in Celsius, Fahrenheit and Kelvin scales respectively. The input contains the temperature (a number) and the unit of the temperature scale (C, F, K) without any space. The output contains temperature in Celsius, Fahrenheit and Kelvin scales in each line in the format similar to input and the value of the temperature is rounded to 2 decimal places.




LATEST TUTORIALS
APPROVED BY CLIENTS