Answer:
import java.util.Arrays;
public class swap{
public static void main(String []args){
int [] arr = {2,4};
swapValues(arr);
}
public static void swapValues(int[] values){
int temp;
System.out.println(Arrays.toString(values));
temp=values[0];
values[0]=values[1];
values[1] =temp;
System.out.println(Arrays.toString(values));
}
}
Explanation:
In the program above, we created the method swapValues that receives an array of integers as parameters. in the method definition, we created a temp variable that is used to swapp the element at index 0 and index 1. Java's Arrays.to string method is used to print the array before and after the swap.
Answer:
I'm better at C++, but I'm pretty sure this it:
/*C - Program to compare two strings
character by character.*/
#include<stdio.h>
int main(){
char str1[]="Hello";
char str2[]="Hello";
int len1=0, len2=0;
int i,isSame=0;
//calculate lengths
i=0;
while(str1[i++]!='\0') len1++;
i=0;
while(str2[i++]!='\0') len2++;
if(len1!=len2){
printf("Strings are not same, lengths are different\n");
return -1;
}
isSame=1;
for(i=0;i<len1;i++){
if(str1[i]!=str2[i]){
isSame=0;
break;
}
}
if(isSame)
printf("Strings are same.\n");
else
printf("Strings are not same.\n");
return 0;
}
E-mail stands for Electronic mail. It is a method of exchanging messages ("mail") between people in a telecommunication network with the usage of electronic devices. There is a sender and a receiver for any given message, and they switch positions in turn.
The statement that E-mail is an temporary message medium is false. E-mail can be kept forever and are not temporary.
I think data mining and software design.