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

Where does most weather occur in the atmosphere?

A) Ionosphere B) Stratosphere
C) Troposphere D) Mesosphere
 
Answer & Explanation Answer: C) Troposphere

Explanation:

The troposphere is the lowest layer of the atmosphere and where most clouds are. That means all weather is in the troposphere. Almost all weather occurs in the Troposphere, basically, the lowest layer that goes up to about 10 - 15 kms.

Report Error

View Answer Report Error Discuss

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

3 2642
Q:

Which area best lends itself to the formation of fossils?

which_area_best_lends_itself_to_the_formation_of_fossils1538734185.jpg image

A) near active volcano B) lake beds
C) Both A & B D) None of the above
 
Answer & Explanation Answer: C) Both A & B

Explanation:

Area near active volcano or lake beds are best areas that lends itself to the formation of fossils.

Report Error

View Answer Report Error Discuss

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

3 2641
Q:

Which program is an example of domestic policy?

A) NAFTA B) The Versailles Treaty
C) The Clean Air Act NATO D) The Carter Doctrine
 
Answer & Explanation Answer: C) The Clean Air Act NATO

Explanation:

Domestic policy is the decisions made by a government regarding issues that occur within the country.

The Clean Air Act NATO program is an example of domestic policy.

Report Error

View Answer Report Error Discuss

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

0 2641
Q:

Why should you use the Ad Preview and Diagnosis tool to check if your ads are live and running on Google?

Answer

By searching for keywords that trigger your ad, you can rack up impressions without clicks, which may lower your Click-Through Rate, which may prevent your ad from appearing as often as it is eligible.

Report Error

View answer Workspace Report Error Discuss

0 2641
Q:

Who had announced that democracy is a government " of the people, by the people and for the people " ?

A) Abraham Lincoln B) George Washignton
C) Theodore Roosevelt D) Winston Churchill
 
Answer & Explanation Answer: A) Abraham Lincoln

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: Famous Personalities
Exam Prep: AIEEE , Bank Exams , CAT
Job Role: Bank Clerk , Bank PO

10 2640
Q:

What would be the output of the following program?

main()

{

   struct emp

   {

        char *n;

        int age;

   };

   struct emp e1 = { "Dravid", 23};

   struct emp e2 = e1;

   strupr (e2.n);

   printf ("\n%s",e1.n);

}

Answer

DRAVID


When a structure is assigned, passed, or returned, the copying is done monolithically. This means that the copies of any pointer fields will point to the same place as the original. In other words, anything pointed to is not copied. Hence, on changing the name through e2.n it automatically changed e1.n

Report Error

View answer Workspace Report Error Discuss

Subject: Programming

0 2640
Q:

Charaka Samhita was a work on

A) Astrology B) Law
C) Medicine D) Religion
 
Answer & Explanation Answer: C) Medicine

Explanation:

Charaka Samhita was a work on Medicine.

Report Error

View Answer Report Error Discuss

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

4 2640