Java Program to Find the Sum and Product of Elements in a Row/Column

This is the Java Program to Find the Sum and Product of Elements in a Row/Column. Problem Description Given a square matrix, print the sum and product of the elements in each row and column. Example: Matrix: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Output: Sum … Read more

advertisement

Java Program to Find the First Capital Letter/Small Letter/Vowel/Consonant/Number/White Space/Special Character in a Given String

This is the Java Program to Find the First Capital Letter/Small Letter/Vowel/Consonant/Number/White Space/Special Character in a Given String. Problem Description Given a string, find the first position of the capital letter, small letter, vowel, consonant, whitespace, and special character if present in the string. Example: String x = “Ac @” Output = Capital letter = … Read more

advertisement

Java Program to Implement Heap Sort on an Array of n Elements

This is the Java Program to Implement Heap Sort on an Array of n Elements. Problem Description Given an array of integers, sort the array using heap sort algorithm. Problem Solution The idea is to create a max heap of the array elements. Then, obtain the maximum element from the heap, interchange it with the … Read more

advertisement

Java Program to Implement the pow() Function

This is the Java Program to Implement the pow() Function. Problem Description Given a value say x, and an exponent n, write a program to calculate x raised to the power n. Problem Solution The value x raised to the power n can be calculated, using a simple recursive algorithm. If the exponent is 1 … Read more

advertisement

Java Program to Implement Heap Sort Using a Priority Queue

This is the Java Program to Implement Heap Sort Using a Priority Queue. Problem Description Given an array of integers, sort the array using heap sort which uses a priority queue. A priority queue is a min-heap in which every node is smaller than its elements. Problem Solution Add all the elements of the array … Read more

advertisement

Java Program to Find the Sum of n Cube Numbers

This is the Java Program to Find the Sum of n Cube Numbers. Problem Description Given an integer says n, find out the sum of the first n cubed numbers. Problem Solution The sum of the first n cubed numbers can be calculated using the formula : sum = (n*(n+1)/2)2 Program/Source Code Here is the … Read more

advertisement

Java Program to Find the Sum of n Square Numbers

This is the Java Program to Find the Sum of n Square Numbers. Problem Description Given an integer says n, find out the sum of the first n squared numbers. Problem Solution The sum of the first n squared numbers can be calculated using the formula : sum = n*(n+1)*(2n+1)/6 Program/Source Code Here is the … Read more

advertisement

Java Program to Print the First n Square Numbers

This is the Java Program to Print the First n square Numbers. Problem Description Given an integer says n, write a java program to print the first n squared numbers. Problem Solution Iterate through the loop from 1 to n and print the square of the loop variable. Program/Source Code Here is the source code … Read more

advertisement

Java Program to Implement the cos() Function(approximately)

This is the Java Program to Implement the cos() Function (approximately). Problem Description Given an angle say x, in degrees find out the cosine of the angle approximately. Problem Solution The cosine of an angle x can be calculated using the following equation cos x = 1 – (x2)/2! + (x4)/4! – (x6)/6! + ….. … Read more

advertisement

Java Program to Implement the sin() Function (approximately)

This is the Java Program to Implement the sin() Function (approximately). Problem Description Given an angle say x, in degrees find out the sine of the angle approximately. Problem Solution The sine of an angle x can be calculated using the following equation sin x = x – (x3)/3! + (x5)/5! – (x7)/7! + ….. … Read more

advertisement
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage, Advanced C Programming, SAN Storage Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him @ LinkedIn | Youtube | Instagram | Facebook | Twitter