Reverse a string in C using pointers with code example and explanation. Input: I am coding string reverse! Output: !esrever gnirts gnidoc ma I Logic to Reverse a string in C: Store the string into a buffer. Take two pointers e.g. start pointer and end pointer. Set the start pointer to the first location of […]
C program to print vowels in a string
C program to print vowels in a string and their location. We need to find all vowels (lower case and upper case) in a given string and its location. For example, Input: Hello world Output: Vowel: e at location: 1Vowel: o at location: 4Vowel: o at location: 7 Solution to find vowels in String Solution […]
Sum of Digits in C Programming
Program to calculate sum of digits in C of a number using loop, explained logic and test cases. Example, Input number: 123 Output = 1+2+3 =6 Logic to find sum of digits: Have two variables” sum” and “remainder” with initial value 0. loop through the number Get remainder of the number with modulus 10. e.g. […]
C program for leap year
C program for leap year – Example with logic, description and C syntax expression to find a leap year. Simple logic to find Leap year? Find if the year is perfectly divisible by 4. If not divisible, then not a leap year. If divisible by 4 then, it can be a leap year. So, now, […]
Factorial program in C
Factorial program in C with logic and examples using loops ( for, while and do while), functions and Recursion techniques. For example, factorial of a number 5 is 120 using below factorial formula. Factorial Formula: n! = n × (n − 1) × (n − 2) . . . × 2 × 1 for a […]
C Program To Find Largest Number In An Array Easy Way
C program to find largest number in an array with simple logic and example and test cases. Example: Input Array: 2 6 4 8 9 Output: 9 LOGIC: Create an integer variable and store first element of the array into it, assuming this is largest value. Traverse the array using for a loop from location […]
C Program To Find Smallest Number In An Array So Easy
C program to find smallest number in an array with easy logic and simple example and test case. Example: Input Array: 2 6 4 8 9 Output: 2 LOGIC: Create an integer variable and store first element of the array into it, assuming this is smallest value. Traverse the array using for a loop from […]
Print an integer in C – from user input
Example to print an integer in C programming from user input. User will be prompted to enter an integer number on console screen. The program will read the integer number entered by user and display on screen. Steps: Create an integer variable Prompt user to enter an integer number using printf function Read the entered […]
String length in C without using strlen
Program example to find string length in C programming without using strlen function. Two program examples are shown one using for loop and another using while loop. String length in C without using strlen but for loop This c program example demonstrates how to calculate length of string without using strlen library function. It will […]
Length of string in C
Program to find length of string in C language using the library function strlen() . Also, includes example of length of string in C programming with user input string. It should be noted that the length of an string can also be calculated without using strlen function. C program to find length of string using […]