Programming Articles - Page 1991 of 3366

Write a program to reverse an array or string in C++

sudhir sharma
Updated on 20-Apr-2020 11:15:49

1K+ Views

Here, we are given an array or a string of characters. We will create a program to reverse the elements of an array or string.Let’s take an example to understand the problem, Inputarray = {2, 5, 7, 1, 9}Output{9, 1, 7, 5, 2}Inputstring = “Hello!”Output!0lleHTo create a program, we will loop through the elements of the array/string(both work in the same way). Taking one variable for start and one of end. And swap both elements. Increment the start variable and decrement the end variable. The swapping will continue till start variable’s value is less than end variable.The program can be ... Read More

How to create Html5 compliant Javadoc in Java 9?

raja
Updated on 20-Apr-2020 10:20:55

273 Views

Before Java 9, we have to search in google to find out particular packages, class, interface, and method information. Since Java 9, Javadoc includes search options in the API documentation itself, and the output is HTML5 compliant.In the below example, we have created the "JavaDocTest.java" file in the "C:/JAVA" folder.Examplepublic class JavaDocTest {    /**       * Default method to be run to print       * Tutorialspoint       * @param args command-line arguments    */    public static void main(String args[]) {       System.out.println("Tutorialspoint");    } }The documentation generated by Java 9 ... Read More

Bypass Anti-virus using Veil Framework

Ajay yadav
Updated on 20-Apr-2020 06:03:20

1K+ Views

This article is intended to demonstrate, how to bypass the anti-virus detection using the Veil framework, as it is a collection of tools designed for use during penetration testing. It currently consists of the following modules −Veil-Evasion − a tool to generate antivirus-evading payloads using a variety of techniques and languagesVeil-Catapult − a psexec-style payload delivery system that integrates Veil-EvasionVeil-PowerView − a powershell tool to gain network situational awareness on Windows domainsVeil-Pillage − a modular post-exploitation framework that integrates Veil-EvasionRequirementsTo install the Veil- Framework, you are supposed to configure the latest Python packages into your machine.How to InstallThe important point ... Read More

Importance of Optional.or() method in Java 9?

raja
Updated on 17-Apr-2020 17:40:48

870 Views

In Java 9,  few static methods: stream(), or(), and ifPresentOrElse() have added to Optional class. The introduction of an Optional class solves the null pointer exception.Optional.or() method returns an Optional describing the value if a value is present, otherwise returns an Optional produced by the supplying function. Syntaxpublic Optional or(Supplier

Write an Efficient C Program to Reverse Bits of a Number in C++

sudhir sharma
Updated on 17-Apr-2020 13:29:53

1K+ Views

In this problem, we are given an unsigned integer n. Our task is to create a program that returns the number which is generated by reversing all the bits of the number.Let’s take an example to understand the problem, Inputn = 1Output2147483648Explanationbinary of 1 is 000...0001, the reverse is 100...0000.To solve this problem, we simple solution will be using a simple formula. We will loop through the binary of the number. And find the position of the set bit in the number lets say it i. The result will be calculated using the formula, ((total_number_of_bits) - 1) - iProgram to ... Read More

Write an iterative O(Log y) function for pow(x, y) in C++

sudhir sharma
Updated on 17-Apr-2020 13:57:56

562 Views

In this problem, we are given two integers x and y. Our task is to create a function that will be equivalent to pow(x, y) using an iterative approach that will complete the task in time complexity of 0(Log y).Let’s take a few examples to understand the problem, Inputx = 7 , y = 3Output343The iterative function for pow(x, y) will iterate and update the result for odd values of y multiplying it by x and update x to x2 at every iteration.Program to show the implementation of the solutionExample Live Demo#include using namespace std; void calcPower(int x, unsigned int ... Read More

Write Code to Determine if Two Trees are Identical in C++

sudhir sharma
Updated on 17-Apr-2020 13:17:27

391 Views

In this problem, we are given two trees. Our task is to write a code to check whether the two trees are identical or not.Two trees are said to be identical if elements of the arrays have the same value and orientation.ExampleAs both of the trees have the same values and position of elements both trees are identical.To check if two trees are identical, we will go from node node to each node of the and check for their equality step by step and if at any point to nodes are not equal return -1, denoting the tree are not ... Read More

Write your own memcpy() and memmove() in C++

sudhir sharma
Updated on 17-Apr-2020 13:07:34

1K+ Views

memcpy() function is an inbuilt function that is used to copy data from source location to destination location.Prototype of memcpy function −void * memcpy(void *destination_location, void *source_location, size_t size)We will character by character copy data from source to destination.Program to show the implementation of the solution,Example Live Demo#include #include void MemcpyFunc(void *dest, void *src, size_t n){    char *dataS = (char *)src;    char *dataD = (char *)dest;    for (int i=0; i

Write your own strcmp that ignores cases in C++

sudhir sharma
Updated on 17-Apr-2020 14:31:26

794 Views

Here, we have to create a strcmp (string compare) function that compares two string but ignores cases of the characters of the string. The function will return -1 if string1 < string2, 0 if string1 = string2, 1 if string1 > string2.Let’s take an example to understand the problem, Inputstring1 = “Hello” , string2 = “hello”Output0To create our own strcmp function that ignores cases while comparing the strings. We will iterate through all characters of both the strings, if characters at ith index are the same i.e. string1[i] == string2[i], continue. If string1[i] > string2[i], return 1. If string1[i] < ... Read More

Writing C/C++ code efficiently in Competitive programming

sudhir sharma
Updated on 17-Apr-2020 13:17:18

435 Views

In competitive programming, the most important thing is an effective code. Optimized and faster code is important and can make a difference in the ranks of the programmer.To write an effective c/c++ code in competitive programming, here are some effective tools for writing c/c++ code efficiently, First, let’s recall some basic terms, Template is writing code that does not depend on a particular type.Macro is a named code fragment.Vectors are like automatically resizable dynamic arrays that update size with insertion and deletion of the element.Now, let’s see some basic updates in code that can make in increasing efficiency of code, ... Read More

Advertisements