Sudhir sharma has Published 1206 Articles

XOR of Prime Frequencies of Characters in a String in C++

sudhir sharma

sudhir sharma

Updated on 20-Apr-2020 11:41:56

107 Views

In this problem, we are given a string of characters, our task is to print the XOR of frequencies of characters of the string whose frequency of occurrence is a prime number.Let’s take an example to understand the problem, Input − TutorialsPointOutput −Here, we will check the frequency of occurrence ... Read More

XOR of Sum of every possible pair of an array in C++

sudhir sharma

sudhir sharma

Updated on 20-Apr-2020 11:39:02

169 Views

In this problem, we are given an array of n elements. Our task is to generate a sequence of size n*n whose elements are the sum of a pair of all elements of A with itself. And print the xor elements of this sum array formed.Let’s take an example to ... Read More

Write a function to get Nth node in a Linked List in C++

sudhir sharma

sudhir sharma

Updated on 20-Apr-2020 11:27:28

599 Views

Here, we are given a linked list and an index. We have to write a function to get Nth node in a linked list.Let’s take an example to understand the problem, Inputlinked list = 34 -> 4 -> 9 -> 1 , n = 2Output9To go to the node specified ... Read More

Write a program that produces different results in C and C++ programming

sudhir sharma

sudhir sharma

Updated on 20-Apr-2020 11:24:53

80 Views

Write a program that compiler and runs both in c and c++ and produces different results.There are multiple types of programs that give different results when compiled in c and c++.i. Using character literals− c and c++ both treat characters differently. In C, they are treated as integer literals whereas, ... Read More

Write a program to calculate pow(x,n) in C++

sudhir sharma

sudhir sharma

Updated on 20-Apr-2020 11:22:37

287 Views

In this problem, we are given two integers x and n. Our task is to write a program to calculate the pow(x, n).Let’s take an example to understand the problem, Inputx = 5 , n = 3Output125Program to calculate the pow(x, n), Example Live Demo#include using namespace std; float myPow(float ... Read More

Write a program to Calculate Size of a tree - Recursion in C++

sudhir sharma

sudhir sharma

Updated on 20-Apr-2020 11:19:20

1K+ Views

In this problem, we are given a tree and our task is to create a program to calculate the size of the tree using recursion.The size of a tree is the total number of nodes present in the tree.Let’s take an example to understand the problem, The size of the ... Read More

Write a Program to Find the Maximum Depth or Height of a Tree in C++

sudhir sharma

sudhir sharma

Updated on 20-Apr-2020 11:18:04

583 Views

In this problem, we are given a binary tree. Our task is to write a program to find the maximum depth or height of the given tree.Let’s take an example to understand the problem, The height of the tree is 3.To find the maximum height of a tree, we will ... Read More

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

sudhir sharma

sudhir sharma

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

898 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 ... Read More

XOR counts of 0s and 1s in binary representation in C++

sudhir sharma

sudhir sharma

Updated on 17-Apr-2020 15:37:35

147 Views

In this problem, we are given a number. Our task is to find the XOR of the count of 0s and 1s in the binary representation of the number.Let’s take an example to understand the problem, Inputn = 9Output0Explanationbinary = 1001 Count of 0s = 2 Count of 1s = ... Read More

Write your own strcmp that ignores cases in C++

sudhir sharma

sudhir sharma

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

675 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 ... Read More

Advertisements