Our website is made possible by displaying online advertisements to our visitors.Please consider supporting us by disabling your ad blocker.
Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu
Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Translate it in your own Language

Print this Job Post

Print Friendly and PDF

Saturday, May 17, 2014

C programming code

#include <stdio.h>
#include<conio.h> 
void main() 
{
    int array[100], minimum, size, c, location = 1;
    printf("Enter the number of elements in array\n");
    scanf("%d",&size);
    printf("Enter %d integers\n", size);
    for ( c = 0 ; c < size ; c++ )
    scanf("%d", &array[c]);
    minimum = array[0];
    for ( c = 1 ; c < size ; c++ ) 
    {
        if ( array[c] < minimum ) 
        {
           minimum = array[c];
           location = c+1;
        }
    } 
      printf("Minimum element is present at location %d and it's value is %d.\n", location, minimum);
      getch();
}
Output  Of the Program:

C programming code using pointers

#include <stdio.h>
#include<conio.h> 
void main() 
{
    int array[100], *minimum, size, c, location = 1;
    printf("Enter the number of elements in array\n");
    scanf("%d",&size);
    printf("Enter %d integers\n", size);
    for ( c = 0 ; c < size ; c++ )
    scanf("%d", &array[c]);
    minimum = array;
    *minimum = *array;
    for ( c = 1 ; c < size ; c++ ) 
    {
      if ( *(array+c) < *minimum ) 
      {
        *minimum = *(array+c);
         location = c+1;
       }
     } 
      printf("Minimum element found at location %d and it's value is %d.\n", location, *minimum);
      getch();
}


Thursday, May 15, 2014

Linear search c program

#include <stdio.h>
#include<conio.h> 
void main()
{
   int array[100], search, c, n;
   clrscr();
   printf("Enter the number of elements in array\n");
   scanf("%d",&n);
   printf("Enter %d integer(s)\n", n);
   for (c = 0; c < n; c++)
   scanf("%d", &array[c]);
   printf("Enter the number to search\n");
   scanf("%d", &search);
   for (c = 0; c < n; c++)
   {
      if (array[c] == search)     /* if required element found */
      {
         printf("%d is present at location %d.\n", search, c+1);
         break;
      }
   }
   if (c == n)
   printf("%d is not present in array.\n", search);
   getch();
}

Linear search for multiple occurrences

In the code below we will print all the locations at which required element is found and also the number of times it occur in the list.
#include <stdio.h>
#include<conio.h> 
void main()
{
   int array[100], search, c, n, count = 0;
   clrscr();
   printf("Enter the number of elements in array\n");
   scanf("%d",&n);
   printf("Enter %d numbers\n", n);
   for ( c = 0 ; c < n ; c++ )
   scanf("%d",&array[c]);
   printf("Enter the number to search\n");
   scanf("%d",&search);
   for ( c = 0 ; c < n ; c++ )
   {
      if ( array[c] == search )    
      {
         printf("%d is present at location %d.\n", search, c+1);
count++;
      }
   }
   if ( count == 0 )
   printf("%d is not present in array.\n", search);
   else
   printf("%d is present %d times in array.\n", search, count);
   getch();
}

C program for linear search using function

