Skip to main content

Posts

Showing posts from April, 2015

C Program To Implement String Operations.

The C language provides no explicit support for strings in the language itself. The string-handling functions are implemented in libraries. The string library (string.h or strings.h) has some useful functions for working with strings, like strcpy, strcat, strcmp, strlen, strcoll, etc. We will take a look at some of these string operations.  #include <stdio.h> #include<string.h> #include<ctype.h> #include<stdlib.h> int length(char str[]); void reverse(char str[]); int palindrome(char str[]); void copy(char str1[], char str2[]); int compare(char str1[], char str2[]); void concat(char str1[], char str2[]); void search(char str1[], char str2[]); void count(char str1[]); int main() { char a[100], b[100]; int result, option;

C Program To Multiply Two Matrices Using Multi-dimensional Arrays.

#include <stdio.h> int main()  { int a[10][10], b[10][10], mult[10][10], r1, c1, r2, c2, i, j, k; printf("Enter Rows and Columns for First Matrix:\n"); scanf("%d%d", &r1, &c1); printf("\nEnter Rows and Columns for Second Matrix:\n"); scanf("%d%d",&r2, &c2); while (c1!=r2)  { printf("\nWrong Input: Column of First Matrix is Not Equal to Row of Second Matrix.\n\n"); printf("\nEnter Rows and Columns for First Matrix:\n"); scanf("%d%d", &r1, &c1); printf("\nEnter Rows and Columns for Second Matrix:\n"); scanf("%d%d",&r2, &c2); }