how to convert c++ to c# sharp code

ayan

New Member
Joined
Apr 9, 2012
Messages
17
hi everyone..i don t know about c# language..so can u plz help me to convert c++ to c# code??

my code is

#include<STDIO.H>
#include<CONIO.H>

main()
{
int m, n, p, c, d, k, sum = 0;
int matrix[10][10], transpose[10][10], product[10][10];

cout<<"Enter the number of rows and columns of matrix\n";
cin>>"%d%d",&m,&n;
cout<<"Enter the elements of matrix\n";

for ( c = 0 ; c < m ; c++ )
for ( d = 0 ; d < n ; d++ )
cin>>"%d",&matrix[c][d];

for( c = 0 ; c < m ; c++ )
{
for( d = 0 ; d < n ; d++ )
{
transpose[d][c] = matrix[c][d];
}
}

for ( c = 0 ; c < m ; c++ )
{
for ( d = 0 ; d < n ; d++ )
{
for ( k = 0 ; k < n ; k++ )
{
sum = sum + matrix[c][k]*transpose[k][d];
}

product[c][d] = sum;
sum = 0;
}
}

for ( c = 0 ; c < m ; c++ )
{
for ( d = 0 ; d < m ; d++ )
{
if ( c == d )
{
if ( product[c][d] != 1 )
break;
}
else
{
if (product[c][d] != 0 )
break;
}
}
if ( d != m )
break;
}
if ( c != m )
cout<<"Matrix is not orthogonal.\n";
else
cout<<"Matrix is orthogonal.\n";

getch();
return 0;
}
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
I don't think cin and cout will work in c# - you probably need to use some other form of input/output.
 
Upvote 0
Where in my post gave you the impression I don't know the answer? There are a ton of resources to do the conversion yourself rather than be spoon feed the answer. Perhaps if you post the snippets you can't quite get, or post the snippets you have successfully converted you'll get more help.
 
Upvote 0
Since this has nothing to do with Office, you might also be better off in a .Net programming forum.
 
Upvote 0
This isn't really either a C++ or C# site so I don't know that there's going to be many here who can actually convert the C++ code to C#. The syntax is mainly compatible but I doubt C# uses cin or cout, and possibly not getch() - so you just have to change the method of input/output.

Let's please keep our posts polite.

ξ
 
Upvote 0

Forum statistics

Threads
1,225,613
Messages
6,186,003
Members
453,334
Latest member
Prakash Jha

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top