Sunidhi Bansal

Sunidhi Bansal

809 Articles Published

Articles by Sunidhi Bansal

Page 80 of 81

Print the given 3 string after modifying and concatenating

Sunidhi Bansal
Sunidhi Bansal
Updated on 30-Jul-2019 291 Views

Input three strings and replace each string with a character which user has entered and then display edited strings. After that, concatenate edited strings and display them.Input:    string 1 : tutorials replacement character for string 1 : x    String 2 : points replacement character for string 2 : y    String 3: best replacement character for string 3 : z Output :    string 1: xxxxxxxxx    String 2 :yyyyyy    String 3 : zzzz    After concatenation : xxxxxxxxxyyyyyyzzzzAlgorithmSTART Step 1-> declare three array of characters str1, str2 and str3 with variables as ch1, ch2 and ch3 ...

Read More

Print elements that can be added to form a given sum

Sunidhi Bansal
Sunidhi Bansal
Updated on 30-Jul-2019 261 Views

Input number of elements user want to enters and than input the total value user want to calculate from the given list of elements.Input : N=5    Enter any 5 values : 3 1 6 5 7    Enter sum you want to check : 10 Output : 3 1 6AlgorithmSTART STEP1-> Take values from the user STEP2-> Take the sum a user want to check in the set. STEP3-> For i = 0; i < n; i++ STEP4-> Check If sum - *(ptr+i) >= 0 then,    STEP4.1-> sum -= *(ptr+i);    STEP4.2-> Print the value of *(ptr+i) END ...

Read More

Print missing elements that lie in range 0 &ndash; 99

Sunidhi Bansal
Sunidhi Bansal
Updated on 30-Jul-2019 256 Views

It will display the missing values from the given set entered by the userGiven : array = {88, 105, 3, 2, 200, 0, 10}; Output : 1 4-9 11-87 89-99AlgorithmSTART STEP 1-> Take an array with elements, bool flag[MAX] to Fale, int i, j, n to size of array Step 2-> Loop For from I to 0 and i=0       Set flag[array[i]]=true    End IF Step 3 -> End For Loop Step 4 -> Loop For from i to 0 and i=0) {          flag[array[i]] = true; //Making the value of the elements present in ...

Read More

Print uncommon elements from two sorted arrays

Sunidhi Bansal
Sunidhi Bansal
Updated on 30-Jul-2019 2K+ Views

Given two sorted arrays and output should display their uncommon elementsGiven : array1[]= {1, 4, 6, 9, 12}    array2[]= {2, 4, 7, 8, 9, 10} Output : 1 2 6 7 8 10 12AlgorithmSTART Step 1 -> declare two arrays array1 and array2 with elements as int and variables n1, n2, i to 0 and j to 0 Step 2 -> calculate number of elements in array1 sizeof(array1)/sizeof(array1[0]) Step 3-> calculate number of elements in array2 sizeof(array2)/sizeof(array2[0]) Step 4 -> Loop While till i loop While i < n1 && array1[i]!=array2[j]    Print array1[i++] Step 7 -> End Loop ...

Read More

Print first N terms of series (0.25, 0.5, 0.75, &hellip;) in fraction representation

Sunidhi Bansal
Sunidhi Bansal
Updated on 30-Jul-2019 247 Views

Input N which is equivalent to the number till where series should be printedInput : N=5 Output : 0 ¼ ½ ¾ 1AlgorithmSTART Step 1 -> declare start variables as int num , den, i, n Step 2 -> input number in n Step 3 -> Loop For from i to 0 and i End For Loop STOPExample#include int main(int argc, char const *argv[]) {    int num, den;    int i, n;    printf("Enter series limit");    scanf("%d", &n); //Till where the series will be starting from zero    for (i = 0; i < n; i++) { ...

Read More

Print numbers in descending order along with their frequencies

Sunidhi Bansal
Sunidhi Bansal
Updated on 30-Jul-2019 561 Views

Given with an array of int elements, the task is to arrange the elements in descending order and finding their occurrences.Input : arr[]={1, 1, 1, 2, 2, 2, 3, 3, 4, 5, 6, 7, 7} Output : 7 occurs: 2    6 occurs: 1    5 occurs: 1    4 occurs: 1    3 occurs: 2    2 occurs: 3    1 occurs: 3AlgorithmSTART Step 1 -> input array with elements in sorting order Step 2 -> calculate size of an array by sizeof(a)/sizeof(a[0] Step 3 -> store size in a variable say en Step 4 -> Loop For i=siz-1 ...

Read More

Print matrix in antispiral form

Sunidhi Bansal
Sunidhi Bansal
Updated on 30-Jul-2019 486 Views

Given a 2d array of n*n and the task is to find the antispiral arrangement of the given matrixInput : arr[4][4]={1,2,3,4,    5,6,7,8,    9,10,11,12    13,14,15,16} Output: 10 11 7 6 5 9 13 14 15 16 12 8 4 3 2 1For this, stack can be used where the transpose of a matrix can be pushed inside stack and poped reverselyAlgorithmSTART STEP 1 -> declare stack vector element as stk and variables as int r=4, c=4, i, j, rs=0 and cs=0 Step 2 -> store matrix elements in 2-3 array Step 3 -> Loop For i=0 and o

Read More

Print an array with numbers having 1, 2 and 3 as a digit in ascending order

Sunidhi Bansal
Sunidhi Bansal
Updated on 30-Jul-2019 778 Views

Here, the task is to print those number in an array having 1, 2 and 3 as digits in their numbers and if their is no such number than the output must be -1Input : arr[] = {320, 123, 124, 125, 14532, 126, 340, 123400, 100032, 13, 32, 3123, 1100} Output : 123 3123 14532 100032 123400 Since the array have values with digits 1, 2 and 3 it wouldn’t return -1 and print 5 values that Contain 1, 2 and 3 in their respective numbers.AlgorithmSTART Step 1 -> Declare array with elements of int type as arr Step ...

Read More

Print prime numbers with prime sum of digits in an array

Sunidhi Bansal
Sunidhi Bansal
Updated on 30-Jul-2019 681 Views

Given with an array of elements and the task is to print those numbers whose digit sum is also prime and return -1 is not such digit exists in an arrayInput: arr[]={2, 4, 3, 19, 25, 6, 11, 12, 18, 7} Output : 2, 3, 25, 11, 12, 7Here, the given output is generated as it contains those additive numbers whose sum is also prime like − 2, 3, 7 are prime but 25(2+5=7), 11(1+1=2), 12(1+2=3) are also prime whereas numbers like 19(1+9=10) are not prime.AlgorithmSTART Step 1 -> Take array of int with values Step 2 -> declare start ...

Read More

Print numbers having first and last bits as the only set bits

Sunidhi Bansal
Sunidhi Bansal
Updated on 30-Jul-2019 273 Views

The task is to print the given n number which have exactly two set bits that neither less than 2 nor more than 2.Set bits in computer language are the one that have value 1 and unset bits have value as 0Input: value of num=5 Output: 1 3 5    As 1 is equivalent to 1 in binary       3 is equivalent to 11 in binary       5 is equivalent to 101 in binaryAlgorithmSTART Step 1 -> declare variable as unsigned int num=5 and int i=1 Step 2 -> print i Step 3 -> Loop For i=3 and i

Read More
Showing 791–800 of 809 articles
Advertisements