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

When backed by buying, power wants become

A) demands B) physical needs
C) exchanges D) social needs
 
Answer & Explanation Answer: A) demands

Explanation:

When backed by buying, power wants become demands. 

Report Error

View Answer Report Error Discuss

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

1 2702
Q:

The Great Barrier Reef is located in which country? 

A) Australia B) China
C) Taiwan D) South Africa
 
Answer & Explanation Answer: A) Australia

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: Famous Places

5 2701
Q:

In Which three languages is the Rosetta Stone written?

Answer

Greek, demotic Egyptian and hieroglyphics.

Report Error

View answer Workspace Report Error Discuss

Subject: World History

0 2701
Q:

Expand and simplify (2x + 5)2 *(4x ­- 1) -­ (3x3 - 16x2 + 25x -­ 21)

A) 13x3 + 92x2 -­ 55x + 4 B) 13x3 -­ 92x2 -­ 55x -­ 4
C) 13x3 + 92x2 + 55x -­ 4 D) 13x3 -­ 92x2 + 55x + 4
 
Answer & Explanation Answer: C) 13x3 + 92x2 + 55x -­ 4

Explanation:
Report Error

View Answer Report Error Discuss

1 2701
Q:

Deep fried foods are carcinogenic because they are rich in

A) Nicotine B) Hydrocarbons
C) Fats D) All of the above
 
Answer & Explanation Answer: C) Fats

Explanation:

Deep fried foods are carcinogenic because they are rich in fats.

Report Error

View Answer Report Error Discuss

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

12 2701
Q:

An irregular mode of reproduction resulting in the development of an embryo without fertilization is called

1.Parthenogenesis 2.Apogamy 3.Sporophytic budding

Select the correct answer using the code given below.

A) 1 only B) 2 only
C) 2 and 3 only D) 1, 2 and 3
 
Answer & Explanation Answer: D) 1, 2 and 3

Explanation:

In animals, parthenogenesis means development of an embryo from an unfertilized egg cell. In plants parthenogenesis is a component process of apomixis.Apogamy is a type of reproduction, occurring in some ferns, in which the sporophytedevelops from the gametophyte without fusion of gametes.Adventitious embryony also called sporophytic budding, is a type of apomixis in which an embryo develops directly from nucellus or integument tissue.So, all three are correct.

Report Error

View Answer Report Error Discuss

Filed Under: Biology
Exam Prep: Bank Exams

2 2701
Q:

Suppose a customer is planning to create a non-hosted Linux partition on an i825. Linux will have only direct-attach devices. What is the Linux console option?

A) Use OS/400 VNC support. B) Telnet to the virtual console.
C) Share the primary partitions console. D) Allocate a console IOA to the Linux partition.
 
Answer & Explanation Answer: B) Telnet to the virtual console.

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: IBM Certification

1 2701