C :: Printing Multiplication Table With The Dimension N Given As Input

Oct 26, 2013

I would like to print a multiplication table, with the dimension n given as input. I attached how the table looks like for n=7.

How do you output the character "-" in that sequence? The first and last numbers have 13 "-" characters before and after them, but the numbers in between have 8 "-" characters.

View 2 Replies


ADVERTISEMENT

C++ :: Output Multiplication Table From Two User Input Integers Between 2 And 10?

Jan 14, 2015

So I'm supposed to write something that will output a multiplication table from two user input integers between 2 and 10.

For example it should display like this is the user inputs 4 and 5

1 2 3 4 5
2 4 6 8 10
3 6 9 12 15
4 8 12 16 20

I was hinted to used two for loops and this is what I have thus far, what I can't figure out is how to display it like the example.

#include <iostream>
using namespace std;
int main() {
int num1;
int num2;
cout << "Enter two numbers between 2 and 10." << endl;

[Code] .....

View 2 Replies View Related

C :: Multiplication Table In 2D Array

Dec 30, 2014

I want to declare a 2D 4*4 array, and fills the array with the multiplication table of an integer x from the user, for example: x*1,x*2,x*3, ....., x*16 and how to pass that array to a function to print the array and to another function that swaps a column with another column chosen by the user.

View 3 Replies View Related

C++ :: Multiplication Table Using Functions?

May 25, 2013

how to print a multiplication table of 2,3 ,4 or any table using functions in c++.. ?

Remember using "Functions" e.g Multiplication(int x)
{ }
int main{
then call the function}

View 3 Replies View Related

C/C++ :: Multiplication Table - Formatting?

Mar 31, 2015

I have to build a multiplication table in c++ and Im close but it still isnt formatted properly...

// multiplication table
#include <iostream>
using namespace std;
int main() {
int integer, range;

cout << "Input integer range :"; cin >> integer; cout;
cout << "Input range :"; cin >> range; cout << endl;

[Code] ....

View 7 Replies View Related

C++ :: Multiplication Table In A Void Function?

Jan 20, 2015

I wanted to make a multiplication table.

Here's the code:

#include<iostream>
#include<conio.h>
using namespace std;
void initArray(int arg1[50][50], int r, int c) {
int val=1;
for(int row=0; row<r; row++) {

[code]....

I want the output to be like this:

1 2 3
2 4 6
3 6 9

If the user inputs 3 rows and 3 columns.

View 5 Replies View Related

C/C++ :: Enter Integer And Find Multiplication Table

Oct 19, 2014

This program to find the multiplication table, need explanation this step : printf("%d * %d =%d ", n, i, n*i);

#include <stdio.h>
int main() {
int n, i;
printf("Enter an integer to find multiplication table: ");
scanf("%d",&n);
for(i=1;i<=10;++i) {
printf("%d * %d =%d ", n, i, n*i);
} return 0;

View 7 Replies View Related

C# :: Writing A Program To Display Multiplication Table?

Feb 3, 2015

i need the output to display the product of every whole number from 1-3 in a table format.

this is the code i have so far. i know some brackets are missing but i just pasted the meat of the code. when i run the program i keep getting the number 1 displayed in a straight line going on forever

int multiply1 = 1;
int multiply2 = 1;
while(num1<=3)
{ // num1*num2;
//num1 = 0;
while(num2<=3)
{ Console.WriteLine(multiply1*multiply2);
if(num1>=3)
{ Console.Write();
}
}
num1++;
}

View 2 Replies View Related

C++ :: Two Dimensional Multiplication Table - Dynamic Memory Allocation

Jun 17, 2013

This is the question; Write a function that builds a two-dimensional multiplication table with arbitrary sizes for the
two dimensions.

This is what I have done. I have allowed the user to input whatever size table they want by arbitrarily choosing what value they can input. However I cannot get the board to have blank squares. I thought the char would do it.

Code: #include <iostream>
using namespace std;
char SQAURE_CHAR = {' '};
const int Board_Size = 14;

[Code] ....

View 3 Replies View Related

C :: Program That Prints Multiplication Table Using Nested Loops

Mar 9, 2013

Write a program that prints a multiplication table using nested loops. In main ask the user for the smallest column number , the largest column number and the size of the increment. Ask the user for the same information for the row values.

In the example the column values entered are: 5, 15 and 2 and the row values 3, 6 and 1.

Given those numbers you would generate the following table.

Multiplication Table
| 5 7 9 11 13 15 ___|___________________________________ | 3 |
15 21 27 33 39 45 4 | 20 28 36 44 52 60 5 | 25 35 45 55 65 75 6 | 30 42 54 66 78 90
Print the 24 values with the grey background. The other numbers show the values to be multiplied.

Code:
#include<stdio.h>
main() {
int a,b,c,d,e,f;
int i,j,total;
printf("Please enter smallest column number: ");
scanf("%i",&a);
printf("

[Code] ....

Challenge:
As an added challenge try to print out the column
headings (5 7 9 11 13 15) and the row headings (3 4 5 6)

View 1 Replies View Related

C/C++ :: 5x5 Multiplication Table Starting With The Number Of User Choice?

Feb 23, 2014

#include <stdio.h>
#include <stdlib.h>
int n;
int m;
char input[20];
int num;
int main() {
int num0;

[code]....

I'm supposed to write C program that will generate a 5 X 5 multiplication table starting with the number of the users choice. The program is supposed to operate within a loop and run until the user indicates that they no longer wish to enter any more numbers. I can get the program to run but am wondering what I need to do to get the program to ask for another number and how to make the program stop when the user no longer wants to play. Should I start with "Do you want to enter a number" if yes, run back through loop if no, goodbye?

View 8 Replies View Related

C++ :: Function To Build Multiplication Table Of Arbitrary Dimensions - Unexpected Output

Nov 8, 2013

So the latest challenge from jumping into c++ is as following.

Code:
Write a function that builds the multiplication table of arbitrary dimensions This chapter also talks a ton about 2d arrays.

So I've built my program thus far as this.

Code:
#include <iostream>
using namespace std;
int drawTable(int,int);
int main()

[Code] .....

So basically, the idea is that I can use the arrays dimensions as a placeholder, and just multiple them to get that specific spot, so table[0][0] = 0, [0][1] = 0 and so on. However the output actually seems to be randomly generated numbers so I'd like to ask, what am I doing wrong? Am I on the right track? Or have I missed the bus stop completely.

View 12 Replies View Related

C/C++ :: Printing Table Of ASCII Chars - Cannot Initialize Variable

Apr 9, 2014

I'm trying to write a program which prints a table of ASCII chars, I'm not really done with my thoughts on it but I already
ran into the following error:

Error: cannot initialize a variable of type 'char' with an rvalue of type 'char (*)[16]'

Here's my code so far:

# include <iostream>
using namespace std;
int main() {
char asciiTable = new char[8][16];
int nextSign = 0;

[Code] .....

View 4 Replies View Related

C :: Unable To Input Correct Form For Matrices Multiplication

Jan 8, 2015

I am unable to input the correct form for matrices multiplication. I have an exam tomorrow in which I need to use this.

Code:

#include <stdio.h>
#include <conio.h>
int main() {
float a[10][10], b[10][10], c[10][10];
int i, j, k, l, n=0, m=0, x=0, y=0, sum=0;
printf("Enter the number of rows and collumns of the first matrix");
scanf("%d %d", &n, &m);

[Code]...

View 7 Replies View Related

C++ :: Printing Substrings From Input String

May 24, 2014

I'm having trouble printing the text in between separators like commas, periods, and at signs. I'm following Jumping into C++ Chapter 19 Practice Problem 2.

This is what I have so far:

Code:
#include <iostream>#include <string>
usingnamespacestd;
int findNeedle (char separator, string inputLine) {
int needleAppearences = 0;

[Code] ....

And this was my test run output:

Enter the contact info. one, two, three, ,? , one two, th three, Program ended with exit code: 0

View 4 Replies View Related

C++ :: Program To Make A Table For Any Input Number - Do While Loop

Nov 27, 2014

Write a program to make a table for any input number and then continuesly ask to press y to print more table and if you press any key other than y then program must be terminate using while loop and do while loop. How to start or end with it.

View 2 Replies View Related

C++ :: Printing The First N Prime Numbers (user Input)

Jan 15, 2014

//Finding prime numbers
#include <iostream>
using namespace std;

[Code]....

/*The program currently prints all the prime numbers up to n (For example, if 7 is entered, it prints out: 1, 2, 3, 5, 7. What I want it to do, is print out the first 7 numbers; 1, 2, 3, 5, 7, 11, 13.

View 1 Replies View Related

C :: Bulls And Cows Program - Compare Table With Input String

Dec 14, 2013

I'm having a small problem on comparing a table i coded with a string that I want to input. I'm actually building a Bulls and Cows program and this is part of my assignment. What i want to do is to input a string and from the table get the results compared to the string i inputted.

Few words about the Bulls and Cows program.

The game involves two players, a coder and a cracker. The coder (either a person or a computer) chooses the four-digit number with all different digits and keeps it secret. The cracker tries to guess the secret number. After a guess, the coder gives you information about number of digits which were correctly guessed but in the wrong place (they are called 'cows') and how many are both the right digit and in the correct place (they are called 'bulls').

For example, if the coder chooses the secret number 0419 and the cracker guesses 6039, then the coder scores this as 1 cow, since 0 is a digit in the secret number that's in the wrong place, and 1 bull (9 is in the right place.)

what i want to do is when i input a string it scans the whole table of possibilities and gives me the results based on the string. so each row of my table is (let's say the secret code) and based on the given string(the guess) it gives me the result. Here's my table code:

Code:
void initialize(int poss[1296][4])
{
int i=0;
int j, k=0;
int m;

[Code] .....

View 2 Replies View Related

C++ :: Printing Double Triangle - Working Fine Up To Input 7

Feb 22, 2013

I wrote code for printing a double triangle. Its woking fine upto input is 7. but when the input is 8 the output is disturbed. the code is this.

#include<iostream>
using namespace std;
int main() {
int a;
cout<<"Enter a number"<<endl;

[Code] ....

View 3 Replies View Related

C/C++ :: Printing Square Pattern Of Asterisks Based On User Input

Dec 15, 2014

I have to make a program that displays a square of asterisks based on the users input. Here is what I have so far.

#include<iostream>
using namespace std;
int main(){
int number;
cout << "Enter a number: ";
cin >> number;
for (int i = 0; i < number; i++){

[Code] ....

But the square needs to be hollow like this. So if the user enters 5 then the following square will be shown.

*****
* *
* *
* *
*****

How to make it do this.

View 11 Replies View Related

C++ :: Hash Table Program - Sorting Pointer Table After All Of Values Entered

Nov 19, 2013

I am having an issue with my sort function. This is one part of the Hash table program. The main issue is that I am trying to sort the pointer table after all of the values have been entered. The ptr_sort function is not a class function and so I am therefore unable to use the class variables psize and pTable. Is there another way I should be trying this? it is a Vector should I use the sort() function from the vector class in STL?

#include "/home/onyuksel/courses/340/progs/13f/p9/util9.h"
#include "/home/onyuksel/courses/340/progs/13f/p9/hTable.h"

#ifndef H_TABLE1
#define H_TABLE1
void ptr_sort ( );

[Code] ....

View 1 Replies View Related

C++ :: Truth Table Generator - If User Enters String Of Boolean Algebra It Will Output Table

Jan 25, 2013

If a user enters a string of boolean algebra it will ouput the table.

I have input parsing, cycling through the combinations, and outputing working. However once i parse the input I am not sure what to do with it. I have thought of having it write the parsed input to a new file as a function and then use that function, but that seems bad.

How to dynamically create the function, how to implement it.

BTW This is a console function, if that changes anything.

View 2 Replies View Related

C# :: Lookup Non-existent Rows In MySQL Table And Then Update Another Table

Dec 15, 2014

I have written an SQL statement that would:

1) Count the number of rows in the table booking that are open and where the booking.postcode is "MK",

2) Take a note of the plot (in booking.plot_id), and then update the table plot.jobs with the value count.

For example running the SQL query when booking table has the following rows:

Would see the following highlighted values in plot.jobs being updated to 1:

I managed to resolve it with this code so far (note I am using Connector/Net):

public void RefreshPlot(){
string query =
"SELECT Count(*) AS count, plot_id FROM booking WHERE postcode='MK' AND status='open' GROUP BY plot_id";
var cmd = new MySqlCommand(query, _connection);
var da = new MySqlDataAdapter(cmd);
var dtCounts = new DataTable();
da.Fill(dtCounts);

[code]....

Currently, my code only checks for existing rows in the booking table and updates the plot table. However if the row gets deleted in the booking, then the changes are not reflected in the plot table.

Example: If we delete the row with plot.id=1 and plot.plot_id=4, then booking.plot_id should go back to being 0, if it was initially 1. At the moment, it doesn't. How would I update my SQL statement to better reflect this? In a sense, it should check for "non-existent" rows, i.e. the impact that the row plot.plot_id=4 & plot.id=1 has on booking.plot_id when deleted?

View 6 Replies View Related

C Sharp :: Copy Data Table To MySQL Table

Mar 25, 2013

I have a C# .NET Application which get data from QuickBooks via the ODBC Driver and save the result to C# data table. So, I want to transfer this data table to a mysql table on my own server. That's the code I use:
 
using System.IO;
using MySql.Data.MySqlClient;
//Add mysql dll on the .NET Tab in Project's references  
string connStr = "DSN=QBTest;";  
            string myServerAddress = "192.168.0.243";
            string myDataBase = "CostTest";

[Code] ....

View 2 Replies View Related

C/C++ :: Get Dimension Of Pixel In Mm?

Apr 17, 2012

I have an image of size 640x480 pixels. It's possible to obtain the dimension in mm of one pixel from that image given only that size?I do not have the size of the image in mm,however.

View 5 Replies View Related

C# :: Use Table Adapter With Textboxes To Edit SQL Table?

Mar 8, 2015

I am a bit stumped with trying to write some code to get the tableadapter/binding source to "update" a current 'user' to the table.

I have the insert/delete methods working fine, but it's the updating that has got me screwed up.

Example of insert.

try
{
personTableAdapter.Insert(tFirstName.Text, tSurname.Text, Convert.ToDateTime(tDoB.Text), tPhone.Text, tAdd1.Text, tAdd2.Text, tSuburb.Text, tState.Text, tPostcode.Text, TeacherType.Text);
teacherTableAdapter.Insert(Convert.ToInt32(tTID1.Text), tRegNo.Text, tPassword.Text);

[Code]....

I also tried to do the updated string/original string with the tableadapter.update, but that didn't work either.

View 7 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved