Important Programming
Important Programming
4) C Program to Sort an Array using Pointers. 9) Wap in C to Compare Two Strings 10) Reverse a String Using Pointers
#include <stdio.h>
#include <stdio.h>
3) C Program to Find G.C.D Using Recursion: void swap(int *a, int *b) {
#include <stdio.h> #include <string.h>
int temp = *a; #include <string.h> void reverseString(char *str) {
*a = *b; int main() {
#include <stdio.h> char *start = str;
*b = temp;
char str1[100], str2[100]; char *end = str + strlen(str) - 1;
}
int gcd(int a, int b) { printf("Enter first string: "); char temp;
void sortArray(int *arr, int size) {
if (b == 0) return a; for (int i = 0; i < size - 1; i++) { fgets(str1, sizeof(str1), stdin); while (start < end) {
return gcd(b, a % b); for (int j = i + 1; j < size; j++) { str1[strcspn(str1, "\n")] = '\0'; temp = *start;
if (*(arr + i) > *(arr + j)) { printf("Enter second string: ");
} *start = *end;
swap(arr + i, arr + j);
int main() { fgets(str2, sizeof(str2), stdin); *end = temp;
}
int num1, num2; str2[strcspn(str2, "\n")] = '\0'; start++;
}
printf("Enter two numbers: "); } int cmp = strcmp(str1, str2); end--;
5) C Program to Find the Largest Element in an Array Using Pointers: 6) Wap in C to Check if a String is a Palindrome Using Pointers 11) Wap in C to Program to Sort a String. 12) C Program to Insert a String into Another String.
#include <stdio.h>
return 0; } return 0; }
}
15) C Program to Find the Maximum and Minimum in an Array. (Important) 16) C Program to Remove Duplicate Elements From a Sorted Array. 20) Write a program in C to check whether a number is Armstrong or not.
for (int i = 1; i < n; i++) { int newSize = 1; // Calculate the sum of digits raised to the power of digitCount
return 0;
printf("\n");
}
return 0;
}
17) C Program to Print Pascal's Pattern Triangle Pyramid. (Important) 18) Write a C program to find the second maximum and second minimum
element from an array along with their positions.
#include <stdio.h>
#include <stdio.h>
#define MAX 100
int main() { int main() {
int n; int arr[MAX];
} secondMax = max;
max = arr[i];
secondMaxPos = maxPos;
maxPos = i;
} else if (arr[i] > secondMax && arr[i] < max) {
secondMax = arr[i];