Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Articles by Sunidhi Bansal
Page 6 of 81
C Program to check if a number belongs to a particular base or not
Given a number as a string and a base, the task is to check whether the given number belongs to that given base or not. We have to check the number and the base according to the number system in which there are bases like 2 for a binary number, 8 for an octal number, 10 for decimal number and 16 for a Hexadecimal number. According to this we have to find whether the given number in a string belongs to a particular base or not. If it belongs to a particular base then we have to print "Yes" ...
Read MoreC Program for N-th term of Arithmetic Progression series
Given 'a' the first term, 'd' the common difference and 'n' for the number of terms in a series. The task is to find the nth term of the Arithmetic Progression series. Arithmetic Progression (AP) is a sequence of numbers where the difference between any two consecutive terms is constant. This constant difference is called the common difference. For example, if we have first term a = 5, common difference d = 2, and we want to find the 4th term, the series would be: 5, 7, 9, 11. So the 4th term is 11. Syntax ...
Read MoreC Program to calculate the Round Trip Time (RTT)
Round Trip Time (RTT) is the time required to send a network request to a server and receive a response back. In C programming, we can calculate RTT by measuring the time before and after making a network request or system call. Syntax #include clock_t start_time = clock(); // Network operation or system call clock_t end_time = clock(); double rtt = ((double)(end_time - start_time)) / CLOCKS_PER_SEC; What is Round Trip Time? Round Trip Time (RTT) consists of − Transmission time − Time to send the request Propagation delay − Time for ...
Read MoreC Program to Change RGB color model to HSV color model
Given RGB color range in form of integers; the task is to find its appropriate HSV color by converting the RGB color range. This conversion helps translate between the hardware-oriented RGB model and the more intuitive HSV model used in graphics and design applications. What is RGB Color Model RGB color model comprised of three colors Red, Green and Blue. RGB model is a color model which is widely used in the display technologies; it is an additive model in which we add these three colors with different intensities to produce millions of different colors on a display ...
Read MoreC Program to convert a given number to words
In C programming, converting numbers to words is a common problem that involves breaking down a number into its place values and mapping each digit to its corresponding word representation. This program converts numbers from 0 to 9999 into their English word equivalents. Syntax void convert(char *num); Algorithm Overview The conversion process involves these key steps − Parse the input string to determine its length Use arrays to store word representations for different place values Process digits from left to right based on their position Handle special cases for numbers 10-19 and ...
Read MorePrinting all subsets of {1,2,3,...n} without using array or loop in C program
Given a positive integer n, we have to print all the subsets of the set {1, 2, 3, 4, … n} without using any array or loops. For example, if n = 3, we need to print all subsets of {1, 2, 3} which are {1 2 3}, {1 2}, {2 3}, {1 3}, {1}, {2}, {3}, and { }. Since we cannot use loops or arrays, recursion is the only way to solve this problem. We use binary representation to generate subsets efficiently. Syntax void generateSubsets(int n, int currentNum); void printSubset(int bitPosition, int num, int ...
Read MoreC Program to check if a number is divisible by any of its digits
Given a number n, the task is to find if any digit in the number divides the number completely. For example, the number 128625 is divisible by 5, which is also present in the number. Syntax int isDivisibleByDigit(long long int n); Algorithm The approach used is as follows − Extract each digit from the number using modulo operation Check if the original number is divisible by that digit If divisible, return true; otherwise continue with the next digit Remove the last digit by dividing the number by 10 Repeat until all digits ...
Read MoreC Program for product of array
Given an array arr[n] of n number of elements, the task is to find the product of all the elements of that array. Like we have an array arr[7] of 7 elements so its product will be like − a[0] a[1] a[2] ... a[n-1] × × × × Product = a[0] × a[1] × a[2] × ... × a[n-1] ...
Read MoreC Program for Arrow Star Pattern
In C programming, an arrow star pattern is a visual pattern that resembles an arrow shape using asterisk (*) characters. The pattern consists of two parts: an upper section that decreases in width and a lower section that increases in width, creating an arrow-like appearance. Syntax void printArrowPattern(int n); Algorithm The arrow pattern generation follows these steps − Upper Part: Print decreasing number of stars with increasing leading spaces Lower Part: Print increasing number of stars with decreasing leading spaces Use nested loops to control spaces and stars for each row ...
Read MoreC Program to check if a number is divisible by sum of its digits
Given a number n we have to check whether the sum of its digits divide the number n or not. To find out we have to sum all the numbers starting from the unit place and then divide the number with the final sum. Like we have a number "521" so we have to find the sum of its digit that will be "5 + 2 + 1 = 8" but 521 is not divisible by 8 without leaving any remainder. Let's take another example "60" where "6+0 = 6" which can divide 60 and will not leave ...
Read More