AYUSH MISHRA

AYUSH MISHRA

112 Articles Published

Articles by AYUSH MISHRA

Page 10 of 12

Check If a Number Is Greater Than Zero in C++

C++
AYUSH MISHRA
AYUSH MISHRA
Updated on 07-Jan-2025 4K+ Views

Problem Description In this problem, we are given a number and have to check whether this number is greater than zero. Using the if-else and ternary approach to check if the given number is greater than zero, equal to zero, or less than zero. In this article, we will discuss how we can find if a given number is greater than zero or not in C++. Prerequisite If-else operator: This operator allows the program to execute certain code blocks based on whether a condition is true or false. Syntax of If-else operator if (condition) { // ...

Read More

Find the duplicate in an array of N+1 integers using C++

C++
AYUSH MISHRA
AYUSH MISHRA
Updated on 06-Jan-2025 4K+ Views

Problem Description In this problem, we are given an array that contains all unique elements except one element which is present exactly two times in the array. We have to return that element which is present two times in the array. In this article, we are going to learn how we can find duplicates in an array of N+1 integers in C++. Example Input: array = {1, 3, 4, 2, 2} Output: 2 Explanation: 2 is the only element in the array that occurs two times. Approaches to Find Duplicate Element in an Array ...

Read More

Calculating the Area of a Triangle Using Heron’s Formula in C++

C++
AYUSH MISHRA
AYUSH MISHRA
Updated on 31-Dec-2024 6K+ Views

Problem Description We are given the three sides of a triangle, and we have to calculate the area of the triangle using Heron's formula. In this article, we are going to discuss how we can calculate the area of a triangle using Heron's Formula in C++. Heron's Formula The formula for calculating the semi-perimeter of the triangle is: s = (a + b + c) / 2 Then, apply Heron's formula to calculate the area of the triangle. Heron's formula for calculating the area of the triangle is: Area = √ s * (s - a) * (s - ...

Read More

C++ Program to Subtract Two Numbers

C++
AYUSH MISHRA
AYUSH MISHRA
Updated on 30-Dec-2024 17K+ Views

Problem Description In this problem, we are given two numbers and we have to find the value obtained after subtracting one number from another. In this article, we are going to learn how we can subtract two numbers in C++ using different approaches. Example 1 Input number1 = 8number2 = 12 Output 4 Explanation The subtraction of number2 - number1 i.e. 12 - 8 will result in 4. Example 2 ...

Read More

Missing Number in an array in O(1) Time Complexity

AYUSH MISHRA
AYUSH MISHRA
Updated on 30-Dec-2024 5K+ Views

Problem Description We are given an array that contains numbers from 1 to n, and one number is missing between the given numbers from 1 to n. We have to return the missing number in O(1) time complexity. In this problem, we are going to discuss how we can find the missing number in an array. Example 1 Input: array = {1, 2, 3, 5, 6, 7} Output: 4 Explanation From 1 to 7, the number 4 is missing in the given array. Example 2 ...

Read More

How to Copy a Tensor in PyTorch?

AYUSH MISHRA
AYUSH MISHRA
Updated on 27-Dec-2024 10K+ Views

PyTorch is a very popular Python library used in machine learning. This library is developed by Facebook AI. This library provides robust tools for deep learning, neural networks, and tensor computations. Below are different approaches to Copying a Tensor in PyTorch. Using clone() function Using detach() method Using copy.deepcopy() method Using clone() function We use the clone() method to create a deep copy of a tensor. In deep copy, the original tensor and the copied tensor do not share memory. If we make changes in copied ...

Read More

How to Insert Multiple Elements at Given Positions in a Vector?

C++
AYUSH MISHRA
AYUSH MISHRA
Updated on 24-Dec-2024 6K+ Views

What is a Vector in C++?A vector is a dynamic array as the size of the vector changes during the program's execution. If we insert more elements in the vector it expands its size and if we remove elements from the vector it shrinks in size. A vector is part of the Standard Template Library (STL). Problem DescriptionIn this problem, we are given a vector and have to insert an element at a certain position. In this article, we are going to learn how to insert multiple positions in a vector in C++ using different approaches. Below are some examples to ...

Read More

Sum of a Geometric Progression in C++

C++
AYUSH MISHRA
AYUSH MISHRA
Updated on 11-Dec-2024 7K+ Views

What is Geometric Progression? A geometric progression is a sequence of numbers where each term is obtained by multiplying the previous term by a fixed number. This fixed number is known as the common ratio and it should be a non-zero. In this article, we are going to learn how we can find the sum of given n terms in geometric progression in C++. We are given first-term, common ratio, and number of terms for which we have to find the sum of geometric progression. Formula for Calculating Sum of Geometric Progression Sn= a (1 - rn)/(1 - r)  ...

Read More

Pythagorean Triplet in an Array Using C++

C++
AYUSH MISHRA
AYUSH MISHRA
Updated on 09-Dec-2024 34K+ Views

Pythagorean Triples Pythagorean triples are a set of three distinct numbers a, b, and c which satisfy the condition: a2 + b2 = c2 These numbers a, b, and c are known as Pythagorean triples. We can say that these three numbers represent the sides of a right-angled triangle. These three sides are known as triplets of the array. Problem Description We are given an array of integers, and we have to find if there exist three distinct numbers in the array which form the Pythagorean triplet in C++. Below are examples to demonstrate the problem statement clearly: ...

Read More

Best Package Managers for Windows

AYUSH MISHRA
AYUSH MISHRA
Updated on 09-Dec-2024 10K+ Views

Package Managers is a tool used to install and update software easily in Windows. There are different tools that we need to use daily while working as software engineers. A package manager is used to install, update, manage, and uninstall software and applications. It simplifies the process, saves time, and ensures consistency. It operates through a command-line interface (CLI) which allows us to execute tasks like installing or updating software with a single command. It handles everything in the background, including dependencies. It improves security by preventing malicious software from downloading and installing all applications from official and trustworthy sources. ...

Read More
Showing 91–100 of 112 articles
« Prev 1 8 9 10 11 12 Next »
Advertisements