#TRY_ON_YOUR IDE
C++ code that calculate addition of matrix transpose and multiplication
#include <iostream>
using namespace std;
void multi(int arr[3][4],int arr2[4][3]);
void add(int mat[3][4],int m[3][4]);
void transpose(int arr[3][4]);
int main()
{
int a;
int matrix[3][4],matri[4][3],m2[3][4];
cout<<"command; "<<"\t enter respective numbers\n\t1)transpose\t2)matrixes multipilication with another matrixes\t3) to add matrices with another\n\t4)exit ";cin>>a;
if(a!=4)
{
for(int i=0;i<3;i++)
{
cout<<"\tenter 3x4 matrices row "<<i+1<<endl;
for(int j=0;j<4;j++)
{
cin>>matrix[i][j];
}
}
}
switch(a)
{
case 1:
transpose(matrix);
do
{
main();}
while(a==4);
break;
case 2:
for(int i=0;i<4;i++)
{
cout<<"enter 4x3 matrix's row "<<i+1<<endl;
for(int j=0;j<3;j++)
{
cin>>matri[i][j];
}
}multi(matrix,matri);
do
{
main();}
while(a==4);
break;
case 3:
for(int i=0;i<3;i++)
{
cout<<"enter second 3x4 matrix's row "<<i+1<<endl;
for(int j=0;j<4;j++)
{
cin>>m2[i][j];
}
} add(matrix,m2);
do
{
main();}
while(a==4);
}
return 0;
}
void transpose(int arr[3][4])
{
cout<<endl<<"before transposing"<<endl;
for(int i=0;i<3;i++)
{
for(int j=0;j<4;j++)
{
cout<<"\t"<<arr[i][j];
}
cout<<endl;
}
cout<<"after transposing"<<endl;
for(int i=0;i<=3;i++)
{
for(int j=0;j<3;j++)
{
cout<<"\t"<<arr[j][i];
}
cout<<endl;
}
}
void multi(int arr[3][4],int arr2[4][3])
{
cout<<"\tthe multiplication of two matrices are;\n";
int temp[3][4];
for(int i=0;i<3;i++)
{
for (int j=0;j<3;j++)
{
temp[i][j]=0;
for(int k=0;k<4;k++)
{
temp[i][j]+=arr[i][k]*arr2[k][j];
}
}
}
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
{
cout<<"\t"<<temp[i][j];
}
cout<<endl;
}
}
void add(int mat[3][4],int m[3][4])
{
cout<<"\n\tthe addition of two matrices are: \n";
for(int i=0;i<3;i++)
{
for(int j=0;j<4;j++)
{
cout<<"\t"<<mat[i][j]+m[i][j]<<"\t";
} cout<<"\n";
}
}
https://t.me/PROGRAMINGLANGUAGES1
https://t.me/PROGRAMINGLANGUAGES1
C++ code that calculate addition of matrix transpose and multiplication
#include <iostream>
using namespace std;
void multi(int arr[3][4],int arr2[4][3]);
void add(int mat[3][4],int m[3][4]);
void transpose(int arr[3][4]);
int main()
{
int a;
int matrix[3][4],matri[4][3],m2[3][4];
cout<<"command; "<<"\t enter respective numbers\n\t1)transpose\t2)matrixes multipilication with another matrixes\t3) to add matrices with another\n\t4)exit ";cin>>a;
if(a!=4)
{
for(int i=0;i<3;i++)
{
cout<<"\tenter 3x4 matrices row "<<i+1<<endl;
for(int j=0;j<4;j++)
{
cin>>matrix[i][j];
}
}
}
switch(a)
{
case 1:
transpose(matrix);
do
{
main();}
while(a==4);
break;
case 2:
for(int i=0;i<4;i++)
{
cout<<"enter 4x3 matrix's row "<<i+1<<endl;
for(int j=0;j<3;j++)
{
cin>>matri[i][j];
}
}multi(matrix,matri);
do
{
main();}
while(a==4);
break;
case 3:
for(int i=0;i<3;i++)
{
cout<<"enter second 3x4 matrix's row "<<i+1<<endl;
for(int j=0;j<4;j++)
{
cin>>m2[i][j];
}
} add(matrix,m2);
do
{
main();}
while(a==4);
}
return 0;
}
void transpose(int arr[3][4])
{
cout<<endl<<"before transposing"<<endl;
for(int i=0;i<3;i++)
{
for(int j=0;j<4;j++)
{
cout<<"\t"<<arr[i][j];
}
cout<<endl;
}
cout<<"after transposing"<<endl;
for(int i=0;i<=3;i++)
{
for(int j=0;j<3;j++)
{
cout<<"\t"<<arr[j][i];
}
cout<<endl;
}
}
void multi(int arr[3][4],int arr2[4][3])
{
cout<<"\tthe multiplication of two matrices are;\n";
int temp[3][4];
for(int i=0;i<3;i++)
{
for (int j=0;j<3;j++)
{
temp[i][j]=0;
for(int k=0;k<4;k++)
{
temp[i][j]+=arr[i][k]*arr2[k][j];
}
}
}
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
{
cout<<"\t"<<temp[i][j];
}
cout<<endl;
}
}
void add(int mat[3][4],int m[3][4])
{
cout<<"\n\tthe addition of two matrices are: \n";
for(int i=0;i<3;i++)
{
for(int j=0;j<4;j++)
{
cout<<"\t"<<mat[i][j]+m[i][j]<<"\t";
} cout<<"\n";
}
}
https://t.me/PROGRAMINGLANGUAGES1
https://t.me/PROGRAMINGLANGUAGES1
#Single_Dimensional_Array
The single-dimensional array may be defined as the type of array capable of holding the values of the same data centre in the form of a list
EXAMPLE; SEE BELOW
#include <iostream>
#include <conio.h>
using namespace std;
void main()
{
int val_array[3];
int int_val=1,counter;
cout<<"Please enter three numbers that you want to multiply"<<endl;
for(counter=0;counter<3;counter++)
{
cin>>val_array[counter];
int_val = int_val*val_array[counter];
}
cout<<"The multiplication of these three numbers is = "<<int_val;
getch();
}
#Multidimensional_Array
The multidimensional array may be defined as the array that holds the values in the way a matrix does. The two-dimensional array is used very often, and with the increase in the size of dimension, the array gets complicated.
EXAMPLE; SEE BELOW
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
int val_array[5][5];
int count_rows,count_cols,counter1,counter2;
cout<<"Please enter the size of the rows and columns that you wnant to input: ";
cin>>count_rows>>count_cols;
cout<<"PLease enter the values for matrics in row wise manner"<<endl;
for(counter1=0;counter1<count_rows;counter1++)
for(counter2=0;counter2<count_cols;counter2++)
cin>>val_array[counter1][counter2];
cout<<"The matrix will be as follows"<<endl;
for(counter1=0;counter1<count_rows;counter1++)
{
for(counter2=0;counter2<count_cols;counter2++)
cout<<val_array[counter1][counter2]<<" ";
cout<<endl;
}
getch();
return 0;
}
https://t.me/PROGRAMINGLANGUAGES1
The single-dimensional array may be defined as the type of array capable of holding the values of the same data centre in the form of a list
EXAMPLE; SEE BELOW
#include <iostream>
#include <conio.h>
using namespace std;
void main()
{
int val_array[3];
int int_val=1,counter;
cout<<"Please enter three numbers that you want to multiply"<<endl;
for(counter=0;counter<3;counter++)
{
cin>>val_array[counter];
int_val = int_val*val_array[counter];
}
cout<<"The multiplication of these three numbers is = "<<int_val;
getch();
}
#Multidimensional_Array
The multidimensional array may be defined as the array that holds the values in the way a matrix does. The two-dimensional array is used very often, and with the increase in the size of dimension, the array gets complicated.
EXAMPLE; SEE BELOW
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
int val_array[5][5];
int count_rows,count_cols,counter1,counter2;
cout<<"Please enter the size of the rows and columns that you wnant to input: ";
cin>>count_rows>>count_cols;
cout<<"PLease enter the values for matrics in row wise manner"<<endl;
for(counter1=0;counter1<count_rows;counter1++)
for(counter2=0;counter2<count_cols;counter2++)
cin>>val_array[counter1][counter2];
cout<<"The matrix will be as follows"<<endl;
for(counter1=0;counter1<count_rows;counter1++)
{
for(counter2=0;counter2<count_cols;counter2++)
cout<<val_array[counter1][counter2]<<" ";
cout<<endl;
}
getch();
return 0;
}
https://t.me/PROGRAMINGLANGUAGES1
π1π1
HAPPY ETHIOPIAN CHRISTMASS FOR ALLππ²π²ππ
https://t.me/+txk6Ik_UwGc4ZGM0
https://t.me/+txk6Ik_UwGc4ZGM0
https://t.me/+txk6Ik_UwGc4ZGM0
https://t.me/+txk6Ik_UwGc4ZGM0
π1π₯1
π6β€1π1
EvoNext
#TRY_ON_YOUR IDE C++ code that calculate addition of matrix transpose and multiplication #include <iostream> using namespace std; void multi(int arr[3][4],int arr2[4][3]); void add(int mat[3][4],int m[3][4]); void transpose(int arr[3][4]); int main() {β¦
continued....
In C++ an array variable is actually a
pointer variable that points to the first indexed variable of the array. Given the
following two variable declarations, p and a are the same kind of variable:
int a[10];
#def int* IntPtr;
IntPtr p;
* The fact that a and p are the same kind of variable. Since a is a pointer that points to a variable of type int (namely the
variable a[0]), the value of a can be assigned to the pointer variable p as
follows:
p = a;
After this assignment, p points to the same memory location that a points to. So, p[0], p[1], β¦ p[9] refer to the indexed variables a[0], a[1], β¦ a[9]. The square bracket notation you have been using for arrays applies to pointer variables as long as the pointer variable points to an array in memory
Β» You cannot change the pointer value in an array variable, such as a.
1 //Program to demonstrate that an array variable is a kind of pointer variable.
2 #include <iostream>
3 using namespace std;
4
5 #def int* IntPtr;
6
7 int main( )
8 {
9 IntPtr p;
10 int a[10];
11 int index;
12
13 for (index = 0; index < 10; index++)
14 a[index] = index;
15
16 p = a;
17
18 for (index = 0; index < 10; index++)
19 cout << p[index] << " ";
20 cout << endl;
21
22 for (index = 0; index < 10; index++)
23 p[index] = p[index] + 1;
24
25 for (index = 0; index < 10; index++)
26 cout << a[index] << " ";
27 cout << endl;
28
29 return 0;
30 }
#what_is_the_output_of_these_program?
https://t.me/+txk6Ik_UwGc4ZGM0
https://t.me/+txk6Ik_UwGc4ZGM0
In C++ an array variable is actually a
pointer variable that points to the first indexed variable of the array. Given the
following two variable declarations, p and a are the same kind of variable:
int a[10];
#def int* IntPtr;
IntPtr p;
* The fact that a and p are the same kind of variable. Since a is a pointer that points to a variable of type int (namely the
variable a[0]), the value of a can be assigned to the pointer variable p as
follows:
p = a;
After this assignment, p points to the same memory location that a points to. So, p[0], p[1], β¦ p[9] refer to the indexed variables a[0], a[1], β¦ a[9]. The square bracket notation you have been using for arrays applies to pointer variables as long as the pointer variable points to an array in memory
Β» You cannot change the pointer value in an array variable, such as a.
1 //Program to demonstrate that an array variable is a kind of pointer variable.
2 #include <iostream>
3 using namespace std;
4
5 #def int* IntPtr;
6
7 int main( )
8 {
9 IntPtr p;
10 int a[10];
11 int index;
12
13 for (index = 0; index < 10; index++)
14 a[index] = index;
15
16 p = a;
17
18 for (index = 0; index < 10; index++)
19 cout << p[index] << " ";
20 cout << endl;
21
22 for (index = 0; index < 10; index++)
23 p[index] = p[index] + 1;
24
25 for (index = 0; index < 10; index++)
26 cout << a[index] << " ";
27 cout << endl;
28
29 return 0;
30 }
#what_is_the_output_of_these_program?
https://t.me/+txk6Ik_UwGc4ZGM0
https://t.me/+txk6Ik_UwGc4ZGM0
Telegram
AlgoMasters : LearnToCode
'You can't be whatever you want until you start doing what you want.'
- Main contents of this channel ><
#website_development and #Mobile_app tips
#Machine_learning tip
#programmers_mindset
#technical_blogs
- Main contents of this channel ><
#website_development and #Mobile_app tips
#Machine_learning tip
#programmers_mindset
#technical_blogs
β€3π1
//a program that works average of n students' maths score
#include <iostream>
using namespace std;
int main(){
int sum,n,i,sub_total;
sum =0;
n = 1;
sub_total = 0;
cout <<"enter number of students: ";
cin >>n;
int array[sub_total];
for(i=1;i>=n;i++)
{ if(array[i]>=0){
cout <<"score of e student "<<i <<": " << endl;
cin >> array[i];
sum+= array[i];
}
}
cout <<"the sum is: " << sum << endl;
float average;
average = sum/n;
cout <<"the average is: " << average;
}
#include <iostream>
using namespace std;
int main(){
int sum,n,i,sub_total;
sum =0;
n = 1;
sub_total = 0;
cout <<"enter number of students: ";
cin >>n;
int array[sub_total];
for(i=1;i>=n;i++)
{ if(array[i]>=0){
cout <<"score of e student "<<i <<": " << endl;
cin >> array[i];
sum+= array[i];
}
}
cout <<"the sum is: " << sum << endl;
float average;
average = sum/n;
cout <<"the average is: " << average;
}
π₯1
//charging of parked car
#include <iostream>
using namespace std;
int main()
{
char type;
int charge, hours;
charge = hours* type;
cout <<"enter your vehicle 'c' 'b' 't': ";
cin >> type;
switch(char){
case 'c':
cout << "enter the parked hours: ";
cin >> hours;
charge = 2 * hours;
cout <<"your charged amount is $:\n" << charge;
break;
case 'b':
cout <<"enter hours parked: ";
cin << hours;
charge = 3 * hours;
cout <<" your charged amount is $:\n" << charge;
break:
case 't':
cout <<"enter the parked hours: ";
cin >> hours;
charge = 5 * hours;
cout <<"your charged amount is $:\n" << charge;
break;
}
}
#include <iostream>
using namespace std;
int main()
{
char type;
int charge, hours;
charge = hours* type;
cout <<"enter your vehicle 'c' 'b' 't': ";
cin >> type;
switch(char){
case 'c':
cout << "enter the parked hours: ";
cin >> hours;
charge = 2 * hours;
cout <<"your charged amount is $:\n" << charge;
break;
case 'b':
cout <<"enter hours parked: ";
cin << hours;
charge = 3 * hours;
cout <<" your charged amount is $:\n" << charge;
break:
case 't':
cout <<"enter the parked hours: ";
cin >> hours;
charge = 5 * hours;
cout <<"your charged amount is $:\n" << charge;
break;
}
}
π2
#include <iostream>
using namespace std;
int main()
{
char chr;
cout <<" Wel come to 'LEARN TO CODE' telegram channel.\n";
chr = 'j';
cout <<"Enter 'j' to join our channel." << endl;
cin >> chr;
cout <<"https://t.me/PROGRAMINGLANGUAGES1";
return 0;
}
thanks ππΏhttps://t.me/PROGRAMINGLANGUAGES1
using namespace std;
int main()
{
char chr;
cout <<" Wel come to 'LEARN TO CODE' telegram channel.\n";
chr = 'j';
cout <<"Enter 'j' to join our channel." << endl;
cin >> chr;
cout <<"https://t.me/PROGRAMINGLANGUAGES1";
return 0;
}
thanks ππΏhttps://t.me/PROGRAMINGLANGUAGES1
β€2
reference books for c++
1ππΏhttps://t.me/PROGRAMINGLANGUAGES1/34
2ππΏhttps://t.me/PROGRAMINGLANGUAGES1/30
3ππΏhttps://t.me/PROGRAMINGLANGUAGES1/85
4ππΏhttps://t.me/PROGRAMINGLANGUAGES1/88
1ππΏhttps://t.me/PROGRAMINGLANGUAGES1/34
2ππΏhttps://t.me/PROGRAMINGLANGUAGES1/30
3ππΏhttps://t.me/PROGRAMINGLANGUAGES1/85
4ππΏhttps://t.me/PROGRAMINGLANGUAGES1/88
Telegram
Learn To Code
nice material to explore your coding skill.π€, CODING is like building library that has many shelves to store book Β« "/*books represents data in coding*/; so you can sore books orderly to use it in case needed. By the way, coding needs not your past experienceβ¦
π1
DS286.AUG2016.Lab2_.cpp_tutorial.pdf
1.8 MB
now π€« c++ is no more difficultπππΏππΏππΏ
β€2π1
//C++ program for converting degree Celsius into Fahrenheit and vice versa
#include<iostream>
using namespace std;
int main()
{
float fahr, cel;
char option;
cout << "Choose from following option:" << endl;
cout << "1. Celsius to Fahrenheit." << endl;
cout << "2. Fahrenheit to Celsius." << endl;
cin >> option;
//option for converting celsius into fahernheit
if (option == '1')
{
cout << "Enter the temperature in Celsius: ";
cin >> cel;
fahr = (1.8 * cel) + 32.0; //temperature conversion formula
cout << "\nTemperature in degree Fahrenheit: " << fahr << " F" << endl;
}
//option for converting Fahrenheit into Celsius
else if (option == '2')
{
cout << "Enter the temperature in Fahrenheit: ";
cin >> fahr;
cel = (fahr - 32) / 1.8; //temperature conversion formula
cout << "\nTemperature in degree Celsius: " << cel << " C" << endl;
}
else
cout << "Error Wrong Input." << endl;
return 0;
https://t.me/PROGRAMINGLANGUAGES1
#include<iostream>
using namespace std;
int main()
{
float fahr, cel;
char option;
cout << "Choose from following option:" << endl;
cout << "1. Celsius to Fahrenheit." << endl;
cout << "2. Fahrenheit to Celsius." << endl;
cin >> option;
//option for converting celsius into fahernheit
if (option == '1')
{
cout << "Enter the temperature in Celsius: ";
cin >> cel;
fahr = (1.8 * cel) + 32.0; //temperature conversion formula
cout << "\nTemperature in degree Fahrenheit: " << fahr << " F" << endl;
}
//option for converting Fahrenheit into Celsius
else if (option == '2')
{
cout << "Enter the temperature in Fahrenheit: ";
cin >> fahr;
cel = (fahr - 32) / 1.8; //temperature conversion formula
cout << "\nTemperature in degree Celsius: " << cel << " C" << endl;
}
else
cout << "Error Wrong Input." << endl;
return 0;
https://t.me/PROGRAMINGLANGUAGES1
π1π₯1
ppt from chapter #3_#5 for c++ππ»π» https://t.me/PROGRAMINGLANGUAGES1
π1