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


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 :: 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 :: 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/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++ :: 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/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++ :: Pass 2 Arrays Into Void Function And Return Values To One Function?

Feb 12, 2014

I'm trying to pass 2 arrays into a void funtion, and return values to one function.

this is the the program I'm working with, after I'm done I have to split it into 3 files, a header, a main, and a separate cpp file for the functions to live in.

#include <iostream>
using namespace std;
void processArrary(int numberCount[], int Numbers[], int intnumberSize, int numberCountSize);
int main() {
int Scores[26] = {76, 89, 150, 135, 200, 76, 12, 100, 150, 28, 178, 189, 167, 200, 175, 150, 87, 99, 129, 149, 176, 200, 87, 35, 157, 189};
int numberCount[8] = { 0 };

[code]...

The goal of this program is to separate and count the groups of numbers then output the amount of numbers in each group. Near as I can tell, everthing should work, but I'm getting all zeros to be displayed in each group.

View 6 Replies View Related

C :: Multiplication With Sort Function

Oct 30, 2014

I need to include validation to only accept numbers and to only the last four odd numbers in the table.

Code:

#include <stdio.h>void main() {
int upper, range, i;
printf("Enter an integer to find multiplication table: ");
scanf("%d",&upper);

[Code].....

View 3 Replies View Related

C :: Math Quiz Program - Multiplication Function

Nov 16, 2014

Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
void correctResponse(void);
void incorrectResponse (void);
void multiplication( void ); // function prototype

[Code] ....

// end function multiplication

// It keeps crashing. How do I compile the responses into a grade?

View 5 Replies View Related

C/C++ :: Parallelize Matrix Multiplication Function Dynamically And Statically

Oct 1, 2014

I've been trying to get my matrix multiplication program to run a few different ways. My assignments wants me to run it statically using chunks, but we're not supposed to use OpenMPs scheduler. So I'm not sure how that's possible. And secondly, we have to run it dynamically using locks/unlocks.

Static (not sure how to implement chunk)

#pragma omp section
{
printf("Thread %d doing matrix mult", threadID);
if (matrixAcols != matrixBrows) {
cout << "Error, operation not possible" << endl;

[Code]....

The code will run for a long time too. It uses as many threads as we tell it to but it never speeds up the results.

Quote
Thread 2 doing matrix mult
Thread 4 doing matrix mult
Thread 2 doing matrix mult
Thread 4 doing matrix mult
Thread 2 doing matrix mult
Thread 4 doing matrix mult
Thread 2 doing matrix mult
Thread 4 doing matrix mult
Thread 4 doing matrix mult
Thread 4 doing matrix mult
Thread 4 doing matrix mult
Thread 4 doing matrix mult
Thread 4 doing matrix mult
Thread 4 doing matrix mult

View 2 Replies View Related

C++ :: Void As Function Argument

Mar 24, 2014

I was reading about void as function argument, but I did not fully understand it's meaning in C.

In C++
void foo(void) {}
and
void foo() {}

are the same. It means no arguments for foo function. But in C it's different. First function means the same as in C++, but second means

In C, an empty parameter list means that the number and type of the function arguments are unknown. But if it is unknown you can't use this arguments if user specifies same. Because here are no variables to store them. So doesn't result are the some? You do not get any arguments. O do I can get this arguments from some hidden variable?

For example.

void foo() {
printf("%d", var);
}
foo(5);

It is very unclear for me. Do this apply to main function too?

int main(void)
int main()

or can I use arguments given to int main() like given to int main(int argc, char* argv[])

View 4 Replies View Related

C++ :: Using Break In Void Function That Does Not Contain A Loop

Jan 14, 2015

I need this break in my main function, but I'm not allowed to put it in void since void is not located in a loop. How can I solve this?

Code:
#include <iostream>#include <string>
using namespace std;
void login(string x, string y);
string username;
string password;
string x;
string y;

[Code] ....

View 6 Replies View Related

C :: Program To Use Void Pointers In A Function

May 14, 2014

As part of my ongoing c programming education, I have written a program to use void pointers in a function,

Code:

#include <stdio.h>
#define MAX_NUMBERS 10
size_t size(void *object);
int main(void) {
}

[code]....

Now I think that the result 4 is the size of the pointer, so I'm confussed as why it doesn't give me the same result as 40.

View 2 Replies View Related

C++ :: If Statement - Void Function Not Calling

Nov 2, 2013

I've been trying to get my program to call void functions with an if statement, but when i run my program and try to call one of the functions "worst case, best case, or random case" it doesn't get called. It just prompts the original menu.

#include<iostream>
#include<fstream>
using namespace std;
void bubbleSort();
void selectionSort();

[Code] .....

View 1 Replies View Related

C++ :: Void Function To Calculate Payroll

Dec 9, 2014

The purpose of this code is to calculate a pagecheck for intered hours and overtime for any hours over 40! This is what I have so far!

#include<iostream>
using namespace std;
void Amount (int hours, int wage, int sum);
void printCheck(int sum);
int main()

[code]....

View 1 Replies View Related

C++ :: Opening A File In Void Function

Feb 26, 2013

how do you open a file inside of a void function

this is the code i have

#include <iostream>
#include <fstream>
#include <sstream>

[Code]....

View 6 Replies View Related

C++ :: How To Pass Char To Function Void

Jun 1, 2013

How to pass the char something[8][8] for example to function void ( char pass.....)???

View 7 Replies View Related

C++ :: How To Pass A Void Function As Parameter

Oct 20, 2013

How can I pass a function as a parameter? I have a class that I'm trying to reuse and one of the methods in this class need to take three parameters, two ints and a function. In other words I want to be able to call a custom function every time this method is invoked when used in other classes. The function I want to call will not return any values, its a void function.

In my Class:

void Utility::someFunction(int var1, int var2, void customFunction) {
int num1 = var1;
int num2 = var2;

[Code] .....

View 9 Replies View Related

C++ :: Using A Void Function For Data Input?

Feb 20, 2014

Modifying this program to Create a function that has the following prototype: void getInputChar(string, char &);.

The function should display the string on the screen and then use cin to read a char from the keyboard.

#include <iostream>
using namespace std;
bool ignoreCaseCompare (char, char);

[Code].....

View 1 Replies View Related

C/C++ :: Find Max And Min Value In Void Function Using Pointers

Aug 31, 2014

I'm having issues with pointers and relationship operators in C.

I need to find a max and min value in a void function using pointers. max and min would work if they had values. mul works, because you can just do math operations with pointers.

There are 0 errors and warnings; but max and min are never going to work as is.

Clearly I'm missing something.

#include <stdio.h>
#include <stdlib.h>
void max(int *a, int *b, int *c, int *d, int *result);
void min(int *a, int *b, int *c, int *d, int *result);
void mul(int *a, int *b, int *c, int *d, int *result);
int main()

[Code]...

Your job will be to create a program that uses pointers. Your output must be done in the main function and the calculations MUST be done in the three functions. Therefore you MUST use pointers correctly.

You must declare and implement the following 3 functions. Below are the three prototypes that you must use in this program.

void max(int *a, int *b, int *c, int *d, int *result);
void min(int *a, int *b, int *c, int *d, int *result);
void mul(int *a, int *b, int *c, int *d, int *result);

The functions have the following meaning:

max
finds the max value of a,b,c,d and stores the largest value in result.
min
finds the min value of a,b,c,d and stores the largest value in result.
mul
multiplies a * b * c and divides by d. Stores that value in result.

Below is an example input/output. This input will be read in via the keyboard (use scanf).

input
output (note that user input is shown in bold)
1 2 3 4
Enter the 4 numbers: 1 2 3 4
The max is 4. The min is 1. (a * b * c) / d = 1
100 3 201 103
Enter the 4 numbers: 100 3 201 103
The max is 201. The min is 3. (a * b * c) / d = 585

Your output MUST match exactly the output below for the input from above. Your program must compile, failure to do so will result in 0 points. */

View 9 Replies View Related







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