AmitDiwan has Published 10740 Articles

Purpose of using CHANGE command in MySQL?

AmitDiwan

AmitDiwan

Updated on 02-Jul-2020 09:10:31

187 Views

The CHANGE command in MySQL is used to rename column name. Let us first create a table −mysql> create table DemoTable796 (    StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, Name varchar(100), StudentAge int ); Query OK, 0 rows affected (0.56 sec)Let us check the description of table −mysql> desc ... Read More

How to get the count of a specific value in a column with MySQL?

AmitDiwan

AmitDiwan

Updated on 02-Jul-2020 08:16:08

2K+ Views

Let us first create a table −mysql> create table DemoTable    (       Id int,       Name varchar(100)    ); Query OK, 0 rows affected (1.40 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(100, 'John'); Query OK, 1 row affected ... Read More

PHP program to calculate the sum of square of first n natural numbers

AmitDiwan

AmitDiwan

Updated on 02-Jul-2020 07:14:49

675 Views

To calculate the sum of square of first n natural numbers in PHP, the code is as follows −Example Live DemoOutputThe sum of square of first 5 natural numbers is 125A function named ‘sum_of_squares’ is defined that takes the limit up to which square of natural number needs to be found. ... Read More

PHP program to calculate the repeated subtraction of two numbers

AmitDiwan

AmitDiwan

Updated on 02-Jul-2020 07:13:50

294 Views

To calculate the repeated subtraction of two numbers, the code is as follows −Example Live DemoOutputThe repeated subtraction results in 18A function named ‘repeated_sub’ is defined that checks to see if two values divide each other completely, and if this is true, it divides the numbers and gives the floor value ... Read More

PHP program to find the sum of odd numbers within a given range

AmitDiwan

AmitDiwan

Updated on 02-Jul-2020 07:12:39

2K+ Views

To find the sum of odd numbers within a given range, the code is as follows −Example Live DemoOutputThe sum of odd natural numbers between the numbers 3 and 23 is 141.75A function named ‘odd_num_sum’ is defined that computes the sum of odd numbers within a specific range of numbers. The ... Read More

PHP program to find the sum of first n natural numbers that are divisible by a number ‘x’ or a number ‘y’

AmitDiwan

AmitDiwan

Updated on 02-Jul-2020 07:11:37

210 Views

To find the sum of first n natural numbers that are divisible by a number ‘x’ or a number ‘y’, the code is as follows −Example Live DemoOutputThe sum of first 11 natural numbers divisible by 2 or 5 is 15A function named ‘sum_of_nums’ is defined that computes three values by ... Read More

PHP program to find the numbers within a given array that are missing

AmitDiwan

AmitDiwan

Updated on 02-Jul-2020 07:10:31

604 Views

To find the numbers within a given array that are missing, the code is as follows −Example Live DemoOutputThe missing numbers in the array is 1 2 3 4 5A function named ‘missing_nums’ is defined that checks to see if a number is missing from an array of continuous numbers. It ... Read More

PHP program to find the first natural number whose factorial can be divided by a number ‘x’

AmitDiwan

AmitDiwan

Updated on 02-Jul-2020 07:08:42

239 Views

To find the first natural number whose factorial can be divided by a number ‘x’, the code is as follows −Example Live DemoOutputThe first natural number whose factorial can be divided by 16 is 4A function named ‘factorial_num’ computes factorial of a number and checks to see if it is divisible ... Read More

PHP program to find if a number is present in a given sequence of numbers

AmitDiwan

AmitDiwan

Updated on 02-Jul-2020 07:07:49

372 Views

To find if a number is present in a given sequence of numbers, the code is as follows −Example Live DemoOutputIs the number present in the sequence? Yes, it is present in the sequenceA function named ‘contains_in_sequence’ checks to see if two values are same, and if they are equal, the ... Read More

PHP program to find the sum of cubes of the first n natural numbers

AmitDiwan

AmitDiwan

Updated on 02-Jul-2020 07:06:10

584 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

Advertisements