The abs, labs, and llabs Functions in C/C++

sudhir sharma
Updated on 04-Oct-2019 08:00:18

1K+ Views

What are Integer Functions in C Library?Integer functions are those functions which returns the exact value of an integer. C only supports integer values. In this function the nearest integer which is less than or equal to the argument returns to this function.Types of Integer functions −int = abs (int n); long = labs (long n); long long = llabs (long long n);where n = integer valueWhat is abs(), labs(), llabs() functions ?They are defined as (C Standard General Utilities Library) header file. They give the exact value of integer that is input to them as their argument.abs() function ... Read More

Set Auto Increment Value to Begin from 1 in MySQL

AmitDiwan
Updated on 04-Oct-2019 07:58:49

495 Views

You can truncate the table to set auto_increment value to start from 1 in MySQL. Let us first create a table −mysql> create table DemoTable (    StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY ); Query OK, 0 rows affected (1.44 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(); Query OK, 1 row affected (0.35 sec) mysql> insert into DemoTable values(); Query OK, 1 row affected (0.30 sec) mysql> insert into DemoTable values(); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable values(); Query OK, 1 row affected (0.06 sec)Display all records ... Read More

C++ Sum Array Puzzle

sudhir sharma
Updated on 04-Oct-2019 07:57:36

274 Views

Array is a data structure that stores multiple elements of the same data type. It can store entire set of values at once. But its length needs to be defined beforehand.In this sum array puzzle, we are given an array A1 of a definite size say n. In order to solve this puzzle, we will create an array called S1 that stores the sum of all elements of the array except the element whose position is being used. For example, if S1[3] is being calculated then we will find the sum of all elements of A1 except the element at ... Read More

Shutdown a System in C/C++

sudhir sharma
Updated on 04-Oct-2019 07:54:57

439 Views

A program to shutdown the system works on the operating systems like windows, linux or macOS. To shut it off and close all opened applications.What shut down or power off means?Shut down or Power off a computer means removing power from a computer's main components in an organised prescribed way and turning off all the works that are done by the computer i.e. all applications and processings are shut off. After a computer is shut down, the main components such as CPU, RAM modules and hard disk drives are powered down, although some internal components, such as an internal clock, ... Read More

Return Value of a Number Raised to the Power in MySQL

AmitDiwan
Updated on 04-Oct-2019 07:53:54

116 Views

No, ^ is the Bitwise XOR operator in MySQL. For this, use POW() or POWER() from MySQL. Let us first create a table &minuns;mysql> create table DemoTable (    BaseValue int,    PowerValue float ); Query OK, 0 rows affected (0.48 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(4, 1.9867); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values(10, 6.789); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values(20, 8.9); Query OK, 1 row affected (0.14 sec)Display all records from the table using select statement −mysql> select *from ... Read More

Find Area of Largest Triangle Inscribed in a Hexagon using C++

sudhir sharma
Updated on 04-Oct-2019 07:52:34

294 Views

Find the area of largest Triangle inscribed in a hexagon we need to learn these figures are and how 1 is inscribed inside other.Triangle is a closed figure with 3 sides which may be equal or different size.Hexagon is a closed figure with 6 sides which may be equal or unequal in size.A triangle inscribed inside a hexagon has all its vertices touching vertices of hexagon. So, the sides of the triangle can be treated as diagonals of a regular hexagon. The hexagon considered here is a regular hexagon, which leads to make the largest triangle an Equilateral triangle.Let’s derive ... Read More

Display Records with SUM Between a Specific Range in MySQL

AmitDiwan
Updated on 04-Oct-2019 07:51:33

442 Views

Let us first create a table −mysql> create table DemoTable (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    CustomerName varchar(20),    ProductPrice int ); Query OK, 0 rows affected (0.70 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(CustomerName, ProductPrice) values('Chris', 600); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable(CustomerName, ProductPrice) values('David', 450); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable(CustomerName, ProductPrice) values('Chris', 980); Query OK, 1 row affected (0.40 sec) mysql> insert into DemoTable(CustomerName, ProductPrice) values('Mike', 1200); Query OK, 1 row affected (0.11 sec) mysql> insert into ... Read More

Display Duplicate Records as Distinct Values in MySQL

AmitDiwan
Updated on 04-Oct-2019 07:47:06

624 Views

For this, you can use GROUP_CONCAT(). You also need to use DISTINCT to fetch distinct records. Let us first create a table −mysql> create table DemoTable(    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    Name varchar(40),    Score int ); Query OK, 0 rows affected (0.53 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(Name, Score) values('Chris', 56); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable(Name, Score) values('Robert', 78); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable(Name, Score) values('Chris', 56); Query OK, 1 row affected (0.42 sec) mysql> insert ... Read More

Sum Selected Column Values Based on Specific Month Records in MySQL

AmitDiwan
Updated on 04-Oct-2019 07:44:57

374 Views

Let us first create a table −mysql> create table DemoTable (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    PurchaseDate date,    SalePrice int ); Query OK, 0 rows affected (0.51 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(PurchaseDate, SalePrice) values('2018-01-10', 450); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable(PurchaseDate, SalePrice) values('2019-12-25', 1000); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable(PurchaseDate, SalePrice) values('2016-12-02', 5560); Query OK, 1 row affected (0.07 sec) mysql> insert into DemoTable(PurchaseDate, SalePrice) values('2015-02-20', 4550); Query OK, 1 row affected (0.18 sec) mysql> insert into ... Read More

Does UPDATE Overwrite Identical Values in MySQL

AmitDiwan
Updated on 04-Oct-2019 07:42:42

493 Views

No, MySQL UPDATE won’t overwrite values if they are identical. Let us first create a table −mysql> create table DemoTable (    StudentId int,    StudentMathMarks int,    StudentMySQLMarks int ); Query OK, 0 rows affected (0.46 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(1, 56, 78); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable values(2, 88, 99); Query OK, 1 row affected (0.15 sec) mysql> inse rt into DemoTable values(3, 34, 98); Query OK, 1 row affected (0.13 sec)Display all records from the table using select statement −mysql> select *from ... Read More

Advertisements