Sunidhi Bansal

Sunidhi Bansal

809 Articles Published

Articles by Sunidhi Bansal

Page 53 of 81

C++ Program to check if tank will overflow, underflow or filled in given time

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 335 Views

Given with the rate of filling the tank, height of a tank and radius of a tank and the task is to check whether the tank is overflow, underflow and filled in given time.ExampleInput-: radius = 2, height = 5, rate = 10 Output-: tank overflow Input-: radius = 5, height = 10, rate = 10 Output-: tank undeflowApproach used below is as follows −Input the rate of filling time, height and radius of a tankCalculate the volume of a tank to find the original rate of flow of water.Check for the conditions to determine the resultIf expected < original ...

Read More

C++ Program for sum of arithmetic series

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 4K+ Views

Given with ‘a’(first term), ‘d’(common difference) and ‘n’ (number of values in a string) and the task is to generate the series and thereby calculating their sum.What is an Arithmetic seriesArithmetic series is the sequence of numbers with common difference where the first term of a series is fixed which is ‘a’ and the common difference between them is ‘d’.It is represented as −a, a + d, a + 2d, a + 3d, . . .ExampleInput-: a = 1.5, d = 0.5, n=10 Output-: sum of series A.P is : 37.5 Input : a = 2.5, d = 1.5, n ...

Read More

C Program for diamond pattern with different layers

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 350 Views

Given with the number and the task is to generate the diamond pattern with the given n different layers and display it.ExampleInput: n = 3Output:Approach used in the below program is as follows −Input the number of rowsAnd in this pattern there are ((2 * n) + 1) rowsNumber of spaces from 0 – n is (2 * (n – i))And the number of spaces from n+1 till end are ((i – n) * 2)AlgorithmStart Step 1-> declare a function to print a pattern    void print_pattern(int n)    declare variables as int i, j    Loop For i = 1 i

Read More

Products of ranges in an array in C

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 654 Views

Given with array, L, R, P as an input and the task is to find the ranges between L and R with the product under modulo as output and display itAs given in the figure we have array of elements and L which is a Left value as 2 and R which is the Right value as 2. Now the program must find the products of ranges between them.ExampleInput-:  A[] = { 1, 2, 3, 4, 5, 6 }    P = 29  L = 2 R = 6 Output-: 24 Input-: A[] = {1, 2, 3, 4, 5, 6},   ...

Read More

Program to compute Log n in C

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 594 Views

Given with the value of n as an input and the task is to compute the value of Log n through a function and display it.Logarithm or Log is the inverse function to exponentiation which means to calculate log the raised power must be calculated as a base.IF  $$\log_b x\;\:=\: y\:than\:b^{y}=x$$Like $$\log_2 64\;\:=\: 6\:than\:2^{6}=64$$ExampleInput-: Log 20 Output-: 4 Input-: Log 64 Output-: 6AlgorithmStart In function unsigned int log2n(unsigned int num)    Step 1-> Return (num > 1) ? 1 + log2n(num / 2) : 0 In function int main()    Step 1-> Declare and assign num = 20    Print log2n(num) ...

Read More

C Program to check if matrix is singular or not

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 1K+ Views

Given a matrix as mat[row][column], our task is to check whether the given matrix is singular or not through a function and display the result.Singular matrix is a matrix whose determinant is zero and if the determinant is not zero then the matrix is non-singular.So to find whether the matrix is singular or non-singular we need to calculate determinant first. Determinant of a matrix can be calculated as −$$M1[3][3]\:=\:\begin{bmatrix}a & b & c \d & e & f \g & h & i \end{bmatrix}$$|m1| = a(e*i - f*h) - b(d*i - f*g) + c(d*h - e*g)ExampleInput-: mat[3][3]= { 4, 10, ...

Read More

C Program to check Strong Number

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 7K+ Views

Given a number ‘n’ we have to check whether the number given is Strong Number or not.Strong number is a number whose sum of all digits’ factorial is equal to the number ‘n’. Factorial implies when we find the product of all the numbers below that number including that number and is denoted by ! (Exclamation sign), For example: 4! = 4x3x2x1 = 24.So, to find a number whether its strong number, we have to pick every digit of the number like the number is 145 then we have to pick 1, 4 and 5 now we will find factorial ...

Read More

C Program to check if a date is valid or not

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 4K+ Views

Given date in format date, month and year in integer. The task is to find whether the date is possible on not.Valid date should range from 1/1/1800 – 31/12/9999 the dates beyond these are invalid.These dates would not only contains range of year but also all the constraints related to a calendar date.Constraints are −Date can’t be less than 1 and more than 31Month can’t be less than 1 and more than 12Year can’t be less than 1800 and more than 9999When the months are April, June, September, November the date can’t be more than 30.When the month is February ...

Read More

C Program to convert first character uppercase in a sentence

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 4K+ Views

Given a string and with mixed case, i.e with both uppercase and lower case, the task is to covert the first character to uppercase rest in lowercase if it’s in upper case.Let’s understand it in depth with the help of a simple example.Like we are given a string “hElLo world”, we have to convert the first character ‘h’ which is in lowercase to uppercase ‘H’ and rest all letters before the space or end of the string to lowercase.Moreover when we encounter first character after a space we have to convert it to uppercase.ExampleInput: str[] = {“heLlO wORLD”} Output: Hello ...

Read More

C Program to check Plus Perfect Number

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 377 Views

Given a number x with n number of digits, our task is to check whether the given number’s Plus Perfect number or not. In order to check that the number is Plus Perfect Number we find the nth power of every digit d (d^n) and then sum all the digits, if the sum is equal to n then the number is Plus Perfect Number. Plus Perfect number is similar like finding an Armstrong of any number.Like In the given example below −ExampleInput: 163 Output: Number is not a perfect_number Explanation: 1^3 + 6^3 + 3^3 is not equal to 163 ...

Read More
Showing 521–530 of 809 articles
« Prev 1 51 52 53 54 55 81 Next »
Advertisements