Question
can you change this java program to c program? import java.io.*; import java.net.*; public class TCPServerMatrix { public static void main (String argv[]) throws Exception
can you change this java program to c program?
import java.io.*; import java.net.*;
public class TCPServerMatrix { public static void main (String argv[]) throws Exception {
String clientInput1; String clientInput2; String clientInput3; String clientInput4; String clientInput;
String serverResult; ServerSocket welcomeSocket = new ServerSocket(6769); while(true) { Socket connectionSocket = welcomeSocket.accept(); BufferedReader inFromClient = new BufferedReader (new InputStreamReader(connectionSocket.getInputStream())); DataOutputStream outToClient = new DataOutputStream(connectionSocket.getOutputStream());
clientInput1 = inFromClient.readLine(); int rowsMatrixA = Integer.parseInt(clientInput1);
clientInput2 = inFromClient.readLine(); int colsMatrixA = Integer.parseInt(clientInput2);
clientInput3 = inFromClient.readLine(); int rowsMatrixB = Integer.parseInt(clientInput3);
clientInput4 = inFromClient.readLine(); int colsMatrixB = Integer.parseInt(clientInput4);
if (colsMatrixA == rowsMatrixB) {
// To Create matrices double[][] matrixA = new double[rowsMatrixA][colsMatrixA]; double[][] matrixB = new double[rowsMatrixB][colsMatrixB]; double[][] matrixC = new double[rowsMatrixA][colsMatrixB];
// Get input from client To fill Matrices // MatrixA for (int rowA=0;rowA // MatrixB for (int rowB=0;rowB // Multiplication C =A.B for(int rowA=0; rowA // To output matrixC (C = A.B) System.out.println("on Servers Screen :" + " "); System.out.println("Matrix C = AxB" + " "); for(int rowC=0; rowC } System.out.println(" " ); serverResult = (" " + " "); outToClient.writeBytes(serverResult); } //System.exit(0); } //close if else { System.out.println("on Servers Screen : Wrong Matrix"); serverResult = ("Wrong Matrix" + " "); outToClient.writeBytes(serverResult); } } } } import java.io.*; import java.net.*; public class TCPClientMatrix { public static void main (String argv[]) throws Exception { String input1; String input2; String input3; String input4; String result; String server; BufferedReader inFromUser = new BufferedReader (new InputStreamReader (System.in)); System.out.println("Enter IP Server : "); server = inFromUser.readLine(); Socket clientSocket = new Socket(server,6769); DataOutputStream outToServer = new DataOutputStream(clientSocket.getOutputStream()); BufferedReader inFromServer = new BufferedReader(new InputStreamReader(clientSocket.getInputStream())); System.out.println( " Input Rows Matrix A : " ); input1 = inFromUser.readLine(); //get integer rowsMatrixA outToServer.writeBytes(input1 + " "); int rowsMatrixA = Integer.parseInt( input1 ); System.out.println( "Input Cols Matrix A : " ); input2 = inFromUser.readLine(); //get integer colsMatrixA outToServer.writeBytes(input2 + " "); int colsMatrixA = Integer.parseInt( input2 ); System.out.println( " Input Rows Matrix B : " ); input3 = inFromUser.readLine(); //get integer rowsMatrixB outToServer.writeBytes(input3 + " "); int rowsMatrixB = Integer.parseInt( input3 ); System.out.println( " Input Cols Matrix B : " ); input4 = inFromUser.readLine(); //get integer colsMatrixB outToServer.writeBytes(input4 + " "); int colsMatrixB = Integer.parseInt( input4 ); if (colsMatrixA == rowsMatrixB) { // To fill Matrices // MatrixA for (int rowA=0;rowA // MatrixB for (int rowB=0;rowB // To output matrixC (C = A.B) System.out.println("on Clients Screen :"); System.out.println("Matrix C = AxB" + " "); for(int rowC=0; rowC } result = inFromServer.readLine(); System.out.println(result); } clientSocket.close(); } //close if else { System.out.println("on Clients Screen :"); result = inFromServer.readLine(); System.out.println(result); } } } Can u change this java to c programmer?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started