Write a computer program that produces the desired output from the given input. Input: Positive integer nOutput: Tables for addition and multiplication modulo n
Write a computer
Input: Positive integer n
Output: Tables for addition and multiplication modulo n
Since you are not mentioning the programming language, here we are using C++ to complete the program.
PROGRAM:
//Header file
#include <iostream>
//Using the namespace
using namespace std;
//Defining the main
int main()
{
//Declaring n
int n;
//Printing statement
cout<<"\n\tTables for addition and multiplication modulo n";
cout<<"\nEnter the n-value:";
//Getting the table number
cin>>n;
//Printing statement
cout<<"Tables for addition\n";
//Looping for 10 lines
for (int i = 1; i <=10; i++)
{
//Generating the table for addition
cout << n << " + " << i<< " = "<< n + i << endl;
}
//Printing statement
cout<<"Tables for multiplication\n";
//Looping for 10 lines
for(int i=1;i<=10;i++)
{
//Generating the table for multiplication
cout << n << " * " << i << " = "<< n * i << endl;
}
return 0;
}
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images