answersLogoWhite

0

What else can I help you with?

Continue Learning about Engineering

How do declare function pointer having two integer parameters and returning integer pointers?

// declare a function int* function(int, int); or int* (function)(int, int); // declare a pointer to a function int* (*pointer_to_function)(int, int);


How do you do matrix multiplication in c using structure?

You took an example of The Product AB is determined as the dot products of the ith row in A and the jth column in B,placed in ith row and jth column of the resulting m x p matrix C. so: this may help you. #include <stdio.h> #include <stdlib.h> // function prototypes void Matrix_Mult( int a1[][3], int a2[][4], int a3[][4] ); void Matrix_MultAlt( int a1[][3], int a2[][4], int a3[][4] ); int dot3(const int a1[][3], const int a2[][4], int row, int col); void PrnNx4 (int ar[][4], int n); //--------------------------------------------------------------------------------- // Function: main(void) // Description: // demonstration of Matrix Multiplication // // Programmer: Paul Bladek // // Date: 10/31/2001 // // Version: 1.0 // // Environment: Hardware:IBM Pentium 4 // Software: Microsoft XP with .NET framework for execution; // Compiles under Microsoft Visual C++.Net 2005 // // Calls: Matrix_Mult(int a1[][3], int a2[][4], int a3[][4]) // Matrix_MultAlt(int a1[][3], int a2[][4], int a3[][4]) // PrnNx4(int ar[][4] // // // Parameters: int a1[][3] -- left matrix // int a2[][4] -- right matrix // int a3[][4] -- answer matrix // // Returns: EXIT_SUCCESS // ------------------------------------------------------------------------------ int main(void) { int A[2][3] = {{1, 3, 4}, {2, 0, 1}}, B[3][4] = {{1, 2, 3, 1}, {2, 2, 2, 2}, {3, 2, 1, 4}}, C[2][4] = {{0, 0, 0, 0}, {0, 0, 0, 0}}; Matrix_Mult(A, B, C); PrnNx4(C, 2); Matrix_MultAlt(A, B, C); // alternate form that calls dot3 PrnNx4(C, 2); return EXIT_SUCCESS; } //--------------------------------------------------------------------------------- // Function: Matrix_Mult(int a1[][3], int a2[][4], int a3[][4]) // Description: // multiplies a 2X3 matrix by a 3X4 matrix // // Programmer: Paul Bladek // // Date: 10/31/2001 // // Version: 1.0 // // Environment: Hardware:IBM Pentium 4 // Software: Microsoft XP with .NET framework for execution; // Compiles under Microsoft Visual C++.Net 2005 // // Calls: None // // Called By: main() // // Parameters: int a1[][3] -- left matrix // int a2[][3] -- right matrix // int a3[][3] -- answer matrix // ------------------------------------------------------------------------------ void Matrix_Mult(int a1[][3], int a2[][4], int a3[][4]) { int i = 0; int j = 0; int k = 0; for(i = 0; i < 2; i++) for( j = 0; j < 4; j++) for( k = 0; k < 3; k++) a3[i][j] += a1[i][k] * a2[k][j]; } //--------------------------------------------------------------------------------- // Function: Matrix_MultAlt(int a1[][3], int a2[][4], int a3[][4]) // Description: // multiplies a 2X3 matrix by a 3X4 matrix -- Alternate Form // // Programmer: Paul Bladek // // Date: 10/31/2001 // // Version: 1.0 // // Environment: Hardware:IBM Pentium 4 // Software: Microsoft XP with .NET framework for execution; // Compiles under Microsoft Visual C++.Net 2005 // // Calls: dot3(const int a1[][3], const int a2[][4], int row, int col) // // Called By: main() // // Parameters: int a1[][3] -- left matrix // int a2[][3] -- right matrix // int a3[][3] -- answer matrix // ------------------------------------------------------------------------------ void Matrix_MultAlt(int a1[][3], int a2[][4], int a3[][4]) { int i = 0; int j = 0; for( i = 0; i < 2; i++) for( j = 0; j < 4; j++) a3[i][j] = dot3(a1, a2, i, j); } //--------------------------------------------------------------------------------- // Function: dot3(const int a1[][3], const int a2[][4], int row, int col) // Description: // dot product of a1 row and a2 col // // Programmer: Paul Bladek // // Date: 10/31/2001 // // Version: 1.0 // // Environment: Hardware:IBM Pentium 4 // Software: Microsoft XP with .NET framework for execution; // Compiles under Microsoft Visual C++.Net 2005 // // Calls: None // // Called By: Matrix_MultAlt(int a1[][3], int a2[][4], int a3[][4]) // // Parameters: int a1[][3] -- left matrix // int a2[][3] -- right matrix // int row -- the row number // int col -- the column number // // Returns: the dot product // ------------------------------------------------------------------------------ int dot3(const int a1[][3], const int a2[][4], int row, int col) { int k = 0; int sum = 0; for( k = 0; k < 3; k++) sum += a1[row][k] * a2[k][col]; return sum; } //--------------------------------------------------------------------------------- // Function: PrnNx4(int ar[][4], int n) // Description: // prints out an NX4 matrix // // Programmer: Paul Bladek // // Date: 10/31/2001 // // Version: 1.0 // // Environment: Hardware:IBM Pentium 4 // Software: Microsoft XP with .NET framework for execution; // Compiles under Microsoft Visual C++.Net 2005 // // Called By: main() // // Parameters: int ar[][4] -- matrix to print // int n -- number of elements // ------------------------------------------------------------------------------ void PrnNx4 (int ar[][4], int n) { int i = 0; int j = 0; for(i = 0; i < n; i++) { for( j = 0; j < 4; j++) printf("%4d", ar[i][j]); putchar('\n'); } }


