computer project
computer project
// Initialize variables
int count = 0;
String positions = "";
// Print results
System.out.println("Original String: " + str);
System.out.println("Swapped String: " + swappedStr);
// c lose Scanner
scanner.close();
}
}
Q 4) A single dimentional array has ‘n’ number of elements. Now enter
a number and check for the presence of the number in the array, if
the number is present, then delete the number, and print the rest of
the numbers.
// Validate position
if (position < 1 || position > n + 1) {
System.out.println("Invalid position.");
return;
}
return newArray;
}
}
Q6) Write a program to input the rows and columns of an array and fill
up the square matrix in the following format :- ‘?’,’#’,’@’.