Posts

Matrix Multiplication Using Pointer

Program   for   Product  of  Two   Matrices   #include<stdio.h>   int main(){          int matrix1[20][20],matrix2[20][20],product[20][20];          int *p1,*p2,*prod,m,n,p,q,d,e,f;          p1=matrix1;          p2=matrix2;          prod=product;          clrscr();          printf("\nEnter the size (no of rows and columns) for 1st matrix :\n");          scanf("%d%d",&m,&n);          printf("\nEnter the size (no of rows and columns) for 2nd matrix :\n");          scanf("%d%d",&p,&q);          if(n==p)         {          printf("\n Enter the 1st matrix elements : \n");          for(d=1;d...

Checking the number of letters repeated in a word.

#include <stdio.h> #include <string.h> void main () { int i , count = 0 ; char c , str [ 100 ]; printf ( "Enter a sentence\n" ); scanf("%c",&str) ; printf ( "Enter a character to know it's repetance in sentence\n" ); scanf ( "%c" ,& c ); for ( i = 0 ; i < strlen ( str ); i ++) { if ( str [ i ]== c ) { count ++; } } printf ( "Letter %c repeated %d times\n" , c , count ); getch(); } Explanation: This program starts with initializing : str[100]  → To store  string with length of 100  which means it can store  100 letters i  →Used as  helping variable count → To store  number of  times a letter is repeated in a given string  and is initilized to  0. c  →Used  to store required letter printf("Enter a sentence\n"); scanf("%c",&str); Takes string from user. printf("Enter a character to know it's repetance in sentence\n"); sc...