Get size of int using sizeoff?

printf ("sizeof (int) = %d\n", (int)sizeof (int));


What is the use of time.h in c?

The time.h include file is a header file for a library of standard time and date manipulation routines. For example... #include <stdio.h> #include <time.h> int main (int argc, char ** argv) { time_t tt = time(NULL); printf ("The date and time is %s", asctime(localtime(&tt))); return 0; }


C plus plus prog a function sum that returns the sum of all Values in the given array int sum int list int arraySize?

int sum(int list[], int arraySize) { int sum=0; for(int i=0; i<arraySize; ++i ) sum+=list[i]; return(sum); }

Related Questions

How I can Coding in c plus plus of a program that input date and display the day?

One way to determine the day of week based on the date is to use Zeller's congruence. For the Gregorian calendar... int dayofweek (int month, int day, int year) { int weekday; if (month < 3) month += 12; weekday = day; weekday += int ((month + 1) * 26 / 10); weekday += year; weekday += int (year / 4); weekday += 6 * int (year / 100); weekday += int (year / 400); weekday %= 7; return weekday; /* 0 = Sunday, ..., 6 = Saturday */ }


What three C code snippets WILL NOT read a date as three integers as follows int day month year?

Which of the following three C code snippets WILL NOT read a date as three integers as follows: int day, month, year;


30 examples of variables?

int n1; int n2; int n3; int n4; int n5; int n6; int n7; int n8; int n9; int n10; int n11; int n12; int n13; int n14; int n15; int n16; int n17; int n18; int n19; int n20; int n21; int n22; int n23; int n24; int n25; int n26; int n27; int n28; int n29; int n30;


If a company issues bonds on July 1st 2010 assuming they are semiannual bonds with int payble on july1 and jan1 what would be the first int payment date would it be july2010 ie on the date of issue?

No, the first payment would be 6 months later on Jan 1.


What is Deferred int expenses?

Deferred int expenses is a term used in accounting for business and finance. It is used to refer to the interest on loans and payments, which is considered an expense that is deferred, or expected to be paid at a later date.


How do declare function pointer having two integer parameters and returning integer pointers?

// declare a function int* function(int, int); or int* (function)(int, int); // declare a pointer to a function int* (*pointer_to_function)(int, int);


How do you do matrix multiplication in c using structure?

