
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
AmitDiwan has Published 10744 Articles

AmitDiwan
547 Views
To find the sum of cubes of the first n natural numbers, the code is as follows −Example Live DemoOutputThe sum of cubes of first 8 natural numbers is 1296A function named ‘sum_of_cubes’ is defined that initializes a sum to 0. Every natural number is multiplied by itself thrice (cube) and ... Read More

AmitDiwan
389 Views
To find the sum of the first n natural numbers who are not powers of a specific number ‘k’, the code is as follows −Example Live DemoOutputThe sum of fist 20 natural numbers that are not powers of 3 is 198A function named ‘sum_of_nums’ is defined and it calculates the sum ... Read More

AmitDiwan
207 Views
To find the sum of the 5th powers of first n natural numbers, the code is as follows −Example Live DemoOutputThe sum of fifth powers of the first n natural numbers is 85648386825A function named ‘sum_of_fifth_pow’ is defined, and an initial sum value is defined as 0. The fifth power of ... Read More

AmitDiwan
842 Views
To find the average of the first n natural numbers that are even, the code is as follows −Example Live DemoOutputThe average of the first n natural numbers that are even is 12A function named ‘even_nums_avg’ is defined that adds up all the numbers up to a given limit, and divides ... Read More

AmitDiwan
297 Views
To find the sum of cubes of natural numbers that are odd, the code is as follows −Example Live DemoOutputThe sum of cubes of first 8 natural numbers that are even is 3968A function named ‘sum_of_cubes_even’ is defined that takes a limit on the natural number up to which the cube ... Read More

AmitDiwan
233 Views
To check if the total number of divisors of a number is even or odd, the code is as follows −Example Live DemoOutputIt is an odd numberA function named ‘divisor_count’ is defined that gives the number of divisors of a given number that is passed as a parameter to the function. ... Read More

AmitDiwan
960 Views
Yes, an alternative is CONCAT_WS(). Let us first create a table −mysql> create table DemoTable ( StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentName varchar(100) ); Query OK, 0 rows affected (0.74 sec)ExampleInsert some records in the table using insert command −mysql> insert into DemoTable(StudentName) values('Chris'); ... Read More

AmitDiwan
2K+ Views
To split a given comma delimited string into an array of values, the PHP code is as follows −Example Live DemoOutputThe array is Array ( [0] => 456 [1] => 789 [2] => 23 [3] => 4 [4] => 019 ) The array is Array ( ... Read More

AmitDiwan
1K+ Views
To remove non-alphanumeric characters from string, the code is as follows −Example Live DemoOutputThe non-alphanumeric characters removed gives the string as ThisissampleonlyThe function ‘preg_replace’ is used to remove alphanumeric characters from the string. A regular expression is used to filter out the alphanumeric characters. The string is previously defined and the ... Read More