#include <stdio.h>
#include<conio.h> 
int linear_search(int*, int, int);
void main()
{
   int array[100], search, c, n, position;
   clrscr(); 
   printf("Enter the number of elements in array\n");
   scanf("%d",&n);
   printf("Enter %d numbers\n", n);
   for ( c = 0 ; c < n ; c++ )
   scanf("%d", &array[c]);
   printf("Enter the number to search\n");
   scanf("%d",&search);
   position = linear_search(array, n, search);
   if ( position == -1 )
   printf("%d is not present in array.\n", search);
   else
   printf("%d is present at location %d.\n", search, position+1);
   getch();
int linear_search(int *pointer, int n, int find)
{
   int c;
   for ( c = 0 ; c < n ; c++ )
   {
      if ( *(pointer+c) == find )
      return c;
   }
     return -1;
}

PAGE:4


If text is not visible in image then you can download and zoom it .....

To Download this image  


               « Prev 1234 Next »



PAGE:3



If text is not visible in image then you can download and zoom it .....

To Download this image  


               « Prev 1234 Next »



PAGE:2


If text is not visible in image then you can download and zoom it .....

To Download this image  


               « Prev 1234 Next »


PAGE:1



If text is not visible in image then you can download and zoom it .....

To Download this image  


               « Prev 1234 Next »


PAGE:5




Some Other Question of CGI *Leaked Paper


1. A works thrice as much as B. If A takes 60 days less than B to do a work then find the number of days it would take to complete the work if both work together?

Ans. 221/2days

2. How many 1's are there in the binary form of 8*1024 + 3*64 + 3

Ans. 4

3. In a digital circuit which was to implement (A B) + (A)XOR(B), the designer implements (A B) (A)XOR(B) What is the probability of error in it ?

4. A boy has Rs 2. He wins or loses Re 1 at a time If he wins he gets Re 1 and if he loses the game he loses Re 1.He can loose only 5 times. He is out of the game if he earns Rs 5. Find the number of ways in which this is possible?

Ans. 16

5. If there are 1024*1280 pixels on a screen and each pixel can have around 16 million colors Find the memory required for this?

Ans. 4MB

6. On a particular day A and B decide that they would either speak the truth or will lie. C asks A whether he is speaking truth or lying? He answers and B listens to what he said. C then asks B what A has said B says "A says that he is a liar"What is B speaking ?

(a) Truth
(b) Lie
(c) Truth when A lies
(d) Cannot be determined

Ans. (b)

7.  What is the angle between the two hands of a clock when time is 8:30

Ans. 75(approx)

8. A student is ranked 13th from right and 8th from left. How many students are there in totality ?

9. A man walks east and turns right and then from there to his left and then 45degrees to his right.In which direction did he go

Ans. North west

10. A student gets 70% in one subject, 80% in the other. To get an overall of 75% how much should get in third subject.

11. A man shows his friend a woman sitting in a park and says that she the daughter of my grandmother's only son. What is the relation between the two

Ans. Daughter

12. A grandma has many sons; each son has as many sons as his brothers. What is her age if it?s the product of the no: of her sons and grandsons plus no: of her sons?(age b/w 70 and 100).

Ans: 81

13. An electric wire runs for 1 km b/w some no: of poles. If one pole is removed the distance b/w each pole increases by 1 2/6 (mixed fraction). How many poles were there initially?

14. There is a church tower 150 feet tall and another catholic tower at a distance of 350 feet from it which is 200 feet tall. There is one each bird sitting on top of both the towers. They fly at a constant speed and time to reach a grain in b/w the towers at the same time. At what distance from the church is the grain?

Ans: 90

15. A person wants to meet a lawyer and as that lawyer is busy he asks him to come three days after the before day of the day after tomorrow? on which day the lawyer asks the person to come?

Ans: thursday


             
         

            « Prev 1234567 Next »


PAGE:6



CGI Quantitative Aptitude Section:

1. Data sufficiency. there were about 15 questions of the type A question is given with 2 options. U have 2 conclude ans can be determined by only option 1 or 2 or both or both r insufficient.

2. Data interpretation. This was dam tough. U have to manipulate a graph and answer about 12 questions. there were also thequestions on graphs and tables.

3. Contractor has 2 complete work within a fixed time. If he is late he has to pay fine. The first day it is Rs 200 and from then on it increases by 25 per day. He has to pay Rs 9450. How many days he got late.

Ans is 21.

4. Sphere of diameter 6 cm is melted to form a cone with diameter 12 cm. Find height of cone.

5. Shakuntala devi sum of the number of glasses received intact.

6. Sum on Cisterns, Pipes a, B and C r there a and b can fill the tank in 4 and 5 hours respectively. C can empty tank in 2 hours. If the pipes were opened at 1.00 and 2.00 am successively by what time will the tank be empty.

7. a question 
on cost of painted area.

8. A brick size is 8″ x 6″. An L shaped wall has to be built with width of 4, other two dimmensions are 21 and 7. Find no of Bricks reqd.

9. Ratio of base and heights of a cone and cylinder is given. Find ratio of their curved surfaces.

CGI 
Technical Section:

1. ——— acts as a command interpreter



A) Unix shell b) kernel c) d) ans) a

2. Combine $x=1;[x -ge 10] into a single statement

3. Wats the output of 
the code snippet