You took an example of The Product AB is determined as the dot products of the ith row in A and the jth column in B,placed in ith row and jth column of the resulting m x p matrix C. so: this may help you. #include <stdio.h> #include <stdlib.h> // function prototypes void Matrix_Mult( int a1[][3], int a2[][4], int a3[][4] ); void Matrix_MultAlt( int a1[][3], int a2[][4], int a3[][4] ); int dot3(const int a1[][3], const int a2[][4], int row, int col); void PrnNx4 (int ar[][4], int n); //--------------------------------------------------------------------------------- // Function: main(void) // Description: // demonstration of Matrix Multiplication // // Programmer: Paul Bladek // // Date: 10/31/2001 // // Version: 1.0 // // Environment: Hardware:IBM Pentium 4 // Software: Microsoft XP with .NET framework for execution; // Compiles under Microsoft Visual C++.Net 2005 // // Calls: Matrix_Mult(int a1[][3], int a2[][4], int a3[][4]) // Matrix_MultAlt(int a1[][3], int a2[][4], int a3[][4]) // PrnNx4(int ar[][4] // // // Parameters: int a1[][3] -- left matrix // int a2[][4] -- right matrix // int a3[][4] -- answer matrix // // Returns: EXIT_SUCCESS // ------------------------------------------------------------------------------ int main(void) { int A[2][3] = {{1, 3, 4}, {2, 0, 1}}, B[3][4] = {{1, 2, 3, 1}, {2, 2, 2, 2}, {3, 2, 1, 4}}, C[2][4] = {{0, 0, 0, 0}, {0, 0, 0, 0}}; Matrix_Mult(A, B, C); PrnNx4(C, 2); Matrix_MultAlt(A, B, C); // alternate form that calls dot3 PrnNx4(C, 2); return EXIT_SUCCESS; } //--------------------------------------------------------------------------------- // Function: Matrix_Mult(int a1[][3], int a2[][4], int a3[][4]) // Description: // multiplies a 2X3 matrix by a 3X4 matrix // // Programmer: Paul Bladek // // Date: 10/31/2001 // // Version: 1.0 // // Environment: Hardware:IBM Pentium 4 // Software: Microsoft XP with .NET framework for execution; // Compiles under Microsoft Visual C++.Net 2005 // // Calls: None // // Called By: main() // // Parameters: int a1[][3] -- left matrix // int a2[][3] -- right matrix // int a3[][3] -- answer matrix // ------------------------------------------------------------------------------ void Matrix_Mult(int a1[][3], int a2[][4], int a3[][4]) { int i = 0; int j = 0; int k = 0; for(i = 0; i < 2; i++) for( j = 0; j < 4; j++) for( k = 0; k < 3; k++) a3[i][j] += a1[i][k] * a2[k][j]; } //--------------------------------------------------------------------------------- // Function: Matrix_MultAlt(int a1[][3], int a2[][4], int a3[][4]) // Description: // multiplies a 2X3 matrix by a 3X4 matrix -- Alternate Form // // Programmer: Paul Bladek // // Date: 10/31/2001 // // Version: 1.0 // // Environment: Hardware:IBM Pentium 4 // Software: Microsoft XP with .NET framework for execution; // Compiles under Microsoft Visual C++.Net 2005 // // Calls: dot3(const int a1[][3], const int a2[][4], int row, int col) // // Called By: main() // // Parameters: int a1[][3] -- left matrix // int a2[][3] -- right matrix // int a3[][3] -- answer matrix // ------------------------------------------------------------------------------ void Matrix_MultAlt(int a1[][3], int a2[][4], int a3[][4]) { int i = 0; int j = 0; for( i = 0; i < 2; i++) for( j = 0; j < 4; j++) a3[i][j] = dot3(a1, a2, i, j); } //--------------------------------------------------------------------------------- // Function: dot3(const int a1[][3], const int a2[][4], int row, int col) // Description: // dot product of a1 row and a2 col // // Programmer: Paul Bladek // // Date: 10/31/2001 // // Version: 1.0 // // Environment: Hardware:IBM Pentium 4 // Software: Microsoft XP with .NET framework for execution; // Compiles under Microsoft Visual C++.Net 2005 // // Calls: None // // Called By: Matrix_MultAlt(int a1[][3], int a2[][4], int a3[][4]) // // Parameters: int a1[][3] -- left matrix // int a2[][3] -- right matrix // int row -- the row number // int col -- the column number // // Returns: the dot product // ------------------------------------------------------------------------------ int dot3(const int a1[][3], const int a2[][4], int row, int col) { int k = 0; int sum = 0; for( k = 0; k < 3; k++) sum += a1[row][k] * a2[k][col]; return sum; } //--------------------------------------------------------------------------------- // Function: PrnNx4(int ar[][4], int n) // Description: // prints out an NX4 matrix // // Programmer: Paul Bladek // // Date: 10/31/2001 // // Version: 1.0 // // Environment: Hardware:IBM Pentium 4 // Software: Microsoft XP with .NET framework for execution; // Compiles under Microsoft Visual C++.Net 2005 // // Called By: main() // // Parameters: int ar[][4] -- matrix to print // int n -- number of elements // ------------------------------------------------------------------------------ void PrnNx4 (int ar[][4], int n) { int i = 0; int j = 0; for(i = 0; i < n; i++) { for( j = 0; j < 4; j++) printf("%4d", ar[i][j]); putchar('\n'); } }


