#include
int main()
{
int m, n, p, q, c, d, k, sum = 0;
int first[10][10], second[10][10], multiply[10][10];
printf("Enter the first matrix number of rows and columns \n");
scanf("%d%d", &m, &n);
printf("Enter elements\n");
for (c = 0; c < m; c++)
for (d = 0; d < n; d++)
scanf("%d", &first[c][d]);
printf("Enter the second matrix number of rows and columns\n");
scanf("%d%d", &p, &q);
if (n != p) printf("Not valid Matrix \n");
else {
printf("Enter elements \n");
for (c = 0; c < p; c++)
for (d = 0; d < q; d++)
scanf("%d", &second[c][d]);
for (c = 0; c < m; c++)
{
for (d = 0; d < q; d++)
{
for (k = 0; k < p; k++)
{
sum = sum + first[c][k]*second[k][d];
}
multiply[c][d] = sum; sum = 0;
}
}
printf("Result Is :-\n");
for (c = 0; c < m; c++)
{
for (d = 0; d < q; d++)
printf("%d\t", multiply[c][d]);
printf("\n");
}
}
return 0;}
Proggramming Tutorials & Web Development Technologies - Tutorials for PHP,Laravel,Codeigniter,Yii,Bootstrap,Ajax,JQuery
Monday, 30 March 2015
Wednesday, 11 February 2015
Palindrome In c using strcpy
#include
#include
void main()
{
char a[100], b[100];
d:
printf("Enter the string to check if it is a palindrome\n");
gets(a);
strcpy(b,a);
strrev(b);
if( strcmp(a,b) == 0 )
{
printf("Entered string is a palindrome.\n");
}
else
{
printf("Entered string is not a palindrome.\n");
}
}
#include
void main()
{
char a[100], b[100];
d:
printf("Enter the string to check if it is a palindrome\n");
gets(a);
strcpy(b,a);
strrev(b);
if( strcmp(a,b) == 0 )
{
printf("Entered string is a palindrome.\n");
}
else
{
printf("Entered string is not a palindrome.\n");
}
}
C Program to Access Elements of an Array Using Pointer in Ascending Order
#include
#include
void main()
{
int x[size], *p, *q, *r, temp,size;
clrscr();
printf("Number of elements to be entered:");
scanf("%d",&size);
p=x;
for(q=p; q
#include
void main()
{
int x[size], *p, *q, *r, temp,size;
clrscr();
printf("Number of elements to be entered:");
scanf("%d",&size);
p=x;
for(q=p; q
{
printf("\nEnter value:");
scanf("%d", q);
}
printf("\n\nkush\n");
printf("\n\nPrinting the elements in asceding order.......\n");
for(q=p; q
printf("\nEnter value:");
scanf("%d", q);
}
printf("\n\nkush\n");
printf("\n\nPrinting the elements in asceding order.......\n");
for(q=p; q
{
for(r=q+1; r
for(r=q+1; r
{
if(*q>*r)
{
temp=*q;
*q=*r;
*r=temp;
}
}
}
for(q=p; q
if(*q>*r)
{
temp=*q;
*q=*r;
*r=temp;
}
}
}
for(q=p; q
{
printf("%d ", *q);
}
getch();
}
printf("%d ", *q);
}
getch();
}
Access Elements of an Array Using Pointer Using C
#include
#include
int main()
{
int i, n;
int *a;
printf("Number of elements to be entered:");
scanf("%d",&n);
a = (int*)calloc(n, sizeof(int));
printf("Enter %d numbers:\n",n);
for( i=0 ; i < n ; i++ )
{
scanf("%d",&a[i]);
}
printf("The numbers entered are: ");
for( i=0 ; i < n ; i++ )
{
printf("%d ",a[i]);
}
return(0);
}
#include
int main()
{
int i, n;
int *a;
printf("Number of elements to be entered:");
scanf("%d",&n);
a = (int*)calloc(n, sizeof(int));
printf("Enter %d numbers:\n",n);
for( i=0 ; i < n ; i++ )
{
scanf("%d",&a[i]);
}
printf("The numbers entered are: ");
for( i=0 ; i < n ; i++ )
{
printf("%d ",a[i]);
}
return(0);
}
Saturday, 31 January 2015
JAVA program to find out ECHO Server using socket.
// File name = ConServer.java
import java.net.*;
import java.io.*;
public class ConServer
{
public static void main(String[] dha)
{
ServerSocket s=null;
try
{
s=new ServerSocket(12345);
}
catch(IOException e)
{
e.printStackTrace();
}
while(true)
{
try
{
System.out.println("Wllcom To SERVER .......");
Socket s1=s.accept();
System.out.println("Enter Your Message For Client ...............");
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
OutputStream out=s1.getOutputStream();
BufferedWriter bw=new BufferedWriter(new OutputStreamWriter(out));
String str;
System.out.println("Enter exit++ to stop");
str=br.readLine();
while(str!=null)
{
if(str.equals("exit++"))
break;
bw.write(str);
bw.newLine();
System.out.println("Read: "+str);
str=br.readLine();
}
br.close();
bw.close();
s1.close();
}
catch(IOException e)
{
e.printStackTrace();
}
}
}
}
***********************************************************************
// File Name = ConClient .java
import java.io.*;
import java.net.*;
public class ConClient
{
public static void main(String[] dha)
{
try
{
Socket s1=new Socket("127.0.0.1",12345);
System.out.println("Wllcom To Client .......");
System.out.println(" Message Is .......");
InputStream is=s1.getInputStream();
BufferedReader br=new BufferedReader(new InputStreamReader(is));
int i;
while((i=br.read())!=-1)
{
System.out.print((char)i);
}
br.close();
s1.close();
}//try over
catch(IOException e)
{ e.printStackTrace();
System.out.println("Conncection Problem");
}
}// main over
}// class over
*******************************************************************************
***************************************************************************
***************************************************************************
Step 1 > javac ConServer.java
//compile file
Step 2 > start
//open new terminal
Step 3 > java ConServer
Step 4 >ConClient .java
//compile file In new terminal
Step 5 > java ConClient
import java.net.*;
import java.io.*;
public class ConServer
{
public static void main(String[] dha)
{
ServerSocket s=null;
try
{
s=new ServerSocket(12345);
}
catch(IOException e)
{
e.printStackTrace();
}
while(true)
{
try
{
System.out.println("Wllcom To SERVER .......");
Socket s1=s.accept();
System.out.println("Enter Your Message For Client ...............");
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
OutputStream out=s1.getOutputStream();
BufferedWriter bw=new BufferedWriter(new OutputStreamWriter(out));
String str;
System.out.println("Enter exit++ to stop");
str=br.readLine();
while(str!=null)
{
if(str.equals("exit++"))
break;
bw.write(str);
bw.newLine();
System.out.println("Read: "+str);
str=br.readLine();
}
br.close();
bw.close();
s1.close();
}
catch(IOException e)
{
e.printStackTrace();
}
}
}
}
***********************************************************************
// File Name = ConClient .java
import java.io.*;
import java.net.*;
public class ConClient
{
public static void main(String[] dha)
{
try
{
Socket s1=new Socket("127.0.0.1",12345);
System.out.println("Wllcom To Client .......");
System.out.println(" Message Is .......");
InputStream is=s1.getInputStream();
BufferedReader br=new BufferedReader(new InputStreamReader(is));
int i;
while((i=br.read())!=-1)
{
System.out.print((char)i);
}
br.close();
s1.close();
}//try over
catch(IOException e)
{ e.printStackTrace();
System.out.println("Conncection Problem");
}
}// main over
}// class over
*******************************************************************************
******************** OUTPUT ********************
ConClient .java
***************************************************************************
How To Run Server-Client Program
***************************************************************************
Step 1 > javac ConServer.java
//compile file
Step 2 > start
//open new terminal
Step 3 > java ConServer
Step 4 >ConClient .java
//compile file In new terminal
Step 5 > java ConClient
Monday, 19 January 2015
Write JAVA Program to print string length using extended thread.
File Name = exteded_thread .java
import java.util.Scanner;
class demo1 extends Thread
{
Thread t;
String threadName,s;
demo1(String name)
{
Scanner in = new Scanner(System.in);
threadName = name;
System.out.println("Creating Thread......");
try
{
Thread.sleep(1000);
}
catch(InterruptedException e)
{
System.out.println("Erroe is --> "+e);
}
}
public void run()
{
System.out.println("Running Thread......");
try
{ Thread.sleep(1000);
System.out.println("length Of String Is -->"+s.length());
Thread.sleep(1000);
}
catch(InterruptedException e)
{
System.out.println("Erroe is --> "+e);
}
System.out.println("Thread Is exiting.");
}
public void start ()
{
if (t == null)
{
t = new Thread (this, threadName);
t.start ();
}
}
}
public class exteded_thread
{
public static void main(String args[])
{
String s="Wellcome";
demo1 T1 = new demo1(s);
T1.start();
}
}
import java.util.Scanner;
class demo1 extends Thread
{
Thread t;
String threadName,s;
demo1(String name)
{
Scanner in = new Scanner(System.in);
threadName = name;
System.out.println("Creating Thread......");
try
{
Thread.sleep(1000);
}
catch(InterruptedException e)
{
System.out.println("Erroe is --> "+e);
}
}
public void run()
{
System.out.println("Running Thread......");
try
{ Thread.sleep(1000);
System.out.println("length Of String Is -->"+s.length());
Thread.sleep(1000);
}
catch(InterruptedException e)
{
System.out.println("Erroe is --> "+e);
}
System.out.println("Thread Is exiting.");
}
public void start ()
{
if (t == null)
{
t = new Thread (this, threadName);
t.start ();
}
}
}
public class exteded_thread
{
public static void main(String args[])
{
String s="Wellcome";
demo1 T1 = new demo1(s);
T1.start();
}
}
Subscribe to:
Posts (Atom)