echo hello

Eval echo Hello

Eval echo eval Hello

Ans: hello

Hello

Hello

4. What does $* represent

5. Which statement is true to dbms?

a) Collection of data

b) Collection of interrelated data and set of programs to access that data

c) Collection of inter related data no need of any programs

d) Collection of data and set of programs

Ans) b

6. Values should dependant on primary key in which normal form?

a) 1 NF b) 2nf c) 3nf d) 4nf

7. Mathematical representation of joining tables ———-

a) Union b) c) Cartesian product d)

8. Question on data objects and constraints

9. Use of normalization?

a) Reducing redundancy b) little storage space c) d) all the above

ANS)d

10. What r the types of joins below

A) Interior & outer b) inner and outer joins c) d)

Ans) b

11. C++ —15 q(15 min)

The code that could be written in which block to raise exceptions?

A) Catch b) try c) finally d) none

Ans) b  


his was especially for the mainframes and they had stressed on CICS.

The paper is divided in 2 sections:

1: Verbal

2: 
quantitative.

The test is of 1 hour and 15 minutes duration.

Verbal:

1. U have 
to point grammatical errors, about 10 were there.

2. U have to fill the blanks with correct options about 20.

3. a comprehension and 12 questions.

Quantitative:

1. Data sufficiency. there were about 15 questions of the type A 
question is given with 2 options. U have 2 conclude ans can be determined by only option 1 or 2 or both or both r insufficient.

2. Data interpretation. This was dam tough. U have to manipulate a graph and 
answer about 12 questions. there were also thequestions on graphs and tables.

3.  Contractor has 2 complete work within a fixed time. If he is late he has to pay fine. The first day it is Rs 200 and from then on it increases by 25 per day. He has to pay Rs 9450. How many days he got late.

Ans is 21.

4. Sphere of diameter 6 cm is melted to form a cone with diameter 12 cm. Find height of cone.

5. Shakuntala devi sum of the number of glasses received intact.

6. Sum on Cisterns, Pipes a, B and C r there a and b can fill the tank in 4 and 5 hours respectively. C can empty tank in 2 hours. If the pipes were opened at 1.00 and 2.00 am successively by what time will the tank be empty.

7. a question 
on cost of painted area.

8. A brick size is 8" x 6". An L shaped wall has to be built with width of 4, other two dimmensions are 21 and 7. Find no of Bricks reqd.

9.
 Ratio of base and heights of a cone and cylinder is given. Find ratio of their curved surfaces.



            « Prev 1234567 Next »




PAGE:7


CGI PUZZLE QUESTION
Question 1. There is a man that lives on the top floor of a very tall building. Every day he gets the elevator down to the ground floor to leave the building to go to work.  Upon returning from work though, he can only travel half way up in the lift and has to walk the rest of the way unless it's raining!  WHY?

ANS: The man is very short and so can only reach half way up the lift buttons!  However, if it is raining then he will have his umbrella with him and so can press the higher buttons with it.

Question 2. A man and his son are in a car accident.  The father dies on the scene, but the child is rushed to the hospital.  When he arrives the surgeon says, "I can't operate on this boy, he is my son!"  How can this be?

ANS: The surgeon is the boy's mother.

Question 3. A man is wearing black.  Black shoes, socks, trousers, jumper, gloves and balaclava.  He is walking down a black street with all the street lamps off.  A black car is coming towards him with its light off too but somehow manages to stop in time.  How did the driver see the man?

ANS: It was daytime.

Question 4. Why is it better to have round manhole covers than square ones?

ANS: A square manhole cover can be turned and dropped down the diagonal of the manhole.  A round manhole cannot be dropped down the manhole. So for safety and practicality, all manhole covers should be round.

Question 5. A woman had two sons who were born on the same hour of the same day of the same year.  But they were not twins.  How could this be so?

ANS: They were two of a set of triplets (or quadruplets etc.)

Question 6. You are participating in a race. You overtake the second. What position do you finish?

ANS: If you answer that you arrived first, then you are absolutely wrong!!!  If you overtake the second and you take his place, you arrived second!!!

Question 7. You are participating in a race. ...If you overtake the last then you arrive...?

ANS: If you answer that you arrived second last then you are wrong again. Tell me, how you can overtake the LAST!!!!

