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
Server Side Programming Articles
Page 925 of 2109
C program to display the prime numbers in between two intervals
In C programming, finding prime numbers between two intervals is a common problem that involves checking each number in the range for primality. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. Syntax for(i = start + 1; i < end; i++) { flag = 0; for(j = 2; j
Read MoreFind the sum of first and last digit for a number using C language
In C programming, finding the sum of the first and last digit of a number involves extracting these digits using modulus and division operations. The last digit is obtained using modulus 10, while the first digit is found by repeatedly dividing the number by 10. Syntax int lastDigit = number % 10; while(number > 9) { number = number / 10; } int firstDigit = number; int sum = firstDigit + lastDigit; Algorithm The algorithm to find the sum of first and last digit is as follows − ...
Read MoreExplain the different sections in C language
A C program follows a structured format with different sections that serve specific purposes. Understanding these sections helps in writing well-organized and maintainable code. Structure of a C Program The complete C program is divided into different sections, which are as follows − Documentation Section − Contains comments about the program like author name, creation or modification date. Information written between /* */ or after // is called a comment line. These lines are ignored by the compiler during compilation. Preprocessor Directives Section − In this section, header files required to execute the program are ...
Read MoreC program to display only the lower triangle elements in a 3x3 2D array
In a 3x3 matrix, the lower triangle consists of elements where the row index is greater than or equal to the column index (i >= j). This includes the main diagonal and all elements below it. Syntax for(i = 0; i < n; i++) { for(j = 0; j < n; j++) { if(i >= j) // Print element at array[i][j] else ...
Read MoreC program to sort an array of ten elements in an ascending order
An array is a group of related data items that are stored with a single name. In this article, we'll learn how to sort an array of ten elements in ascending order using the bubble sort technique. For example, int student[30]; Here, student is an array name which holds 30 collection of data items with a single variable name. Syntax for(i = 0; i < n-1; i++) { for(j = i+1; j < n; j++) { if(arr[i] > arr[j]) { ...
Read MoreExplain monolithic and modular programming in C language
Monolithic and modular programming are two different approaches to writing C programs. The main difference lies in how the code is organized and structured. Monolithic Programming In monolithic programming, the entire program logic is written in a single function, typically the main() function. All the code is placed in one location without breaking it into smaller, manageable parts. Example: Monolithic Approach Here's an example of a monolithic program that performs arithmetic operations − #include int main() { int a = 10, b = 5; ...
Read MoreHow to display the complete text one word per line in C language?
In C, displaying text one word per line involves reading words from a file and printing each word on a separate line. This can be accomplished by using file handling functions to read words and format the output appropriately. Syntax fscanf(file_pointer, "%s", word_buffer); printf("%s", word); Example: Reading Words from File The following program demonstrates how to display text one word per line by reading from a file − Note: This example uses file operations. Create a text file named "input.txt" with some text content before running the program. #include ...
Read MoreC program to convert upper case to lower and vice versa by using string concepts
Converting uppercase letters to lowercase and lowercase letters to uppercase is commonly known as case toggling. In C programming, we can achieve this using ASCII values or built-in character functions. Syntax // Manual approach using ASCII values if (ch >= 'a' && ch = 'A' && ch = 'a' && string[i] = 'A' && string[i]
Read MoreC program to verify if the numbers are abundant(friendly) or not?
In C programming, abundant numbers (also called friendly numbers) are special numbers where the sum of their proper divisors equals the number itself. Two numbers form an abundant pair if both numbers are abundant individually. Syntax // Find sum of proper divisors for(i = 1; i < number; i++) { if(number % i == 0) { sum = sum + i; } } // Check if abundant if(sum == number) { // Number is abundant } ...
Read MoreExplain Squeeze Function C language
The squeeze() function in C is a user-defined function that removes all characters from the first string that are present in the second string. This function is particularly useful for filtering characters based on a reference string. Syntax void squeeze(char string1[], char string2[]); Parameters string1[] − The source string from which characters will be removed string2[] − The reference string containing characters to be removed from string1 How It Works The squeeze function works by scanning each character in the first string and checking if it exists in the second ...
Read More