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

In which of the following branches of Knowledge outstandin contribution for the benefits of mankind is not recognised with a Nobel Prize

A) Madicine B) Chemistry
C) Engineering D) Economics
 
Answer & Explanation Answer: C) Engineering

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: Honours and Awards

1 2308
Q:

Primary growth in plants occurs by

A. Vertical meristem

B. Lateral meristem

C. Intercalary meristem

D. Apical meristem

 

A) C & D B) A, B & D
C) A, B, C & D D) B, C & D
 
Answer & Explanation Answer: A) C & D

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: Biology
Exam Prep: Bank Exams

0 2308
Q:

What is BGP ?

Answer

It is a protocol used to advertise the set of networks that can be reached with in an autonomous system. BGP enables this information to be shared with the autonomous system. 

Report Error

View answer Workspace Report Error Discuss

Subject: Networking
Job Role: Network Engineer

0 2308
Q:

First woman Governor of Kerala?

A) Sheila Dikshit B) Fathima Beevi
C) Sarojini Naidu D) Jyothi Venkitachalam
 
Answer & Explanation Answer: D) Jyothi Venkitachalam

Explanation:

Jyothi Venkitachalam was an Indian politician who served as Governor of Kerala and Member of the Legislative Assembly of Tamil Nadu.

First_woman_Governor_of_Kerala1557552474.jpg image

Report Error

View Answer Report Error Discuss

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

2 2308
Q:

Smart-Up grants, is associated with which Indian bank?

 

A) ICICI Bank B) Yes Bank
C) Axis Bank D) HDFC Bank
 
Answer & Explanation Answer: D) HDFC Bank

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: General Awareness
Exam Prep: Bank Exams

0 2307
Q:

The Solar System was discoverd by

A) Galleleo B) Finsen
C) Copernicus D) None of these
 
Answer & Explanation Answer: C) Copernicus

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: Inventions

0 2307
Q:

Would the following program compile?

main()

{

    int a = 10, *j;

    void *k;

    J = k = &a;

    J++;

    k++;

   printf ("\n%u %u", j, k);

}

Answer

An error would be reported in the statement k++ since arithmetic on void pointers is not permitted unless the void pointer is appropriately typecasted.

Report Error

View answer Workspace Report Error Discuss

Subject: Programming

0 2307