Sort an Array in Ascending Order in C

Bhanu Priya
Updated on 10-Dec-2024 13:01:40

123K+ Views

Problem Sort the given array in descending or ascending order based on the code that has been written. Solution An array is a group of related data items which share’s a common name. A particular value in an array is identified with the help of its "index number". Declaring array The syntax for declaring an array is as follows − datatype array_name [size]; For example, float marks [50] It declares ‘marks’ to be an array containing 50 float elements. int number[10] It declares the ‘number’ as an array to contain a maximum of 10 integer constants. Each element is identified ... Read More

What is a Watering Hole Attack? Definition, Prevention, and Examples

ARPON KUMAR CHOWDHURY
Updated on 10-Dec-2024 12:16:43

320 Views

Attackers always come up with new ways to breach networks and steal confidential data for all users in the field of cybersecurity. A cybersecurity issue known as the "watering hole attack" occurs when any particular hacker compromises websites that a certain user base is known to visit regularly to target their initial activities.After hacking the website, the attackers infect visitors' computers or phones with malware functions within the system. They rely on the fact that this website is frequently visited by the group they wish to target all the particular information. Attackers can infiltrate people's devices to steal confidential information ... Read More

Find Minimum Sum of Factors of a Number in Java

AmitDiwan
Updated on 09-Dec-2024 21:56:39

503 Views

In mathematics, the factors of a number are the integers that divide the number without leaving a remainder. For a given number, finding the minimum sum of its factors involves identifying a pair of factors whose sum is the smallest among all possible factor pairs. In this article, we will learn to find the minimum sum of factors of a number we will be using the Integer class and Math class in Java − Integer class The Java Integer class serves as a wrapper for the primitive int type, encapsulating a single integer value within an object. For Integer.MAX_VALUE, which provides ... Read More

Check if a String is a Literal or an Object in JavaScript

Mayank Agarwal
Updated on 09-Dec-2024 21:56:22

3K+ Views

In this article, we will be exploring strings and how they can be used as a literal and an object depending on the requirements. In JavaScript, strings can exist in two forms: String Literal: Created using quotes (', ", or `).String Object: Created explicitly using the String constructor, e.g., new String("text"). JavaScript Literals A JavaScript literal can be referred to as representing fixed values in source code. In most languages, values are denoted by Integers, floating-point numbers, strings, boolean, characters, arrays, records, and many more. JavaScript Objects On the other hand, a JavaScript object can be defined as a list of ... Read More

JavaScript Robotics: Controlling Hardware with Johnny-Five and Arduino

Mukul Latiyan
Updated on 09-Dec-2024 21:56:02

530 Views

JavaScript is no longer limited to web development; it has expanded into controlling hardware devices, thanks to frameworks like Johnny-Five. Johnny-Five is a powerful and user-friendly JavaScript robotics library that allows developers to interact with hardware components like LEDs, motors, sensors, and more using microcontrollers such as Arduino. What is Johnny-Five? Johnny-Five is a JavaScript robotics and IoT (Internet of Things) platform that allows you to control hardware devices using JavaScript. It provides a simple and intuitive API that abstracts the complexities of working with electronics, making it easier for developers to prototype and experiment with physical computing projects. Johnny-Five ... Read More

Convert String to Integer in C++

Arnab Chakraborty
Updated on 09-Dec-2024 18:40:33

13K+ Views

C++ is a statically typed language. To write programs we need to define variables of specified types. Sometimes we need to read inputs from the console or files. In such a scenario the string data are read into the program. To convert them into other datatypes needs special operations. In this article, we shall discuss how to convert strings to integers in C++. There are a few different techniques to do so. Let us explore them one by one. String to Integer Using stringstream Class C++ uses streams for different applications. Such streams are filestreams, standard input/output streams, etc. There ... Read More

Swap Two Arrays Without Using Temporary Variable in C

Bhanu Priya
Updated on 09-Dec-2024 16:53:46

6K+ Views

Swap two arrays without using a temporary variable. We will use arithmetic and bitwise Operators instead of a third variable. The logic to read the first array is as follows − printf("enter first array ele:"); for(i = 0; i < size; i++){ scanf("%d", &first[i]); } The logic to read the second array is as follows − printf("enter first array ele:"); for(i = 0; i < size; i++){ scanf("%d", &first[i]); } The logic to swap the two arrays without using a third variable is as follows − for(i = 0; i < size; i++){ ... Read More

Convert Binary to Hex Using C Language

Bhanu Priya
Updated on 09-Dec-2024 16:44:29

11K+ Views

Binary numbers are represented in 1’s and 0’s. It can also be referred to as a rational number with a finite representation in the system. This is a quotient of an integer by a power of two. Hexadecimal number system with 16 digits is {0, 1, 2, 3…..9, A(10), B(11), ……F(15)}. In base 16 transfer encoding, each byte of plain text is divided into two 4-bit values, which are represented by two hexadecimal digits. Converting Binary to Hex using C To convert from binary to hexadecimal representation, the bit string is grouped into 4-bit blocks, called nibbles, starting from the ... Read More

Align Output Using Justifications in C Language

Mandalika
Updated on 09-Dec-2024 16:37:29

21K+ Views

By using justifications in the printf statement, we can format the data in various ways. To implement the right justification, insert a minus sign before the width value in the %s character. printf("%-15s", text); Program 1 The example below prints a table with name and amounts, formatted in two columns with fixed widths for better alignment, using printf() for row and column-wise output. #include int main(){ char a[20] = "Names", b[20]="amount to be paid"; char a1[20] = "Bhanu", b1[20]="Hari", c1[20]="Lucky", d1[20]="Puppy"; int a2 = 200, b2 = 400, c2 = ... Read More

Sorting Techniques in C Language

Bhanu Priya
Updated on 09-Dec-2024 16:28:32

44K+ Views

In this article, we are going to learn about the different sorting techniques and their implementations in C language. Sorting in C programming requires rearranging elements in the array into a determined order, i.e., in ascending or descending order. This will use the comparison operator to specify the new order of a list or array. This is widely used in different applications that include searching algorithms, data structure optimization, and database management. The following are the sorting techniques that we can implement with C language and other programming also: ... Read More

Advertisements