Question 8. Once there was loving couple travelling in a bus in a mountainous area.  They wanted to get down at some place. The couple disembarked
the bus and   it moved on. As the bus moved on a humongous rock fell
on the bus from a mountain and crushed the bus to crumbs. Everybody on
board was killed. The couple upon seeing that, said, "We wish we could
be on that bus?" Why did they say that?

ANS: In case they had decided not to get down, the resulting time delay
could have been avoided and the rock would have fallen after the bus
had passed off.

Question 9. At the end of the day one market stall had 16 apples and 48 oranges left. Another market stall had 36 apples and 24 oranges left. What is the difference between the percentages of apples left in the two market stalls?

ANS:
35%.
First stall 16 out of 64 = 25%.
Second stall 36 out of 60 = 60%.
Difference in percentages = 35%.

Question 10. You have a birthday cake and have exactly 3 cuts to cut it into 8 equal pieces. How do you do it?

ANS: The “correct” answer is to cut the cake in quarters (4 pieces) using 2 of the cuts, then stack all 4 of the pieces and then split all four of the stacked pieces with the third cut.
Question 11. Given the numbers 1 to 1000, what is the minimum number [of] guesses needed to find a specific number if you are given the hint ‘higher’ or ‘lower’ for each guess you make?

ANS: This may be considered a trick question, since it’s deceptively easy. Read the question carefully and you’ll note that the question asks for the ‘minimum’ number of guesses. Think about it – someone can guess the right question on their first try right?
So, the answer here would be ‘1’, since it would take only one correct guess to find a specific number. But, what if we wanted to find the maximum number of guesses?
Well, think about this one. What if the number that you have to guess is ‘1’ and you start guessing from 1,000? Then, if the person who knows the number keeps saying lower, then you would guess 999,998,997…6,5,4,3,2, and finally until you get to 1. This means that the maximum number of guesses is 999.

Question 12. Suppose that you are standing in a hallway next to 3 light switches, which are all off. There is another room down the hallway, where there are 3 incandescent light bulbs – each light bulb is operated by one of the switches in the hallway. Because the light bulbs are in another room, you cannot see them since you are standing in the hallway. How would you figure out which switch operates which light bulb, if you can only go the room with the light bulbs one time, and only one time?

ANS:What about the light bulbs? Well, we do know that incandescent light bulbs get hot when they are on. We know that the longer an incandescent light bulb stays on the hotter it gets.
So, if we turn one switch off after 5 minutes, turn the second one on, and leave the last one off then what happens? Well, the light bulb corresponding to the first switch will still be warm (even though it’s off), the bulb corresponding to the second switch will be on, and the bulb corresponding to the last switch will be off. This is enough information so that we can go into the attic only once and figure out which switch belongs to which light bulb.

Question 13. You are given 8 pennies, 7 of which weigh exactly the same, but one penny weighs less than the other 7. You also have a judge scale. Find the one penny that weighs the least in less than 3 steps.

ANS: First, you split the 8 pennies into 3 groups of pennies – 2 groups with 3 pennies each and 1 group with 2 pennies. Then, you compare the weight of the first two groups of 3 pennies each by putting them on the scale.
Scenario #1The 2 groups weigh the same. This means the lightest coin is in the group of 2. So, take those 2 pennies and compare them to each other and find the lightest coin.
Scenario #2The 1st group weighs more than the 2nd group. Take group #2 (3 pennies) and pick any 2 pennies out of that group of 3. If they weight the same, then the third penny is lighter. If they don’t weigh the same then the lighter one is obviously the lightest penny.

Question 14. Suppose you have a 3 litter jug and a 5 litter jug (this could also be in gallons). The jugs have no measurement lines on them either. How could you measure exactly 4 litters using only those jugs and as much extra water as you need?

ANS:
First Answer:
Step 1: First, fill the 5 litter jug and then pour it into the 3 litter jug. The 5 litter jug now has only 2 litters left.
Step 2: Next, empty out the 3 litter jug. Then, pour the 2 litters from the 5 litter jug to the 3 litter jug. So, now the 3 litter jug has 2 litters.
Step 3: Fill the 5 litter jug again, and pour 1 litter into the 3 litter jug. Now, what’s left in the 5 litter jug? Well, exactly 4 litters! There’s your answer.

