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:

Middle latitude cyclones are fueled by? 

A) air high in the atmosphere B) polar continental air masses
C) energy from falling precipitation D) All of the above
 
Answer & Explanation Answer: A) air high in the atmosphere

Explanation:

Extratropical cyclones, sometimes called mid-latitude cyclones or wave cyclones, are low-pressure areas which, along with the anticyclones of high-pressure areas, drive the weather over much of the Earth.

 

Middle latitude cyclones are fueled by air high in the atmosphere.

Report Error

View Answer Report Error Discuss

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

2 2653
Q:

Who becomes the first Indian woman President of Indian National Congress?

A) Pratibha Patil B) Annie Besant
C) Sarojini Naidu D) Vijaya Lakshmi
 
Answer & Explanation Answer: C) Sarojini Naidu

Explanation:

The first Indian woman President of Indian National Congress was Sarojini Naidu in the year 1925.

 

First woman to become the president of INC - Annie Besant 1917.

Report Error

View Answer Report Error Discuss

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

0 2652
Q:

Who is the author of ' The Accidental Prime Minister - The Making and Unmaking of Manmohan Singh'

Answer

Sanjaya Baru

Report Error

View answer Workspace Report Error Discuss

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

Which of the following is the sacred book of Judaism?

A) Old Testament B) Aporypha
C) Avesta D) Both (a) and (b)
 
Answer & Explanation Answer: D) Both (a) and (b)

Explanation:

The sacred books of judaism form the Old Testament and Aporypha. These books contain the history of the Jews and lay down the religious laws and ethics which they must follow.

Report Error

View Answer Report Error Discuss

Filed Under: World History

3 2652
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 2651
Q:

What literary period is the beat generation aligned with?

A) Postmodernism B) Naturalism
C) Modernism D) Realism
 
Answer & Explanation Answer: A) Postmodernism

Explanation:

Postmodernism is the literary period, the beat generation aligned with. Postmodernism refers to mid to late 20th century.

Report Error

View Answer Report Error Discuss

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

7 2651