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

Shahi Litchi of which recently got a GI tag?

A) Telangana B) Bihar
C) Odisha D) Maharastra
 
Answer & Explanation Answer: B) Bihar

Explanation:

Shahi Litchi of Bihar recently got a GI tag and got official recognition for Muzaffarpur in Bihar.

Report Error

View Answer Report Error Discuss

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

3 2740
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
Q:

Which of the following countries is not a member of the UN

A) Nepal B) Iran
C) Kampuchea D) Switzerland
 
Answer & Explanation Answer: C) Kampuchea

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: World Organisations

2 2739
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 2739
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 2738
Q:

The systematic risk of the market is measured by

A) alpha B) beta
C) gamma D) All of the above
 
Answer & Explanation Answer: B) beta

Explanation:

Beta is the measurement of the systematic risk of the market.

Report Error

View Answer Report Error Discuss

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

0 2738
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 2738