Second Answer:
Step 1: First fill the 5 litters jug by 3 litters jug 2 times. After filling the 5 litters jug full, 1 litter water will be remaining in 3 litters jug.
Step 2: Next, empty out the 5 litters’ jug. Then, pour the 1 litter water of 3 litters jug in to 5 litters’ jug.
Step 3: Now fill the 3 litters water from the 3 litter jug in to 5 litters jug. Now 5 litters will have 4 litters water.

Question 15. Four people need to cross a rickety rope bridge to get back to their camp at night. Unfortunately, they only have one flashlight and it only has enough light left for seventeen minutes. The bridge is too dangerous to cross without a flashlight, and it’s only strong enough to support two people at any given time.

ANS: Each of the campers walks at a different speed. One can cross the bridge in 1 minute, another in 2 minutes, the third in 5 minutes, and the slowest camper takes 10 minutes to cross. How can the campers make it across in exactly 17 minutes?
Camper-1: 1 Minute,
Camper-2: 2 Minutes,
Camper-5: 5 Minutes,
Camper-10: 10 Minutes
First camper-1 and camper-2 will go and camper-1 will return. So total 3 minutes gone. Now camper-5 and camper-10 will go (total time: 10+3=13) and camper-2 will return. So total time is now 15. Now camper-1 and camper-2 will go. Now total time is exactly 17 minutes.

C1, C2,C5,C10----------------------------------------------------------------
            C5,C10---------------------------(2 min)----------------------------à C1,C2
C1,      C5,C10ß------------------------(2+1=3 mins)--------------------C2
C1                    ------------------------(3+10=13 mins)---------------------C2,C5,C10
C1,C2              <------------------------(13+2=15 mins)-------------------C5,C10
                         ------------------------(15+2=17 mins)--------------------àC1,C2,C5,C10

Question 16. You wake up one morning and there’s been a power outage. You know you have 12 black socks and 8 blue ones. How many socks do you need to pull out before you’ve got a match?

ANS: Pick three because out of three, two will be of same colour.

Question 17. You’re trying to get to Truthtown. You come to a fork in the road. One road leads to Truthtown (where everyone tells the truth), the other to Liartown (where everyone lies). At the fork in the road is a man from one of those towns . You get to ask him one question to discover the way. What’s the question?

ANS: To find the way to Truthtown, ask the man, “Which way is your hometown?” Then, go whichever way he points: If he’s from Liartown, he’ll point to Truthtown, and if he’s from Truthtown, he’ll point to Truthtown.

Question 18. How many cubes are at the center of a Rubik’s Cube?

ANS: There is only one cube at the center of a Rubik’s Cube.

Question 19. You have two containers, one holds five gallons, the other holds three. You can have as much water as you want. Measure exactly four gallons of water into the five gallon container.

ANS: Fill up the three-gallon container and pour it into the five-gallon container. Do it again -- there will be one gallon left in the three-gallon container. Empty the five, pour in the one, fill the three again and pour it into the firve-gallon container -- you have four!

Question 20. You have two sticks and matchbox. Each stick takes exactly an hour to burn from one end to the other. The sticks are not identical and do not burn at a constant rate. As a result, two equal lengths of the stick would not necessarily burn in the same amount of time.  How would you measure exactly 45 minutes by burning these sticks?

ANS:The answer is really simple. Since the sticks do not burn at a constant rate, we can not use the length of the stick as any sort of measurement of time. If we light a stick, it takes 60 minutes to burn completely. What if we light the stick from both sides? It will take exactly half the original time, i.e. 30 minutes to burn completely.
0 minutes – Light stick 1 on both sides and stick 2 on one side.
30 minutes – Stick 1 will be burnt out. Light the other end of stick 2.
45 minutes – Stick 2 will be burnt out.

Question 21. A farmer bought a goat, a wolf and a cabbage from the market. On his way home, he has to cross a river. He has a small boat which only allows him to take one thing with him at a time. The farmer cannot leave the cabbage and the goat together (the goat would eat the cabbage) nor can he leave the goat and the wolf together (the wolf would eat the goat). How does he cross the river without losing any of the things he bought?

