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 15 of 81
Print matrix in antispiral form
In C programming, printing a matrix in antispiral form means traversing the matrix in a spiral order (clockwise from outside to inside) and then displaying the elements in reverse order. This creates an "antispiral" pattern where we start from the center and work outward. Syntax // Using array to store spiral elements int spiral[n*n]; // Traverse in spiral order: right → down → left → up // Print in reverse order Algorithm The approach involves two main steps − Spiral Traversal: Traverse the matrix in spiral order (right → down → left ...
Read MorePrint numbers in descending order along with their frequencies
Given an array of integer elements, the task is to arrange the elements in descending order and find their frequencies. This approach works when the input array is already sorted in ascending order. 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 ...
Read MorePrint prime numbers from 1 to N in reverse order
In this article, we will learn how to print prime numbers from 1 to N in reverse order. A prime number is a number greater than 1 that has no positive divisors other than 1 and itself. Our goal is to find all prime numbers in the given range from 1 to N and then print them in reverse order. For example, given N = 20, the prime numbers between 1 and 20 are: 2, 3, 5, 7, 11, 13, 17, 19. The output should be the prime numbers printed in reverse order: 19, 17, 13, 11, 7, 5, ...
Read MorePrint first N terms of series (0.25, 0.5, 0.75, ...) in fraction representation
In C programming, printing a series like (0.25, 0.5, 0.75, ...) in fraction representation involves converting decimal values to their equivalent fractions. This series represents multiples of 0.25, which can be expressed as fractions with denominator 4. Syntax for (i = 0; i < n; i++) { // Calculate numerator and denominator // Print in fraction form: numerator/denominator } Algorithm START Step 1 → Declare variables: int num, den, i, n Step 2 → Input number in n Step 3 → Loop from i = ...
Read MorePrint uncommon elements from two sorted arrays
Given two sorted arrays, we need to find and print all uncommon elements (elements that appear in one array but not in both). This problem uses a two-pointer technique to efficiently traverse both arrays simultaneously. Given : array1[] = {1, 4, 6, 9, 12} array2[] = {2, 4, 7, 8, 9, 10} Output : 1 2 6 7 8 10 12 Syntax void printUncommonElements(int arr1[], int n1, int arr2[], int n2); Algorithm Initialize two pointers i and j to traverse both arrays ...
Read MorePrint missing elements that lie in range 0 – 99
In C programming, finding missing elements within a specific range is a common problem. Given an array of integers, we need to identify which numbers from 0 to 99 are missing and display them either as individual numbers or as ranges. Syntax bool flag[MAX] = { false }; for (i = 0; i < n; i++) { if (array[i] >= 0 && array[i] < 100) { flag[array[i]] = true; } } Algorithm Create a boolean array flag[100] ...
Read MorePrint the given 3 string after modifying and concatenating
This program demonstrates how to modify multiple strings by replacing all characters with user−specified replacement characters, then concatenate the modified strings together. Syntax strlen(string) // Get string length strcat(dest, source) // Concatenate strings scanf("%s", string) // Read string input Algorithm START Step 1 → Declare three character arrays str1, str2, str3 and replacement characters ch1, ch2, ch3 Step 2 → Input the three strings and three replacement characters Step 3 → Replace all characters in str1 with ...
Read MorePrint number of words, vowels and frequency of each character
In C programming, string analysis is a common task where we need to count words, vowels, and find the frequency of specific characters. This program demonstrates how to analyze a string by counting these different elements in a single pass. Syntax // String traversal for character analysis for(i = 0; str[i] != '\0'; i++) { // Character comparison and counting logic } Algorithm START Step 1: Declare string array, character variable, and counters (freq=0, vowels=0, words=0) Step 2: Input string and target character Step 3: Loop through each character ...
Read MorePrint n numbers such that their sum is a perfect square
Given n numbers, we need to find n numbers whose sum is a perfect square. The solution uses the first n odd numbers, as the sum of first n odd numbers is always n². Input : 5 Output : 1 3 5 7 9 1+3+5+7+9=25 i.e (5)² Syntax for(i = 1; i
Read MoreCount odd and even digits in a number in PL/SQL
We are given a positive integer of digits and the task is to calculate the count of odd and even digits in a number using PL/SQL. PL/SQL is a combination of SQL along with the procedural features of programming languages. It was developed by Oracle Corporation in the early 90's to enhance the capabilities of SQL. PL/SQL is one of three key programming languages embedded in the Oracle Database, along with SQL itself and Java. Input int number = 23146579 Output count of odd digits in a number are : 5 count of even digits in a number are : ...
Read More