Arnab Chakraborty has Published 4452 Articles

Program to distribute repeating integers in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 07-Oct-2021 07:52:26

117 Views

Suppose we have an array nums, there are at most 50 unique values. We also have another array called quantity, where quantity[i] denotes the amount of values the ith customer ordered.We have to check whether it is possible to distribute nums such thatThe ith customer gets exactly quantity[i] items, The ... Read More

C++ program to check how many students have greater score than first one

Arnab Chakraborty

Arnab Chakraborty

Updated on 07-Oct-2021 07:46:48

661 Views

Suppose we have n students score on five subjects. The first scores are for Kamal, and there are n-1 more scores for other students and each student has five subjects. We shall have to count number of students who have scored more than Kamal. Here we shall define one class ... Read More

C++ program to hold student info using data hiding and encapsulation

Arnab Chakraborty

Arnab Chakraborty

Updated on 07-Oct-2021 07:44:04

413 Views

Suppose we want to make student data type with data hiding and encapsulation. Students must have first_name, last_name, age and class items, but these variables cannot be accessible directly. We shall have to define some functions like get_firstname() set_firstname(), get_age() set_age() etc to retrieve and update variable values, and a ... Read More

C++ program to make student type data and display in proper format

Arnab Chakraborty

Arnab Chakraborty

Updated on 07-Oct-2021 07:39:53

124 Views

Suppose we have provided the first name, last name, age and class of a student in different lines. We shall have to write a program using structs in C++ to read them all and show in this format (age, first_name, last_name, class). The age and class will be of type ... Read More

C++ program to get length of strings, perform concatenation and swap characters

Arnab Chakraborty

Arnab Chakraborty

Updated on 07-Oct-2021 07:37:09

241 Views

Suppose we have two strings s and t, we shall have to find output in three lines, the first line contains lengths of s and t separated by spaces, the second line is holding concatenation of s and t, and third line contains s and t separated by space but ... Read More

C++ Program to take out integer from comma separated string

Arnab Chakraborty

Arnab Chakraborty

Updated on 07-Oct-2021 07:35:03

3K+ Views

Suppose we have a string where we have few integers which are separated by comma. We shall have to separate them out and display each integer in different line. To do this we shall use stringstream (under sstream library) in C++. This is one string based stream class present in ... Read More

Program to find number of ways to form a target string given a dictionary in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 07-Oct-2021 07:33:32

665 Views

Suppose we have a list of string called words, where all elements are of same length. We also have a string called target. We have to generate target using the given words under the following rules −We should generate target from left to right.To get the ith character (0-indexed) of ... Read More

C++ program to reverse an array elements (in place)

Arnab Chakraborty

Arnab Chakraborty

Updated on 07-Oct-2021 07:32:30

19K+ Views

Suppose we have an array with n different elements. We shall have to reverse the elements present in the array and display them. (Do not print them in reverse order, reverse elements in place).So, if the input is like n = 9 arr = [2, 5, 6, 4, 7, 8, ... Read More

C++ program to find addition and subtraction using function call by address

Arnab Chakraborty

Arnab Chakraborty

Updated on 07-Oct-2021 07:29:43

2K+ Views

Suppose we have two numbers a and b. We shall have to define a function that can calculate (a + b) and (a - b) both. But using a function in C++, we can return at most one value. To find more than one output, we can use output parameters ... Read More

C++ program to find greatest among four input integers

Arnab Chakraborty

Arnab Chakraborty

Updated on 07-Oct-2021 07:27:19

5K+ Views

Suppose we have four integers a, b, c and d. We shall have to find the greatest number among them by making our own function. So we shall create one max() function that takes two numbers as input and finds the maximum, then using them we shall find maximum of ... Read More

Advertisements