Thursday, 19 September 2013

Simple C Program In Ubantu

Step 1:
Open Terminal
Write Command "gedit" to open editor

Step 2:
Write C Program In editor
for eg:

#include<stdio.h>

void main()
{
    printf("Hello Bharat");
   
}


Save the Program "bharat.c"

Step 3:
Open The terminal
CD command for change directory
 cd Desktop
(For example you save the program in Desktop then use cd Desktop)

Step 4
First compile the program using command
gcc bharat.c -o  bharat

if you use only gcc bharat.c then create a.out file
-o file name is the output file

Step 5:
Run The Program using command
"./outputfile name"

./bharat

Step 6:
Output show in terminal
Hello Bharat

Monday, 16 September 2013

Separation of Number And Char from String.

Separation of Number And Char from String.

Program:


public class DemoProgram {
public static void main(String[] args) {
String s = "(123)-456SS-7891ABCC";
String s1 = "(123)-456SS-7891ABCC";
   s = s.replaceAll("[^0-9]", "");
   s1 = s1.replaceAll("[^a-z|A-Z]", "");
   System.out.println("Number=="+s);
   System.out.println("Char=="+s1);

}

OutPut:
Number==1234567891
Char==SSABCC