Get size of int using sizeoff?

printf ("sizeof (int) = %d\n", (int)sizeof (int));


C program to find LCMof three integers?

int LCM3 (int a, int b, int c) { return LCM2 (a, LCM2 (b, c)); } int LCM2 (int a, int b) { return a*b/GCD2(a, b); }


What is the use of time.h in c?

The time.h include file is a header file for a library of standard time and date manipulation routines. For example... #include <stdio.h> #include <time.h> int main (int argc, char ** argv) { time_t tt = time(NULL); printf ("The date and time is %s", asctime(localtime(&tt))); return 0; }


It is known that October 2001 starts on monday write a program that would diplay the day of the week of each date starting from October 1?

#include<iostream> #include<string> enum day_enum{monday, tuesday, wednesday, thursday, friday, saturday, sunday}; enum mon_enum{january, february, march, april, may, june, july, august, september, october, november, december}; const std::string day_name[7] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" }; const std::string mon_name[12] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}; int main() { int date=1; // day of month int d=monday; int m=october; int y=2001; while(y<2014) { std::cout<<day_name[d].c_str()<<' '<<date<<' '<<mon_name[m].c_str()<<' '<<y<<std::endl; d=d<sunday?d+1:monday; ++date; if((date==32 ) (date==31 && (m==april m==june m==september m==november)) (m==february && (date==30 date==29 && y%4))) { date=1; m=m<december?m+1:january; if(m==january) ++y; } } }


C plus plus prog a function sum that returns the sum of all Values in the given array int sum int list int arraySize?

int sum(int list[], int arraySize) { int sum=0; for(int i=0; i<arraySize; ++i ) sum+=list[i]; return(sum); }

Trending Questions
What happens when you sit on the toilet for to long? What is this in java? Why does the wax seal keep breaking on your toilet? How do you adjust load sensor valve on navara ute you upgraded the spring so now it does not see a load? What did Frederick W Taylor do? Can I use eurometer calibrated in RMS to measure HWDC in peak? If a 15-ohm resistor is connected in parallel with a 30 ohm-resistor the equivalent resistance is? How do you take apart a click clack plug the plug in the bathroom basin lets water down the sink whilst the plug is pushed down. do they pull apart or unscrew? Making paper from recycled paper instead of from wood? Trying to make some indicators for a bike and am going to use 1.5 volt leds and a 12 volt 11ah battery by putting 8 leds in series was wondering whether resistors are needed not to short the leds? What is the purpose of OS Virtualization? What writing explains a process? What type of mine involves digging tunnels and shaft deep underground? Why 0.01uf capacitor is used in IC 555 timer? What is the thickest wall schedule pipe? What is the part of the cell that contains all the genetic information? What is symbol table in system programming? According to the Gregorian calendar it was Monday on the date 01 01 1900 if any year is input through the keyboard write a c program to find your what is the day on 1st January of this year? What is the difference between radar level measurement and ultrasonic level measurement? Is cystic fibrosis a viral disease?