Found 38 Questions For C Programming

How to Remove Duplicates From a Given String

Updated on 01-Apr-2024 15:19:18
  Duplicate characters within a string can clutter data and complicate processing. Whether you're a programmer, a data analyst, or just someone trying to clean up their text, knowing how to remove duplicates from a string is a valuable skill. In this comprehensive guide, we'll explore various methods to achieve this task using different programming languages: PHP, C, C++, JavaScript, Python, and Java. Understanding the Problem: Before delving into solutions, it's essential to understand t... Read Mores

C Program to Sum the Digits of Any Given Number

Updated on 28-Mar-2024 12:27:12
In the realm of programming, efficiency and accuracy are paramount. One fundamental task often encountered is summing the digits of a given number. This seemingly simple task can be approached in various ways, but harnessing the power of the C programming language can provide a robust solution. In this article, we will delve into the intricacies of crafting a C program to sum the digits of any given number, exploring the algorithm, implementation, and test cases to ensure its reliability. Algor... Read Mores

How to Print List Items Containing All Characters of a Given Word

Updated on 01-Apr-2024 9:40:40
  In programming, there often arises the need to search through a list of items and find those that contain all the characters of a given word. This task can be efficiently accomplished using various programming languages such as C++, C, Java & Python. In this article, we will explore algorithms and provide code implementations in each of these languages, along with their respective outputs and complexities. Algorithm: The algorithm employed revolves around iterating through each item... Read Mores

Count Number of Homogenous Substrings

Updated on 09-Nov-2023 17:52:13
  Introduction: Given a string s, the goal is to determine the number of homogenous substrings it contains. A string is considered homogenous if all its characters are the same. Substrings, on the other hand, are contiguous sequences of characters within a string. To handle potentially large results, the answer is returned modulo 10^9 + 7. Problem Statement: We are given a string s, and we need to count the number of homogenous substrings in it. Example 1: Input: "abbcccaa" Output: 13 Exp... Read Mores

C Program To Print Your Own Name

Updated on 07-Apr-2023 15:15:28
In C programming language, we can use the scanf() and printf() functions to take input and output data respectively. In this article, we will write a C program to print your own name using these two functions in two way. Example 1: In this example, we print the user name using printf() function. // C program to demonstrate printing of // our own name using printf() #include <stdio.h> int main() { // print name printf("Name : Codegyan"); return 0; } Output :  Name :... Read Mores

Write C Program For Finding The Length Of Loop In Linked List

Updated on 02-Apr-2023 15:08:05
Introduction: Linked lists are data structures that store data elements in a linear manner. Each element of a linked list, known as a node, consists of two parts: data and a pointer that points to the next node in the list. A linked list can have one or more loops or cycles, where a node points to a previously visited node in the list. In this article, we will discuss how to find the length of a loop in a linked list using C programming language. Algorithm: To find the length of a loop in a link... Read Mores

Write C program to Check Whether a Number is Positive or Negative

Updated on 10-Feb-2023 13:46:26
In this tutorial we'll learn how to check whether a given integer is positive or negative. We have the the number that we need to check that integer is positive or negative number using c program. Problem Description The program takes the given integer and checks whether the integer is positive or negative. Problem Solution 1. Take the integer which you want to check as input. 2. Check if it is greater or lesser than zero and print the output accordingly. 3. Exit. Program/So... Read Mores

Find Second largest element in an array using C Programming

Updated on 12-Jan-2023 0:25:36
Given an array of integers, our task is to write a program that efficiently finds the second largest element present in the array. Example: Input: arr[] = {12, 35, 1, 10, 34, 1} Output: The second largest element is 34. Explanation: The largest element of the array is 35 and the second largest element is 34 Input: arr[] = {10, 5, 10} Output: The second largest element is 5. Explanation: The largest element of the array is 10 and the second largest element is 5 Input: arr[] =... Read Mores

Recursive program to linearly search an element in a given array using C

Updated on 15-Feb-2022 16:04:30
Given an unsorted array and an element x, search x in given array. Write recursive C code for this. If element is not present, return -1. Approach : The idea is to compare x with the last element in arr[]. If an element is found at the last position, return it. Else recur elmntSrch() for remaining array and element x. Program : /* * Approach : The idea is to compare x with the last element in arr[]. * If an element is found at the last position, return it. * Else recur el... Read Mores

Write C Program to Merge Two arrays in C Programming

Updated on 17-Jan-2022 9:28:10
Program : C Program to Merge Two arrays in C Programming #include<stdio.h> int main() { int arr1[30], arr2[30], res[60]; int i, j, k, n1, n2; printf("\nEnter no of elements in 1st array :"); scanf("%d", &n1); for (i = 0; i < n1; i++) { scanf("%d", &arr1[i]); } printf("\nEnter no of elements in 2nd array :"); scanf("%d", &n2); for (i = 0; i < n2; i++) { scanf("%d", &arr2[i]); } i = 0; j = 0; k = 0; // Merging starts while (i < n1 &... Read Mores
1 2 3 4 Next



Advertisements

ads