# Missing Number in java with example

Missing Number in Java
The set of number is number will be given so we have to find the number which is missing inside the the set
number={1,2,3,4,5,7,8,9}
then we have to find the missing number from the given set
Output: 6

### source code:

import java.io.*;
import java.util.*;
class Missno
{
public static void main(String arg[ ])
{
Scanner obj=new Scanner(System.in);
System.out.println(“enter n value”);
int n=obj.nextInt();
int sum=0;
int c,i,a[]=new int[n];;
System.out.println(“enter values”);
for(i=0;i<n-1;i++)
{
a[i]=obj.nextInt();
sum=sum+a[i];
}
c=(n*(n+1)/2)-sum;
System.out.println(“missing no is”+c);
}
}

sites: https://www.myprogrammingschool.com/

### Have any Question or Comment?

#### 10 comments on “Missing Number in java with example”

[…] Missing Number in java with example […]

[…] { System.out.println(j); j++; } int k=20; do { System.out.println(k); k++; } while(k!=60); } } Missing Number in java with example Write a Java program that reads a file and displays the file on the screen with a line number […]

[…] { public static void main(String…aa) { System.out.println(“Hello World”); } } Missing Number in java with example Write a Java program that reads a file and displays the file on the screen with a line number […]

[…] num1 = num2; num2 = sumOfPrevTwo; i ++; } } } Output: Fibonacci series of 7 numbers: 0 1 1 2 3 5 8 Missing Number in java with example Write a Java program that reads a file and displays the file on the screen with a line number […]

[…] are”+a[i]); } if((a[i]%2)==1) {  System.out.println(“odd no are”+a[i]); } } } } Missing Number in java with example Write a Java program that reads a file and displays the file on the screen with a line number […]

[…] { if((a[i]%2)==0) { System.out.println(“even no are”+a[i]); } } } } Missing Number in java with example Write a Java program that reads a file and displays the file on the screen with a line number […]

[…] value l and h”); int Rec=l*h; System.out.println(“Area of rectangle:”+Rec); } } Missing Number in java with example Write a Java program that reads a file and displays the file on the screen with a line number […]

[…] Missing Number in java with example […]

[…] Missing Number in java with example […]

[…] and b=8”); int a=5 int b=8 int c=a+b; System.out.println(“sum of c:”+c); } } Missing Number in java with example Write a Java program that reads a file and displays the file on the screen with a line number […]

You have successfully subscribed to myprogrammingschool

There was an error while trying to send your request. Please try again.

My Programming School will use the information you provide on this form to be in touch with you and to provide updates and marketing.