Thursday, February 3, 2011

Immigration from C to java[to be finished]
















In CIn java

main(){
/*Code here*/
}

public static void main(String[] args) {
/*Code here*/
}

int num;
printf("Enter a number: ");
scanf("%d",&num);

Scanner scn=new Scanner(System.in);
System.out.print("Enter a number to a variable: ");
int num=scn.nextInt();
//end of solution 1

//Start of solution 2
int num;
Scanner scn=new Scanner(System.in);
System.out.print("Enter a number to a variable: ");
num=scn.nextInt();

int x=0;
printf("x+1= %d\n",x+1);

int x=0;
System.out.println("x+1= "+(x+1));

char word[10];
printf("Enter a word: ");
scanf("%s",word);
String word;
System.out.print("Enter a word: ");
word=scn.next();
//scn is a defined scanner object from the code above

int ArrInt[5];
int[] ArrInt=new int[5]

No comments:

Post a Comment