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 2742
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 2741
Q:

Name the sea demoness known for trapping birds by illusion, who tried to obstruct Hanuman on his way to Lanka?

Answer

Simhika

Report Error

View answer Workspace Report Error Discuss

Subject: Indian Culture

33 2741
Q:

Elastomers can extend upto

A) ten times their original dimensions B) seven times their original dimensions
C) five times their original dimensions D) three times their original dimensions
 
Answer & Explanation Answer: B) seven times their original dimensions

Explanation:

An elastomer is a polymer with viscoelasticity which have low youngs modulus with weak intermolecular forces when compared with other materials.

Report Error

View Answer Report Error Discuss

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

3 2740
Q:

Microorganisms that cause disease are called

A) Pathogens B) Microbes
C) Infectees D) None of the above
 
Answer & Explanation Answer: A) Pathogens

Explanation:
Report Error

View Answer Report Error Discuss

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

2 2740
Q:

Who is in the judicial branch?

Answer

Judicial branch is one among the three branches of the government. 


Supreme court, the magistrate (local) and municipal (city) courts are there in the judicial branch.


The Judicial branch interprets the laws.

Report Error

View answer Workspace Report Error Discuss

Subject: Indian Politics Exam Prep: AIEEE , Bank Exams , CAT , GATE
Job Role: Analyst , Bank Clerk , Bank PO

1 2740
Q:

Which microscope is often used to view metal surfaces?

A) Optical microscopes B) Scanning tunneling microscopes
C) Electron microscopes D) None of the above
 
Answer & Explanation Answer: B) Scanning tunneling microscopes

Explanation:

Microscopes are of three types. They are :

 

1) Optical microscopes

 

2) Electron microscopes

 

3) Scanning tunneling microscopes

 

 Which_microscope_is_often_used_to_view_metal_surfaces1538720175.png image

 

Scanning tunneling microscopes are the microscopes that are used to view metal surfaces.

Report Error

View Answer Report Error Discuss

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

0 2739
Q:

Limbs of frog, lizard, bird and human are example of ______ organs.

A) Homogenous B) Heterogeneous
C) Analogous D) Homologous
 
Answer & Explanation Answer: D) Homologous

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: Biology

4 2739