ANS:The farmer takes the goat with him and leaves it on the other side of the river. Then he comes back to the side of the river where he left the wolf and cabbage together. He then takes the cabbage with him. When he reaches the other side, he leaves the cabbage and brings the goat back with him. Then he leaves the goat and takes the wolf with him. He then drops the wolf off with the cabbage and finally comes back for the goat. So this way, the farmer avoids leaving the goat and the cabbage or the wolf and the goat together unattended.

Question 22. You are standing outside a room next to three switches, all of which are off. Each switch operates a different light bulb in the room. The room door is closed, so you cannot see which switch operates which bulb. You are only allowed to go into the room once. Determine which switch operates which bulb.

ANS:First, we turn the first switch on and leave the other two off. After 5 minutes, we turn the first switch off, turn the second switch on and leave the third switch off. Then we go into the room and touch one of the bulbs which is turned off. After that, it would be easy to tell that the first switch matches the warm bulb, the second switch matches the bulb thats turned on and the third switch matches the colder bulb.

Question 23. You have 3 baskets, one with apples, one with oranges and one with both apples and oranges mixed. Each basket is closed and is labelled with ‘Apples’, ‘Oranges’ and ‘Apples and Oranges’. However, each of these labels is always placed incorrectly. How would you pick only one fruit from a basket to place the labels correctly on all the baskets?

ANS:Say you pick a fruit from the basket labelled ‘Apples and Oranges’. Surely this basket will have either apples or orange.  If this fruit is an apple in the basket labelled Apples and oranges. We have two closed basket labelled Apples and Oranges. It is sure that they do not have the right things according to labelled. The basket labelled Apples may have oranges or mixed. The basket labelled Oranges may have Apples or mixed, but since we have found apples in the basket labelled Mixed, so the basket labelled Orange can contain only mixed. If Orange labelled basket has mixed then the basket labelled Apples will have Oranges. You can apply the same logic if you assume you picked an orange from the basket labeled as ‘Apples and Oranges’.

Question 24. You want to send a secret message to your friend Sathish in the post. You don’t trust the postal company. So you put your message in a box with a lock. But you are not allowed to send a key!How can you get your message through securely?

ANS:Send the box with the lock to Sathish. Sathish can’t open it, but can put another lock on the box. Sathish sends this box with the 2 locks back to you, you unlock your lock and send it back to Alex again. So there is just Alex’s lock on the box and Alex can now open it.

           « Prev 1234567 Next »


PAGE:3


If text is not visible in image then you can download and zoom it .....

To Download this image  

            « Prev 1234567 Next »








PAGE:4


If text is not visible in image then you can download and zoom it .....

To Download this image  

           « Prev 1234567 Next »



PAGE: 2


If text is not visible in image then you can download and zoom it .....

To Download this image  

            « Prev 1234567 Next »




PAGE: 1


If text is not visible in image then you can download and zoom it .....

To Download this image  

           « Prev 1234567 Next »


  


C programming code


#include <stdio.h>
#include<conio.h> 
void main()
{
  int array[100], maximum, size, c, location = 1;
  printf("Enter the number of elements in array\n");
  scanf("%d", &size);
  printf("Enter %d integers\n", size);
  for (c = 0; c < size; c++)
  scanf("%d", &array[c]);
  maximum = array[0];
  for (c = 1; c < size; c++)
  {
    if (array[c] > maximum)
    {
       maximum  = array[c];
       location = c+1;
    }
  }
  printf("Maximum element is present at location %d and it's value is %d.\n", location, maximum);
  getch();
}

C programming code using pointers

#include <stdio.h>
#include<conio.h> 
void main()
{
  long array[100], *maximum, size, c, location = 1;
  printf("Enter the number of elements in array\n");
  scanf("%ld", &size);
  printf("Enter %ld integers\n", size);
  for ( c = 0 ; c < size ; c++ )
  scanf("%ld", &array[c]);
  maximum  = array;
  *maximum = *array;
  for (c = 1; c < size; c++)
  {
    if (*(array+c) > *maximum)
    {
       *maximum = *(array+c);
        location = c+1;
    }
  }
  printf("Maximum element found at location %ld and it's value is %ld.\n", location, *maximum);
  getch();
}

Copyright @ CrackMNC 2014-2024
Divas Nikhra Theme by Crack MNC