Skip to main content

Featured

C Program to display spellings of number 1-10 on entry

C Program to display spellings of number 1-10 on entry.   #include<stdio.h>   void main() { int num; printf("Enter a number between 1-10:"); scanf("%d",&num); printf("\n"); switch (num) { case 1: printf("ONE"); break; case 2: printf("TWO"); break; case 3: printf("THREE"); break; case 4: printf("FOUR"); break; case 5: printf("FIVE"); break; case 6: printf("SIX"); break; case 7: printf("SEVEN"); break; case 8: printf("EIGHT"); break; case 9: printf("NINE"); break; case 10: printf("TEN"); break; default:         printf("THE ENTERED NUMBER IS NOT BETWEEN 1-10"); } } OUTPUTS

C program to calculate addition and subtraction of 2 dimensional matrix

C program to calculate addition and subtraction of 2 dimensional matrix 


#include<stdio.h>
void main()
{
int mat1[2][2],mat2[2][2],i,j;
printf("Enter the elements of first matrix(2X2):\n");
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
scanf("%d",&mat1[i][j]);
}
printf("\n");
}
printf("Enter the elements of second matrix(2X2):\n");
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
scanf("%d",&mat2[i][j]);
}
printf("\n");
}
printf("The addition of two matrices:\n");        //ADDITION
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
printf("\t%d",mat1[i][j]+mat2[i][j]);
}
printf("\n");
}
printf("The subtraction of two matrices:\n");     //SUBTRACTION
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
printf("\t%d",mat1[i][j]-mat2[i][j]);
}
printf("\n");
}
}


OUTPUTS



Comments