Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Can someone help me with this C program?! Its an into class so please try to kee

ID: 3695131 • Letter: C

Question

Can someone help me with this C program?! Its an into class so please try to keep it simple!! Thank you!!!

Use nested loops to print out the multiplication table as follows, use 2 spaces for the product and leave a tab between the equations: 1x1- 1 1x2- 2 1x9-9 2x1-2 2x2- 4 2x9-18 9x1-9 9x2-18... 9x9-81 You can start from the multiplication_table.c program from the class public directory on GRACE and modify it so that it prints out the table in the following three formats: . rotate the table 1x1- 1 2x1- 2 1x2- 2 2x2- 4 9x1-9 9x2-18 1x9-9 2x9-18 9x9-81 . only the lower triangle half 1x1- 1 2x1- 2 2x2- 4 3x1-3 3x2= 6 3x3= 9 9x1-99x2=18 9x3=27 9x9-81 only the upper triangle half

Explanation / Answer

Solution:

i) Rotate the Multiplication of tables

#include<stdio.h>
main()
{
int n,i,m,j;
printf(" Enter the value of N:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
printf(" TABLE OF %d IS:",i);
for(j=1;j<=10;j++)
{
m=i*j;
printf(" %d*%d=%d",i,j,m);
}
getche();
}

ii) Multiplication of tables only lower triangle half:

# include <stdio.h>

# include <conio.h>

void main()

{

int mat[10][10] ;

int m,i, j, size, lower = 0 ;

clrscr() ;

printf("Enter size of the square matrix : ") ;

scanf("%d", &size) ;

printf(" Enter the elements of the matrix : ") ;

for(i = 0 ; i < size ; i++)

for(j = 0 ; j < size ; j++)

    scanf("%d", &mat[i][j]) ;

printf(" The lower triangular matrix is : ") ;

for(i = 0 ; i < size ; i++)

{  

for(j = 0 ; j < size ; j++)

{

    if(j <= i)

    {

      printf("%d ", mat[i][j]) ;

      lower = lower + mat[i][j] ;

      m=i*j;

    }

    else

      printf(" ") ;

}

printf(" ") ;

}

printf(" The sum of lower triangular elements is : %d", lower) ;

getch() ;

}  

ii) Multiplication of tables only Upper triangle half:

# include <stdio.h>

# include <conio.h>

void main()

{

int mat[10][10] ;

int m,i, j, size, upper = 0;

clrscr() ;

printf("Enter size of the square matrix : ") ;

scanf("%d", &size) ;

printf(" Enter the elements of the matrix : ") ;

for(i = 0 ; i < size ; i++)

for(j = 0 ; j < size ; j++)

    scanf("%d", &mat[i][j]) ;

printf(" The upper triangular matrix is : ") ;

for(i = 0 ; i < size ; i++)

{

for(j = 0 ; j < size ; j++)

{  

  if(i <= j)

    {

      printf("%d ", mat[i][j]) ;

      upper = upper + mat[i][j] ;

      m=i*j;

    }

    else

      printf(" ") ;

}

printf(" ") ;

}

printf(" The sum of upper triangular elements is : %d ",upper);

getch() ;

}  

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote