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


ADVERTISEMENT

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++ :: 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 :: 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 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++ :: User Input 10 Integers Of Array - Add Numbers Greater Or Equal To 10

Oct 29, 2013

create a program that asks the user to input 10 integers of an array the program will add the numbers greater or equal to 10.

View 6 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 :: Input From User As Char And Output In Hex Form

Sep 9, 2014

I'm trying to write a program that takes input from the user (thats a char) and outputs it to the monitor in hex form.The program is meant to continuously take input from the user then output to the monitor in hex form until an EOF is detected this triggers the program to close.The following code does this except that I get a lower case 'a' at the end of each output.I think the 'a' has to do with the enter key and if that is the case how can i tell the program to ignore this input from the user.

Example: input from user: ABC output to monitor: 41 42 43 a

Code:
#include <stdio.h>
int main(void) {
char myChar;
while(EOF != (myChar = getchar())) {
printf("%x ",myChar);
}
system("pause");
return 0;
}

View 5 Replies View Related

C++ :: Converting User Input Int To String Output?

Apr 22, 2014

I am writing a code in a class that will change the user input which is integer to a string. For example if the user enter 13347..the output should change to "one three three four seven" on the user screen.I'm not getting the right output.

Code below:

#include <iostream>
#include <string>
using namespace std;
string arr[]={"one","two","three","four","five","six","seven","eight","nine"};
class convertTo{
public:
int signed num;
int convet(){
cout<<"Enter a number to convert to string "; cin>>num;

[code]....

View 2 Replies View Related

C/C++ :: Program To Allow User Input And Output Perfect Number

Mar 11, 2014

The problem that I am having is that , the program outputs numbers that are perfect numbers and im not sure where i can add a statement to make it so that if it isn't a perfect number it doesn't output...

#include<iostream>// allows user input/output
#include<conio.h>
#include<fstream>//data file / result file
#include<iomanip>
#include<cmath> // math function
#define in_file "data.txt"
#define out_file "result.txt"

[Code] ....

View 3 Replies View Related

C/C++ :: Input User Name And Height In Inches And Output In Centimeters

Oct 22, 2012

I am attempting to write a simple C program, in which the user is asked to input their name and height in inches and the output is the user's height in centimeters.

I have attached my program and what happens when I try to run it.

Attached Images : PM.jpg (120.6 KB)

View 1 Replies View Related

C++ :: Output Vowel From User Input - Error With Strings And Functions

Nov 25, 2014

The program is supposed to read in a string from the user and then output the number of each vowel that the string has. My first function is initializing the vectors, and the one that I'm having trouble with is the function used to read the string from the user and save it.

Here's my code:

#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
using namespace std;

// FUNCTION PROTOTYPES GO HERE:
void init_vectors(vector<char> & vowels, vector<int> & frequencies);
string read_text(const string & prompt);

[Code] ....

And I'm getting the error:

freq.cpp: In function ‘std::string read_text(const std::string&)’:
freq.cpp:74: error: no matching function for call to ‘getline(std::istream&, const std::basic_string<char, std::char_traits<char>, std::allocator<char> >&)’

I'm not too sure if I can't use the function getline here or if there is something wrong with the function prototype itself but I'm pretty sure there isn't an error there as it was given to me.

View 4 Replies View Related

C++ :: Prompt User For Two Characters - Output Movies That Begin With Input

Nov 24, 2014

I have trouble printing out the movies starting with inputing only two letters.

#include <iostream> //cout, cin, endl,getline
#include <fstream> //ifstream
#include <cstdlib> // exit
using namespace std;

const int NUM_MOVIES = 116792;
struct Movie {

[Code] ....

View 1 Replies View Related

C++ :: Program Will Echo Letter (User Input) And Output Name Of The Day Of Week

Oct 21, 2012

Write a C++ program that does the following:

Prompt the user to enter a day of the week as M (or m), T, W, R, F, S, and U for Monday through Sunday respectively. The user may enter an upper or lower case letter.

When the user enters a character, the program will echo the letter and output the name of the day of the week.

Provide an error trap that reads something like "you have entered an invalid letter; program aborting." Suggestion: use a switch statement with the error trap as the default condition. it is not necessary to prompt for multiple inputs.

So I know how to get the program to echo back the letter and everything. What I am a little confused about is: will I have to define all the letters as their respective day? eg. make M== Monday. And if I do have to do that how would I get it to accept Upper and Lower case letters and recognize that that letter is == monday ect. ect.

Also my main problem is the switch statement as the error trap. I have never used the switch statement, but I know what they do. I just don't really understand how I would use it for an error trap. Am I suppose to just make a case for every other letter in the alphabet other then M T W R F S and U? Even if I do that then what if the user enters a number instead of a letter?

View 4 Replies View Related

C++ :: Looping - Input Numbers Until User Types 0 Then Output Product Of Non Zero Numbers

May 1, 2014

How to do the problem below using loop?

Input numbers until the user types a 0, then output the product of the non 0 numbers: e

E.g., if the user types 2 4 6 0, the program should output 48

View 3 Replies View Related

C++ :: How To Output A Table

Oct 1, 2014

How would I output a table in C++? I did it a while ago, but I do not remember how, nor do I have the source for the program I did it in.

View 2 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++ :: Goto Statement - No Output Data Table

Feb 26, 2015

Project Golfer.cpp

So when you enter the number 99 its supposed to quit the program and it wasnt so i fixed that then i noticed that if you don't hit the green its supposed to loop back to a certain point but it was going to far back so i put a goto statement in and now it wont output my data table.

View 1 Replies View Related

C/C++ :: Hash Table - Interpreting Valgrind Output

Nov 22, 2014

I have a large hash table, where each index has a container that has a doubly linked list. Things work up until releasing the memory. Each record is created with malloc, and each record->data is also created with malloc and the associated string is copied in using strcpy(). The table itself is released in another part of the program and doesn't produce and error.

/**
* valgrind --track-origins=yes
*/
==16898== Conditional jump or move depends on uninitialised value(s)
==16898== at 0x8049685: shFree (SpellHash.c:110)
==16898== by 0x8049352: unload (dictionary.c:115)
==16898== by 0x8048E64: main (speller.c:158)
==16898== Uninitialised value was created by a heap allocation

[Code] .....

How to interpret valgrind. Error resolved on a small problem. Now running into issues on large (>10000 words to check) problems. It appears the virtual machine just can't keep up for some reason. Running the code on my local computer produces no errors, memory usage is minuscule, and profile tools don't report any issues.

View 4 Replies View Related







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