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 2653
Q:

Hong Kong will be transferred to china in

A) 1990 B) 1996
C) 1997 D) 2000
 
Answer & Explanation Answer: C) 1997

Explanation:
Report Error

View Answer Report Error Discuss

2 2653
Q:

Head Quaters of NATO is located in 

A) Newyork B) Brussels
C) Alaska D) California
 
Answer & Explanation Answer: B) Brussels

Explanation:

Head Quaters of NATO is located in Brussels

Report Error

View Answer Report Error Discuss

Filed Under: World Organisations

5 2653
Q:

Which of these is ATP?

A) 3 Phosphate groups attached to chromosome attached to Adenine B) 3 Phosphate groups attached to a Ribose attached to Adenine
C) 3 Phosphate groups attached to a Ribose attached to Thymine D) None of the above
 
Answer & Explanation Answer: B) 3 Phosphate groups attached to a Ribose attached to Adenine

Explanation:

ATP is a Adenosine Triphosphate.

 

ATP is 3 Phosphate groups attached to a Ribose attached to Adenine.

Report Error

View Answer Report Error Discuss

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

4 2653
Q:

Plants grow in size because of 

A) addition of cells B) increase in size of cells
C) enlargement of cells D) elongation of cells
 
Answer & Explanation Answer: A) addition of cells

Explanation:

Plants grow in size both in height and in girth. Enlargement of cells already present cannnot contribute much to the growth. Only addition of more and more cells could increase the size of the plant considerably.

Report Error

View Answer Report Error Discuss

Filed Under: Biology

3 2653
Q:

The capacity of a water heater is measured in

A) Gallons B) Liters
C) Meters D) Both A & B
 
Answer & Explanation Answer: D) Both A & B

Explanation:

The capacity of a water heater is measured in Gallons or Liters. In the USA, it is measured in Gallons and in India, we measure it in Liters.

Hence, if the capacity of the water heater is 15 gallons or 15 liters, then it says that it can hold 15 gallons or 15 liters of water.

Report Error

View Answer Report Error Discuss

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

3 2653
Q:

The Reserve Bank of India has imposed a penalty of Rs 5 crore on which of the following banks for non-compliance of its directives?

A) Karur Vysya Bank B) HDFC Bank
C) Kotak Mahindra Bank D) Yes Bank
 
Answer & Explanation Answer: A) Karur Vysya Bank

Explanation:

The Reserve Bank of India has imposed a penalty of Rs 5 crore on Karur Vysya Bank for non-compliance of its directives on Income Recognition and Asset Classification (IRAC).

Report Error

View Answer Report Error Discuss

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

0 2653
Q:

_____ officially recognises Bitcoin as currency ?

A) South Korea B) China
C) Japan D) India
 
Answer & Explanation Answer: C) Japan

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: General Awareness

2 2652