Write a Program that Inputs 10 Numbers in an Array and Show the Maximum Number

Answers were Sorted based on User's Feedback



Write a Program that Inputs 10 Numbers in an Array and Show the Maximum Number..

Answer / aroosa naseer

import java.util.*;
class ArraysMax{
public static void main(String args[]){
int a[]=new int[10];
int max=0;
int temp;
Scanner scan=new Scanner(System.in);
System.out.println("Enter 10 numbers to find
out maximum");
for(int i=0;i<a.length;i++){
a[i]=scan.nextInt();
}
for (int i = 0; i < a.length; i++) {
while(a[i]>max){
max=a[i];
}

}
System.out.println("maximum number is= " + max);
}
}

Is This Answer Correct ?    3 Yes 1 No

Write a Program that Inputs 10 Numbers in an Array and Show the Maximum Number..

Answer / g mohan kumar

import java.util.*;
class arrmax{
public static void main(String args[]){
int a[]=new int[10];
int max=0;
int temp;
Scanner s=new Scanner(System.in);
System.out.println("Enter 10 numbers to find out maximum");
for(int i=0;i<a.length;i++){
a[i]=s.nextInt();
}
for (int i = 0; i < a.length; i++) {
while(a[i]>max){
max=a[i];
}
}
System.out.println("this number is maximun number "+max);
}
}

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Code Interview Questions

Question: We would like to design and implement a programming solution to the reader-writer problem using semaphores in C language under UNIX. We assume that we have three readers and two writers processes that would run concurrently. A writer is to update (write) into one memory location (let’s say a variable of type integer named temp initialized to 0). In the other hand, a reader is to read the content of temp and display its content on the screen in a formatted output. One writer can access the shared data exclusively without the presence of other writer or any reader, whereas, a reader may access the shared memory for reading with the presence of other readers (but not writers).

1 Answers  


main() { int i; float *pf; pf = (float *)&i; *pf = 100.00; printf("\n %d", i); } a. Runtime error. b. 100 c. Some Integer not 100 d. None of the above

2 Answers   HCL, LG,


main() { int x=5; clrscr(); for(;x==0;x--) { printf("x=%d\n”", x--); } } a. 4, 3, 2, 1, 0 b. 1, 2, 3, 4, 5 c. 0, 1, 2, 3, 4 d. none of the above

3 Answers   HCL,


int swap(int *a,int *b) { *a=*a+*b;*b=*a-*b;*a=*a-*b; } main() { int x=10,y=20; swap(&x,&y); printf("x= %d y = %d\n",x,y); }

1 Answers  


what is oop?

3 Answers  






main() { int c=- -2; printf("c=%d",c); }

1 Answers   TCS,


main() { int i, j; scanf("%d %d"+scanf("%d %d", &i, &j)); printf("%d %d", i, j); } a. Runtime error. b. 0, 0 c. Compile error d. the first two values entered by the user

2 Answers   HCL,


What is your nationality?

1 Answers   GoDB Tech,


main() { int i=400,j=300; printf("%d..%d"); }

3 Answers  


main() { int i, j, *p; i = 25; j = 100; p = &i; // Address of i is assigned to pointer p printf("%f", i/(*p) ); // i is divided by pointer p } a. Runtime error. b. 1.00000 c. Compile error d. 0.00000

3 Answers   HCL,


Printf can be implemented by using __________ list.

3 Answers  


why do you use macros? Explain a situation where you had to incorporate macros in your proc report? use a simple instream data example with code ?

0 Answers  


Categories