Question

I need a program written in C, not C+ or C++. I have no idea how...

I need a program written in C, not C+ or C++. I have no idea how to go about doing it. Basically, I need it to take in the following information and spit out the following for a number table. The operation should be able to take plus, minus, division or multiplication and the low/high row/column numbers should be able to go up to where ever. But I'm sure the following example is fine.

Enter low row number: 1

Enter high row number: 3

Enter low column number: 1

Enter high column number: 4

Enter operation: +

+ 1 2 3 4

1 2 3 4 5

2 3 4 5 6

3 4 5 6 7

** Table Complete **

Homework Answers

Answer #1

I have uploaded the Images of the code, Typed code and Output of the Code. I have provided explanation using comments(read them for better understanding).

Images of the Code:


Note: If the below code is missing indentation please refer code Images

Typed Code:

/*Libraries*/
#include <stdio.h>
#include <stdlib.h>
void main()
{
/*declaring integers and character*/
int lr,hr,lc,hc;
char op;
/*taking inputs from the user*/
printf("Enter low row number: ");
scanf("%d",&lr);
printf("Enter high row number: ");
scanf("%d",&hr);
printf("Enter low column number: ");
scanf("%d",&lc);
printf("Enter high coloumn number: ");
scanf("%d",&hc);
/*if low values greater than high values */
if(lr>hr || lc>hc)
{
/*it is invalid and program will exit*/
printf("You have entered invalid input");
exit(0);
  
}
/*taking operator as input from user*/
printf("Enter operation: ");
scanf(" %c",&op);
/*if operator is not (+,-,*,/) */
if(op != '+' && op != '-' && op != '*' && op != '/')
{
/*operators are invalid and program exits*/
printf("You have entered wrong operation");
exit(0);
}
/*printing operator*/
printf(" %c\t",op);
/*for loop will iterate from lc(low column) to hc(high column)*/
for(int i = lc; i <= hc; i++)
{
/*printing values from lc to hc, one after one in every iteration*/
printf("%d\t",i);
}
/*for loop will iterate from lr(low row) to hr(high row)*/
for(int j = lr; j <= hr; j++)
{
/*\n is escape character to jump to next line*/
printf("\n");
/*printing values from lr to hr, one after one in every iteration*/
printf("%d\t",j);
/*this for loop is used for operation purpose
it will iterate from lc to hc*/
for(int k = lc; k <= hc; k++)
{
/* if op is + */
if(op == '+')
{
/*adding row element with column element*/
printf("%d\t",j+k);
}
/* if op is - */
else if(op == '-')
{
/*subtracting row element with column element*/
printf("%d\t",j-k);
}
/* if op is * */
else if(op == '*')
{
/*multiplying row element with column element*/
printf("%d\t",j*k);
}
/* if op is / */
else if(op == '/')
{
/*dividing row element with column element*/
printf("%d\t",j/k);
}
}
}
}
/*code ended here*/

Output:


If You Have Any Doubts. Please Ask Using Comments.

Have A Great Day!

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
I'm working with doubly linked lists in c++, I have written my classes and constructors. I...
I'm working with doubly linked lists in c++, I have written my classes and constructors. I need help with a randomizing method, any guidance or sample code would be appreciated, I'm pretty lost. For the method: void DLL::Random(); I want to basically shuffle/randomize my list. My list is a list of strings (names) if that's important to know. I'm mainly struggling with how to use pointers to prev and next to apply to each node and then move them throughout...
using C++ 1) write a program to calculate to avg of N number of subjects. 2)write...
using C++ 1) write a program to calculate to avg of N number of subjects. 2)write a program to find the factorial of 5! 5*4*3*2*1 3)write a program to display the multiplication table for any number please enter number : 3 1*3=3 2*3=6 2*4= 10*3=30 4) find the factorial on n
Question: Write a C++ program to ask the user to give you the number of rows...
Question: Write a C++ program to ask the user to give you the number of rows and number of columns, then make the multiplication table by using nested loop. For example, if the user enters 3 for rows and 4 for columns then the multiplication table would be like the following: 1    2   3     4 1   1 2 3 4 2   2    4      6    8 3    3 6 9 12
In C++ write a program for a multiplication table It must Prompt the user for two...
In C++ write a program for a multiplication table It must Prompt the user for two integers between 1 and 20 (inclusive) • also must Calculates and displays the multiplication table in a well-formatted output The table must include a label for each row and column The program must follow the requirements: • Validates user input, displaying an error message and prompting to user to enter another integer if the input is invalid, and repeating it as many times as...
I need to use a Bubble Sort to sort data: “C”, “Y”, “B”, “N”, “Q”, “G”,...
I need to use a Bubble Sort to sort data: “C”, “Y”, “B”, “N”, “Q”, “G”, “C” – show count of “swaps” for each 8 Queens: Place initial “Queen” on row 6, column 1 *Knight’s Tour – initial position Row 1, Column 1, for the Queens question I just need the final position of the Queen
I need this as soon as possible, please. It is due two hours and I need...
I need this as soon as possible, please. It is due two hours and I need to check my answers. Problem-1 Calculate the Product of the following using refined multiplication method (show all steps in table)                                                                 6 X 3
I need code for a problem in Matlab Create a single Matlab script that accomplishes the...
I need code for a problem in Matlab Create a single Matlab script that accomplishes the following: Defines a blank tic tac toe board, a 3 x 3 matrix, called board with blank spots represented by zeros. Asks player 1 for a row and column, then puts 1 in a given location. Asks player 2 for a row and column, then puts 2 in a given location
In Java. Write a program that reads-in a times table-number. The program, using this table-number will...
In Java. Write a program that reads-in a times table-number. The program, using this table-number will produce the following report (as shown). The first item in the report is a number with starting value 1. Second column is the word “ X ” (representing the times symbol). Third column is the table-number (itself). Following is an equal sign “ = “ (representing a result). Last column is the result of the operation for that line or row which is the...
The answers to the practice quiz are below I need to understand why the answers are...
The answers to the practice quiz are below I need to understand why the answers are correct. Consider the One-Way ANOVA table (some values are intentionally left blank) for the pizza delivery times of 20 randomly assigned deliveries at four pizza franchises(A, B, C, D) (5 observations per franchise or Group). H0:MeanA=MeanB=MeanC=MeanD         H1: At least one mean is different. Please answer questions 1, 2, 3, and 4, based on the following table. ANOVA Source of Variation SS df MS F...
I need this written in both shell script and C. Assume that it goes on infinitely...
I need this written in both shell script and C. Assume that it goes on infinitely Program 3: nested loop. e.g. 1*2 + 2*3 + 3*4 + ...(n-1)*n  (Only nested loops)
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT