Posts

Showing posts from September, 2022

‘C’ program to add two matrices of order m X n.

C File => /* Write a ‘C’ program to add two matrices of order mXn */ #include<stdio.h> int main()  {      int m,n,i,j,mat1[20][20];      int mat2[20][20],add[20][20];        printf("\n Enter no. of rows : ");      scanf("%d",&m);      printf("\n Enter no. of cols : ");      scanf("%d",&n);        printf("\n Input Matrix1 : \n");      for(i=0;i<m;i++)     {        for(j=0;j<n;j++)       {            printf("\n Enter element %d%d : ", i+1,j+1);            scanf("%d",&mat1[i][j]);       }    }        printf("\n Input Matrix2 : \n");      for(i=0;i<m;i++)     {         for(j=0;j<n;j++)        {           printf("\n Enter element %d%d : ", i+1,j+1);           scanf("%d",&mat2[i][j]);         }      }         printf("\n\n Addition Matrix is :\n");       for(i=0;i<m;i++)      {         for(j=0;j<n;j++)        {              add[i][j]=mat1[i][

Preprocessor in 'C'

Image
Preprocessor  : As the name suggests a processor which performs pre-processing or some processing on a program before submitting it for actual compilation is called preprocessor.  For example inclusion of header files in a program. Role of Pre-processor : Program written in C language is given to preprocessor.  Preprocessor checks of preprocessor directives if any present in given program. It performs specific actions according to directive instructions and submit modified code to the compiler.  Compiler then compiles it and produces object code which is then executed with the help of linker. Format of preprocessor directive : Preprocessor directive is an instruction given to preprocessor to perform certain task. All preprocessor directives begins with # followed by identifier and directive name respectively.  For example #include ,#define ,#undef etc. In C preprocessor allows us to do inclusion of header files, expansion of macros, c