example of programe with
//continue//
#include <iostream>
using namespace std;
int main() {
for (int i = 0; i < 10; i++) {
if (i == 4) {
continue;
}
cout << i << "\n";
}
return 0;
}
/* the output is
1
2
3
4
5
6
7
8
9
10
*/
https://t.me/PROGRAMINGLANGUAGES1
//continue//
#include <iostream>
using namespace std;
int main() {
for (int i = 0; i < 10; i++) {
if (i == 4) {
continue;
}
cout << i << "\n";
}
return 0;
}
/* the output is
1
2
3
4
5
6
7
8
9
10
*/
https://t.me/PROGRAMINGLANGUAGES1
sample code with
//break// statement
#include <iostream>
using namespace std;
int main() {
for (int i = 0; i < 10; i++) {
if (i == 4) {
break;
}
cout << i << "\n";
}
return 0;
}
/*the output is
1
2
3
*/
https://t.me/PROGRAMINGLANGUAGES1
//break// statement
#include <iostream>
using namespace std;
int main() {
for (int i = 0; i < 10; i++) {
if (i == 4) {
break;
}
cout << i << "\n";
}
return 0;
}
/*the output is
1
2
3
*/
https://t.me/PROGRAMINGLANGUAGES1
#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