0

Im very new to C, The programs primary function is to print multiplication tables up to the users specified integers. But the main thing that Im missing is being able to print the designated times table for which is being printed. For example this is the 1's time table this is the 2's time table etc. Thanks for your Help.

This is my output...

enter image description here

This is the Output i'am Looking to get to....

enter image description here

RAW CODE:

#include<stdio.h>


int main()
{
     int i, j, n, z,  product;
    
    printf("Please Enter an Interger: ");
    scanf("%d", &n);
    
    //next Interger
    
    printf("Please Enter an Interger: ");
    scanf("%d", &z);
    
     /* Generating Multiplication Table */
     for(i=1;i<=n;i++)
     {
          for(j=1;j<=z;j++) //Nested For Loop to iterate until the second interger is met
          {
               product = i*j;
               printf("%d x %d = %d\t", i, j, product);
          }
          printf("\n");
     }
     return(0);
}
3
  • 1
    Looks like the only thing you need to add is a print statement? The tables are correct right? Commented Apr 22, 2022 at 18:42
  • Thats correct the Tables are functioning as they are suppose t although I may need to work on the formatting a little bit, & Yes the print function would be the only thing I would need to add however I'm stuck as to where to add it in order to get the program to print after each times table is printed. Commented Apr 22, 2022 at 18:45
  • Images of code and output are generally frowned upon on StackOverflow. what you call the "raw code" is what you should include in questions, and similarly, the "raw output". Typically people would downvote you over this. Commented Apr 22, 2022 at 19:16

2 Answers 2

1

You are looking for this.

#include <stdio.h>

int main()
{
    int n, m, i, j, product;
    
    printf("Enter integer: ");
    scanf("%d", &n);
    
    printf("Enter integer: ");
    scanf("%d", &m);
    
    printf("\n");
    
    for(i=1; i<=n; i++) {
        printf("* %d Times Table*\n", i); //###
        for(j=1; j<=m; j++) {
            product = i*j;
            printf("\t%d x %d = %d\n", i, j, product); //###
        }
        printf("****************"); //###
        printf("\n\n"); //###
    }
    

    return 0;
}

The logic was fine, but you had to fix a bit your printf usage.

Sign up to request clarification or add additional context in comments.

1 Comment

That worked !! Thanks !! I'm looking through to see what you added to get to the solution . The only Thing I added was prompting the user
0

A little Bit Changes are Needed

#include<stdio.h>

int main()
{
 int i, j, n, z,  product;

printf("Please Enter an Interger: ");
scanf("%d", &n);

//next Interger

printf("Please Enter an Interger: ");
scanf("%d", &z);

 for(i=1;i<=n;i++)
 {
      printf("\n*%d Times Table*",i); //statement to print before table printing
      for(j=1;j<=z;j++) //Nested For Loop to iterate until the second interger is met
      {
           product = i*j;
           printf("\n %d x %d = %d\t", i, j, product); //to print on new line
      }
      printf("\n");
      printf("\n***********"); //* pattern as output demand     
 }
 return(0);

}

1 Comment

Thanks a bunch !! I see the formatting

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.