Palindrome number reads the same from both directions, forward and backward. For example, “156434651” reads the same from both directions. If we reverse a palindrome number, the reversed number would be the same as the original one. Here we’ll see how to write a C program to check whether a number is a palindrome. Method … Continue reading “C Program to Check Whether a Number is Palindrome”
Category: Programming
C Program to Check Whether a String is Palindrome
Palindrome string is a string that reads the same from both forward and backward directions. For example, “madam” reads the same from both directions. If you reverse a palindrome string, the reversed string would be the same as the original one. Here we’ll see how to write C program to check whether a string is … Continue reading “C Program to Check Whether a String is Palindrome”
C Program to Reverse a String
Here we’ll see how to write a C program to reverse a string. Solution 1 The reverse_string() function takes the input string as input parameter and reverses that into the output string. The last character of the input string is set as the first character of the output string, second last character of the input … Continue reading “C Program to Reverse a String”
C Program to Reverse an Integer
Here we’ll see how to write C program to reverse an integer. The reverse_integer() function takes an integer like 5234569 and returns 9654325. Output: Logic: The reverse_integer() function takes the last digit of “in” by doing modulo operation by 10. For example, if in is 5234569, 5234569 % 10 would be the last digit 9. … Continue reading “C Program to Reverse an Integer”
C Program to Sleep in Milliseconds
We don’t have millisecond level control in the sleep() function. But in Linux we can implement our own function that will take duration in milliseconds as input and sleep for that duration. Using usleep() The usleep() function takes the duration in micro seconds as input. We can have a wrapper around this usleep() function that … Continue reading “C Program to Sleep in Milliseconds”