File program to read and encrypts character
program to read a character file and encrypts it by replacing each alphabet by its next alphabet cyclically i.e., z
program for one member used at a time in union
#include <stdio.h> #include <string.h> union Data { int i; float f; char str[20]; }; int main( ) { union Data data; data.i = 10; printf( "data.i : %d\n", data.i);data.f =
C program to sort given strings in ascending order
#include<stdio.h> #include<string.h> main() { char a[5][10],t[10]; int i,n,j; printf("enter no of strings:\n"); scanf("%d",&n); printf("enter strings:\n "); for(i=0;i<5;i++) scanf("%s",a[i]); for(i=0;i<n-1;i++) { for(j=i+1;j<n;j++) { if(strcmp(a[i],a[j])>0) { strcpy(t,a[i]); strcpy(a[i],a[j]); strcpy(a[j],t); } } } printf("\n After sorting\n"); for(i=0;i<n;i++) printf("%s\t",a[i]); } Output:
C program to perform string handling functions
#include<stdio.h> #include<string.h> main() { char a[10],b[10]; int ch,len; printf("enter str1 "); scanf("%s",a); printf("enter str2 "); scanf("%s",b); while(1) { printf("\n choose ur option"); printf("\n 1.length\n 2.compare\n 3.copy\n 4.concat\n"); printf("enter ur choice: "); scanf("%d",&ch); switch(ch) { case 1: len=strlen(a); printf("length is
C program to search given string from set of strings
#include<stdio.h> #include<string.h> main() { char a[5][10],b[10]; int i,n; printf("enter no of strings:"); scanf("%d",&n); printf("enter strings:\n"); for(i=0;i<5;i++) scanf("%s",a[i]); printf("enter a search string:"); scanf("%s",b); printf("given strings are: "); for(i=0;i<5;i++) printf("%s\t",a[i]); printf("\n"); for(i=0;i<n;i++) { if(strcmp(a[i],b)==0) { printf("string found at %d position\n",i); break; } } } Output:
C program to find the trace of a given square matrix
We know that the trace of a matrix is defined as the sum of the leading diagonal elements.Note : Trace
C program to find a product of two matrices
Consider two matrices A and B in the order of 2 x 2. Multiply them to get the resultant matrix
C program to find sum and difference of two matrices
#include <stdio.h> int main() { int i,j,r1,c1, a[10][10], b[10][10]; printf("Enter Order of Matrix A & B: "); scanf("%d %d", &r1, &c1); printf("Enter Elements of Matrix of
C program to merge two sorted arrays
#include <stdio.h> void main() { int array1[5], array2[5], array3[10], m, n, i, j, k = 0; printf("\n Enter sorted elements of array