Questions

Q:

Write a c program for binary search.

Answer

#include<stdio.h>
int main(){

    int a[10],i,n,m,c=0,l,u,mid;

    printf("Enter the size of an array: ");
    scanf("%d",&n);

    printf("Enter the elements in ascending order: ");
    for(i=0;i<n;i++){
         scanf("%d",&a[i]);
    }

    printf("Enter the number to be search: ");
    scanf("%d",&m);

    l=0,u=n-1;
    while(l<=u){
         mid=(l+u)/2;
         if(m==a[mid]){
             c=1;
             break;
         }
         else if(m<a[mid]){
             u=mid-1;
         }
         else
             l=mid+1;
    }
    if(c==0)
         printf("The number is not found.");
    else
         printf("The number is found.");

    return 0;
}

Sample output:
Enter the size of an array: 5
Enter the elements in ascending order: 4 7 8 11 21
Enter the number to be search: 11
The number is found.

Report Error

View answer Workspace Report Error Discuss

Subject: Programming

0 2702
Q:

When backed by buying, power wants become

A) demands B) physical needs
C) exchanges D) social needs
 
Answer & Explanation Answer: A) demands

Explanation:

When backed by buying, power wants become demands. 

Report Error

View Answer Report Error Discuss

Filed Under: Marketing and Sales
Exam Prep: AIEEE , Bank Exams , CAT
Job Role: Analyst , Bank Clerk , Bank PO

1 2701
Q:

In Which three languages is the Rosetta Stone written?

Answer

Greek, demotic Egyptian and hieroglyphics.

Report Error

View answer Workspace Report Error Discuss

Subject: World History

0 2701
Q:

The Great Barrier Reef is located in which country? 

A) Australia B) China
C) Taiwan D) South Africa
 
Answer & Explanation Answer: A) Australia

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: Famous Places

5 2701
Q:

The purpose of the constitution is presented in the

A) Amendments B) Preamble
C) Bill of Rights D) Articles
 
Answer & Explanation Answer: B) Preamble

Explanation:

The Preamble proclaims the solemn resolution of the people of India to constitute India into a 'Sovereign socialist secular democratic republic'.

Report Error

View Answer Report Error Discuss

Filed Under: Indian Politics
Exam Prep: AIEEE , Bank Exams , CAT
Job Role: Analyst , Bank Clerk , Bank PO

3 2701
Q:

Earth is known as Blue planet?

A) TRUE B) FALSE
Answer & Explanation Answer: B) FALSE

Explanation:

We know that, 


Earth is known as Watery planet.


Neptune is known as Blue planet. 

Report Error

View Answer Workspace Report Error Discuss

Subject: General Science
Exam Prep: AIEEE , Bank Exams , CAT
Job Role: Analyst , Bank Clerk , Bank PO

0 2701
Q:

Magnetism in materials is due to

A) Displacement of electrons B) Circular motion of electrons
C) Charges of neutrons D) All of the above
 
Answer & Explanation Answer: B) Circular motion of electrons

Explanation:

Magnetism in materials is due to circular motion of electrons.

Report Error

View Answer Report Error Discuss

Filed Under: Physics
Exam Prep: AIEEE , Bank Exams , CAT , GATE
Job Role: Analyst , Bank Clerk , Bank PO

4 2701
Q:

Deep fried foods are carcinogenic because they are rich in

A) Nicotine B) Hydrocarbons
C) Fats D) All of the above
 
Answer & Explanation Answer: C) Fats

Explanation:

Deep fried foods are carcinogenic because they are rich in fats.

Report Error

View Answer Report Error Discuss

Filed Under: Biology
Exam Prep: AIEEE , Bank Exams , CAT
Job Role: Analyst , Bank Clerk , Bank PO

12 2701