# Tag Archives: Arrays

Given a rod of length L, the task is to cut the rod in such a way that the total number of segments of length… Read More
Given start, end and an array of N numbers. At each step, start is multiplied with any number in the array and then mod operation… Read More
Given a 2D array of size M x N. Calculate count of positions in 2D array where address as per row-major order equals to address… Read More
Given a string, find the longest substring which is a palindrome. For example, if the given string is “forgeeksskeegfor”, the output should be “geeksskeeg”. Prerequisite… Read More
#include <stdio.h> int main() {     char p;     char buf = {1, 2, 3, 4, 5, 6, 9, 8};     p = (buf + 1);     printf("%d\n", p);… Read More
#include<stdio.h> int main() {     int a = {0};     a = 2;     return 0; } Which of the following will print the value 2 for the… Read More
class Test {     public static void main (String[] args)      {         int arr1[] = {1, 2, 3};         int arr2[] = {1, 2, 3};         if (arr1.equals(arr2))             System.out.println("Same");… Read More
Output of following Java program? import java.util.Arrays; class Test {     public static void main (String[] args)      {         int arr1[] = {1, 2, 3};         int arr2[]… Read More
Output of following Java program? class Test {     public static void main (String[] args)      {         int arr1[] = {1, 2, 3};         int arr2[] = {1,… Read More
public class Main {     public static void main(String args[]) {         int arr[][] = new int[];         arr = new int;         arr = new int;         arr =… Read More
class Test {    public static void main(String args[]) {      int arr[] = new int;        System.out.println(arr);      System.out.println(arr);    } } (A) 0 0 (B) garbage value garbage… Read More
class Test {    public static void main(String args[]) {      int arr;        System.out.println(arr);      System.out.println(arr);    } } (A) 0 0 (B) garbage value garbage value (C) Compiler… Read More
Predict the output? // file name: Main.java public class Main {     public static void main(String args[]) {        int arr[] = {10, 20, 30, 40, 50};… Read More
Which of the following is FALSE about arrays on Java (A) A java array is always an object (B) Length of array can be changed… Read More
#include <stdio.h>    int main() {     int a[][] = {{1,2},{3,4}};     int i, j;     for (i = 0; i < 2; i++)         for (j = 0;… Read More