S

@Shobh89

Write a C Program to sort arrays using Bubble, Selection, and Insertion Sort.

C
1 year ago
//C Program to implement //sorting algorithms #include <stdio.h> //A Function to implement bubble sort void bubble_sort(int* arr,int n) { for(int j=0;j<n-1;j++){ //Last j elements are already in place

Write a C Program to search elements in an array using Binary Search.

C
1 year ago
//C program to Search element //in Array using Binary Search #include <stdio.h> int binarySearch(int arr[],int l,int r,int x) { if(r>=1){ int mid=l+(r-l)/2; //If the element is present at the middle

Write a C Program to search elements in an array.

C
1 year ago
//C code to search elements in an array #include <stdio.h> int search(int arr[],int N,int x) { int i; //iterate through all the element of array for(i=0;i<N;i++) if(arr[i] == x)

Write a program to print all permutations of a given string in lexicographically sorted order in C.

C
1 year ago
// C program to print all permutations in sorted // Order #include <stdio.h> #include<stdlib.h> #include<string.h> //function to compare two characters a and b int compare(const void* a,const void* b) { return(*(char*)a-*(char*)b);

Write a Program in C to reverse a string using recursion.

C
1 year ago
//C program to reverse a string //using recursion #include <stdio.h> //Function to print reverse of // passed string void reverse(char*str) { if(*str) {

Write a Program to find the HCF of two Numbers using Recursion

C
1 year ago
//C Program to find //GCd of two numbers #include <stdio.h> //Recursion function to //Calculate and return gcd of a and b int gcd(int a,int b) { //Everything divides 0 if(a==0)

Write a Code to print the Fibonacci series using recursion.

C
1 year ago
//C Program to illustrate //Fibonacci Series using Recursion #include <stdio.h> int fibonacci(int n) { if(n<=1) return n; return fibonacci(n-1)+fibonacci(n-2); }

Write a program to check string is a palindrome.

C
1 year ago
#include <stdio.h> #include<string.h> int isPalindrome(char str[]){ int low=0; int high=strlen(str)-1; //keep comparing characters while they are same while(low<high){ if(str[low] !=str[high]){

Program to calculate the length of the string.

C
1 year ago
#include <stdio.h> int main() { char s[] = "Programming is fun"; int i; for (i = 0; s[i] != '\0'; ++i); printf("Length of the string: %d", i); return 0; }

Write a program to calculate the Power of a Number using Recursion in C.

C
1 year ago
//C Program to calculate the power of a Number using //Recursion #include <stdio.h> int power(int a,int b) { if(b==0) return 1; return power(a,b-1) * a;

Write a program to count the sum of numbers in a string.

C
1 year ago
#include <stdio.h> int main() { char s[]="124259"; int ans=0; //iterate through all the number for(int i=0; s[i] != '\0';i++){

Write a Program to find the Spiral Traversal of a Matrix in C.

C
1 year ago
// C Program to find Spiral Traversal // Of a matrix #include <stdio.h> int main() { int arr[4][4] = { { 1, 5, 9, 13 }, { 2, 6, 10, 14 }, { 3, 7, 11, 15 }, { 4, 8, 12, 16 } };

Write a Program to Rotate a matrix by 90 degrees in the clockwise direction in C.

C
1 year ago
// C Program to rotate the array // By 90 degree in clockwise direction #include <stdio.h> void swap(int* a, int* b){ int temp = *a; *a = *b; *b = temp; }

Write a Program to find the transpose of a matrix.

C
1 year ago
#include <stdio.h> // This function stores transpose of A[][] in B[][] void transpose(int N, int M, int A[M][N], int B[N][M]) { int i, j; for (i = 0; i < N; i++) for (j = 0; j < M; j++) B[i][j] = A[j][i]; }

Write a C program to Implement Kadane’s Algorithm

C
1 year ago
//C program to implement kadane's Algorithm #include<limits.h> #include <stdio.h> int main() { int a[]={-2,-3,4,-1,-2,1,5,-3}; int n=sizeof(a)/sizeof(a[0]); int max_so_far=INT_MIN,max_ending_here=0,

Write a Program to Find if there is any subarray with a sum equal to 0.

C
1 year ago
//C program to check 0 sum //subarray possible #include <stdio.h> int main() { //arrray int arr[]={-2,2,1,1,8}; int n=sizeof(arr)/sizeof(arr[0]);

Write a Program to print sums of all subsets in an array.

C
1 year ago
//C program to print sum of //all subsets #include <stdio.h> //Function to print sum of subset //Using Recursion void subset_sum(int arr[],int i,int j,int sum) { if(i>j){ printf("%d",sum);

Write a Program to sort First half in Ascending order and the Second in Descending order.

C
1 year ago
//C program for Sorting //First half in Ascending Order //and Second Descending Order #include <stdio.h> void Sort_asc_desc(int arr[],int n) { int temp; for (int i=0;i<n-1;i++){ for(int j=i+1;j<n;j++){

Write a Program for the cyclic rotation of an array to k positions.

C
1 year ago
// C program to rotate //Array by k elements #include <stdio.h> //Print Array void printArray(int arr[],int n) { int i; for(i=0;i<n;i++) printf("%d",arr[i]);

Write a Program to print the Maximum and Minimum elements in an array.

C
1 year ago
//C program for calculating //maximum and minimum element #include <stdio.h> void find_small_large(int arr[],int n) { int min,max; //assign first element as minimum and maximum min=arr[0];