C programs

How to write a Program to Reverse a String in C Programming Tutorial?

Following is the program to Reverse a String using for loop. #include<stdio.h> #include<conio.h> void main() { int i, j, k; char str[100]; char rev[100]; printf(“Enter a string\t”); scanf(“%s”, str); printf(“The original string is %s”, str); for(i = 0; str[i] != ‘\0’; i++); { k = i-1; } for(j = 0; j <= i-1; j++) { …

How to write a Program to Reverse a String in C Programming Tutorial? Read More »

Program to Find the Largest Element of an Array using Recursion

You can do this in many ways, Let’s learn how to do this using recursion. #include<stdio.h> #include<conio.h> int findLargest(int arr[],int size); void main() { int arr[5]; int i, max=0; clrscr(); printf(“Enter 5 numbers\t”); for(i=0; i<5; i++) { scanf(“%d”, &arr[i]); } max = findLargest(arr, 5); printf(“The largest element is %d”, max); getch(); } int findLargest(int *arr,int …

Program to Find the Largest Element of an Array using Recursion Read More »

Program to Check whether a Number is Palindrome or Not in C Programming Language

#include<stdio.h> #include<conio.h> void main() { int a, b, c, s=0; clrscr(); printf(“Enter a number:\t”); scanf(“%d”, &a); c = a; //the number is reversed inside the while loop. while(a > 0) { b = a%10; s = (s*10)+b; a = a/10; } //Here the reversed number is compared with the given number if(s == c) { …

Program to Check whether a Number is Palindrome or Not in C Programming Language Read More »