0% found this document useful (0 votes)
14 views4 pages

Array@19 10 24

Programs related to array programming which is very useful for class 10 students

Uploaded by

jayraj9300
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views4 pages

Array@19 10 24

Programs related to array programming which is very useful for class 10 students

Uploaded by

jayraj9300
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Array Date: 19-10-2024

1. Basic Input and Output in Array


import java.util.Scanner;

class ArrayOperations

void main()

Scanner sc=new Scanner(System.in);

int roll[]= new int[10];

System.out.println("Enter the roll of 10 Students:-");

for(int i=0;i<10;i++)

roll[i]=sc.nextInt();

System.out.println("Rolls of 10 Students are:-");

for(int i=0;i<10;i++)

System.out.print(roll[i]+" ");

}
2. /*

* WAP in java to take 10 numbers as input in an SDA and Print the


sum of odd and even numbers.

*/
import java.util.Scanner;

class OddEvenSum

void main()

Scanner sc= new Scanner (System.in);

int arr[]=new int[10],e=0,o=0;

System.out.println("Enter 10 Numbers:");

for(int i=0;i<10;i++)

arr[i]=sc.nextInt();

for(int i=0;i<10;i++)

if(arr[i]%2==0)

e=e+arr[i];

else

o=o+arr[i];

}
System.out.println("Sum of even Terms="+e);

System.out.println("Sum of Odd Terms="+o);

3. A Java program to search an element in an array.


import java.util.Scanner;

class SearchArray

void main()

Scanner sc= new Scanner(System.in);

int a[]=new int[10];

System.out.print("Enter 10 elements one by one");

for(int i=0;i<10;i++)

a[i]=sc.nextInt();

System.out.print("Enter the number which you want to search:");

int x=sc.nextInt();

int c=0;

for(int i=0;i<10;i++)

{
if(a[i]==x)

System.out.println("Found");

c++;

break;

if(c==0)

System.out.println("Number Not Found!");

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy