Question

C Thank You for You x Home - OwNet x B Assignment 401 X CPP-A01 - Dynam x ASM-103 - Intege X ASM-A03 - Integex Calculus - FinC Thank You for You x Home - OwNet x B Assignment 401 X CPP-A01 - Dynam x ASM-103 - Intege X ASM-A03 - Integex Calculus - FinC Thank You for You x Home - OwNet x B Assignment 401 X CPP-A01 - Dynam x ASM-103 - Intege X ASM-A03 - Integex Calculus - Fin

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Hi,

Please refer screenshots for more clarity..

I've used double pointer and setw for setting width for printing in this code.. Please go through it..

C++ code:

//program starts here..

#include <iostream>
#include<stdlib.h>
#include<iomanip>
using namespace std;

int main() {
int row,col;
while(1)//while for validation
{
cout << "please enter the rows in the range of [1 to 10]:";
cin >> row;
if(row >= 1 && row <= 10)
break;
else
cout << "input not within the range[1 to 10]. Please Try again.." << endl;
}

while(1)//column validation
{
cout << "please enter the rows in the range of [1 to 10]:";
cin >> col;
if(col >= 1 && col <= 10)
break;
else
cout << "input not within the range[1 to 10]. Please Try again.." << endl;
}
int **arr = (int **)malloc(row * sizeof(int *));//allocating memory with row's size
//for each row one pointer
for(int i =0 ; i < row ; i++)
{
arr[i] = (int *)malloc(col * sizeof(int));//pointer to ith row ..
}
for(int i = 1 ; i <= row ; i++)
{
for(int j = 1; j <= col ; j++)
{
arr[i-1][j-1] = i*j;//multiplication and storing in 2D array
}
}
for(int i = 1; i <= col; i++)
{
cout << setw(3)<< " |" << i ;//setting width for each value and printing it
}
cout << endl;
for(int x = 1; x < col; x++)
{
cout << "-----*";
}
cout << endl;

for(int i = 0 ; i < row ; i++)
{
cout <<left <<setw(3) << i+1 ;//each row value
for(int j = 0; j < col ;j++)
{
cout <<"|" << setw(3)<< arr[i][j] ; //multiplication value
  
}
cout << endl;
for(int x = 1; x < col; x++)
{
cout << "-----*";//after each row, separator
}
cout << endl;
}
}

//End of the program

main.cpp saved #include <iostream> #include<stdlib.h> 3 #include<iomanip> using namespace std; int main() { int row,col; whilfor(int i = 1; i <= col; i++) 41 E cout << setw(3)<< 1 «i ;//setting width for each value and printing it 43 cout << endl;} ./main please enter the rows in the range of [1 to 10]:5, please enter the rows in the range of [1 to 10]:5 11 12 13 14 15} ./main please enter the rows in the range of [1 to 10]:-3, input not within the range[1 to 10]. Please Try again.. please e

If you have any doubts, please feel free to comment below..

Thank you..

Add a comment
Know the answer?
Add Answer to:
C Thank You for You x Home - OwNet x B Assignment 401 X CPP-A01 -...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Need help part B and C please. Thank you . CDA3201·Intro to Logic Desig Lab Assignment...

    Need help part B and C please. Thank you . CDA3201·Intro to Logic Desig Lab Assignment Name: Grade: 20 5) 120] At right is the state dingram for a Moore sequential 1 01.10 АО circuit which monitors two inputs XiXo. When the two inputs XiXo are 00, the output Z toggles at every clock When the two inputs XiXo are 11, the output Z toggles at every other clock. When the two inputs XiXo are different, the output Z holds...

  • Please code in C++. link to continue the code is this below or you can make...

    Please code in C++. link to continue the code is this below or you can make your own code if you wish(fix any mistakes if you think there are any in it): cpp.sh/3qcekv 3. Submit a header file (project3.h), a definition file (project3.cpp), a main file (main.cpp), and a makefile to compile them together. Make sure to run the command make and produce an application file and include it with your submission. For this project, you are required to create...

  • //Need help ASAP in c++ please. Appreciate it! Thank you!! //This is the current code I have. #include <iostream> #include <sstream> #include <iomanip> using namespace std; cl...

    //Need help ASAP in c++ please. Appreciate it! Thank you!! //This is the current code I have. #include <iostream> #include <sstream> #include <iomanip> using namespace std; class googlePlayApp { private: string name; double rating; int numInstalls; int numReviews; double price;    public: googlePlayApp(string, double, int, int, double); ~ googlePlayApp(); googlePlayApp();    string getName(); double getRating(); int getNumInstalls(); int getNumReviews(); string getPrice();    void setName(string); void setRating(double); void setNumInstalls(int); void setNumReviews(int); void setPrice(double); }; googlePlayApp::googlePlayApp(string n, double r, int ni, int nr, double pr)...

  • The both files are included. Where are these which are colorful. Point.h and point.cpp Hor this assignment you are provided the files for a class called point. Download the h and .cpp files and incl...

    The both files are included. Where are these which are colorful. Point.h and point.cpp Hor this assignment you are provided the files for a class called point. Download the h and .cpp files and include them in your project. IheじML diagram below details the class Point くくfriend>> ostream& operator.((ostream&, point&) <ごfriend::. İstream& operator:..イ1stream&-point& - : double - v doublc getX) double getYO double - sctX( double): void - set Y(double) : void - point(double-0.0, double-0.0 operator-(const point& bool perator< const...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT