## Infosys Placement Paper Infosys 2010 with Answers & Solutions.

Here are the details of Infosys Placement Paper I job in Infosys
Here you will find Infosys Placement Paper Pattern and Download questions of Infosys Placement Paper 2010 with Answers & Solutions.

Infosys Placement Paper Pattern 2010:-

1) arithmetic and reasoning skills : 30 questions -----40 mins
2) verbal English grammar & comprehension) : 40 questions -----30 mins

Infosys Placement Paper 2010:-
Arithmetic:-
1. There is a merry-go-round race going on.One person says,"1/3 of those in front of me and 3/4 of those behind me, give the total number of children in the race". Then the number of children took part in the race? (repeated from previous papers)

Ans: 13

[ Assume there are x participants in the race.In a round race,no: of participants in front of a person wil be x-1 an that behind him wil b x-1. i.e, 1/3(x-1) + 3/4(x-1) = x ; solving x = 13 ]

2. In an Island the natives lie and visitors speak truth. A man wants to know whether a salesman beside him in a bar is a native or visitor. He asked him to ask a woman beside him whether she is a native or visitor. He replied "she says she is a visitor". Then he knew that the salesman is a native or visitor. salesman is in which category , native or visitor?

Ans: Native

[ Draw table and see ]

3.A man fixed an appointment to meet the manager, Manager asked him to come two days after the day before the day after tomorrow. Today is Friday. When will the manager expect him? (repeated from previous papers)

Ans: Monday

[Don't confuse it with Tuesday.the correct answer is Monday]

5.A man said he spent 1/6 of his as a child, 1/12 as salesman in a liquor shop, 1/7 and 5 years as a politician and a good husband respectively. At that time Jim was born. Jim was elected as Alderman four years back.when he was half of his age. What is his age? (repeated from previous papers)

Ans: 84 years

[Assume that he lived x years. X/6 + x/12 + x/7 + 5 + 4 + x/2 = x. Solving x= 84, Same as Question in Shakundala Devi book]

6.Jack,Doug and Ann, 3 children had a running race while returning from school.Mom asked who won the race. Then Jack replied" I wont tell u.I wil give u a clue,When Ann takes 28 steps Doug takes 24 steps, meantime I take 21 steps. Jack explained that his 6 steps equals Droug's 7 steps and Ann's 8 steps. Who won the race? (repeated from previous papers)

Ans: Doug

[ Ann steps = 8,16,24,28 --- finished by 3 & half full steps

Doug steps=7,14,21,24 --- finished before 3 & half full steps

Jack steps= 6,12,18,21 --- finished by 3 & half full steps

So Doug won the race ]

7. Every day a cyclist meets a car at the station.The road is straight and both are travelling in the same direction. The cyclist travels with a speed of 12 mph.One day the cyclist comes late by 20 min. and meets the car 5miles before the Station. What is the speed of the car?

Ans: 60 mph

[Very similar to Shakuntala Devi puzzles to puzzle you problem no: 38 ]

9.A lady goes for shopping. She bought some shoestrings. 4 times the number of shoestrings, she bought pins and 8 times, handkerchiefs. She paid each item with their count as each piece's cost. She totally spent Rs. 3.24.How many handkerchiefs did she buy? (repeated from previous papers)

10. Complete the series :

a) 3,6,13,26,33,66,____(repeated from previous papers)

b) 364,361,19,16,4,1,___( " " " )

Ans: a) 63

b) 1

11. Lucia is a wonderful grandmother. Her age is between 50 and 70.Each of her sons have as many sons as they have brothers. Their combined number gives Lucia?s age. What is the age?

Ans: 64

12.There are two towers A and B. Their heights are 200ft and 150ft respectively and the foot of the towers are 250ft apart. Two birds on top of each tower fly down with the same speed and meet at the same instant on the ground to pick a grain. What is the distance between the foot of tower A and the grain?

Ans:90ft

13 Grass in lawn grows equally thick and in a uniform rate. It takes 40 days for 40 cows and 60 days for 30 cows to eat the whole of the grass. How many days does it take for 20 cows to do the same?

Ans: 120

13. Four tourists A,B,C,D and four languages English, German, French and Italian. They are not able to converse among themselves in one language. Though A does not know English he can act as an interpreter between B and C. No one spoke both French and German. A knows German and was able to converse with D who doesn?t know a word in German. Only one language was spoken by more than two persons. Each spoke two languages. Find who spoke what.

Ans: A- German,Italian

B- French,Italian

c- German,English

D- Italian,English

14. There is a five digit number. It has two prime digits (1 is not a prime number). Third digit is the highest. Second digit is the lowest. First digit is one less than the third digit. The fifth digit is half of the fourth. The sum of 4th and 5th is less than the first. Find the number.

Ans ? 71842

15.6. Four persons A, B, C and D are playing cards. Each person has one card, laid down on the table below him, which has two different colours on either side. No card has the same color on both sides. The colours visible on the table are Red, Green, Red and Blue respectively. They see the color on the reverse side and give the following comment.

A: Yellow or Green

B: Neither Blue nor Green

C: Blue or Yellow

D: Blue or Yellow

Given that out of the 4 people 2 always lie find out the colours on the cards each person.

Ans: A- Yellow

B- Yellow

C- Green

D- Red

16. A 1 k.m. long wire is held by n poles. If one pole is removed, the length of the gap becomes 12/3m. What is the number of poles initially?

Ans:6km

17. Find the digits X,Y,Z

X X X X

Y Y Y Y +

Z Z Z Z

--------------

Y X X X Z

----------------

Ans: X Y Z

9 1 8

18. A man starts walking at 3 pm . ha walks at a speed of 4 km/hr on level ground and at a speed of 3 km/hr on uphill , 6 km/hr downhill and then 4 km/hr on level ground to reach home at 9 pm. What is the distance covered on one way?

Ans: 12 km

19. 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

20. 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?

21. 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

22. 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

23. A person is 80 years old in 490 and only 70 years old in 500 in which year is he born?

Ans: 470

24.A person says that their speed while going to a city was 10mph however while returning as there is no much traffic they came with a speed of 15mph. what is their average speed?

Ans: 12mph

25. There is a peculiar island where a man always tells truth and a women never says two 2 consecutive truth or false statements that is if she says truth statement then she says false statement next and vice versa. A boy and girl also goes in the same way. one day i asked a child " what r u a boy or a girl" however the
child replied in their language that i dint understand but the parents knew my language and one parent replied that " kibi is a boy" the other one said that "no kibi is a girl, kibi lied".

a: is kibi a boy or a girl
b: who ansered first mother or father?

Ans: kibi is a girl and mother answered first.

26. The boy goes to school reaches railway station at his 1/3 of his journey& mill at 1/4 of his journey the time taken him to walk between railway station & mill is 5 mins. Also he reaches railway station at 7.35amwhen he started from house& when he reaches school?

Ans: 7:15to8.15

27. if a person is sitting in a exam having 30 questions (objective type) the examiner use the formula to calculate the score is S=30+4c-w here c is number
of correct answer and w is number of wrong answer , the examiner find the score is more than 80, tell how may questions are correct ? if the score is little less
but still more than 80 then u wont be able to answer.

Ans:- 16

28. if a person having 1000 rs and he want to distribute this to his five children in the manner that ecah son having 20 rs more than the younger one , what will
be the share of youngest child

ans- 160

29.raju having some coins want to distribute to his 5 son , 5 daughter and driver in a manner that , he gave fist coin to driver and 1/5 of remaining to first
son he again gave one to driver and 1/5 to 2nd son and so on.... at last he equally distributed all the coins to 5 daughters. how many coins raju initially have???

Ans:-881

30.if ravi binded his book and the binder cut the pages of the book , ravi decided to mark the pages by himself own , what he found that number of three
appears 61 times find of number of pages answer

ans - 300

31. a painter went in a exhibition to purchases some pictures where T,U,V,W,X,Y,Z pictures were remaining , he want to buy only five in the condition on that
if T is there then X should not be there,
if U is there than y should be there
if if v is there then X should be there

which is the combination the painter can have
(a) T,U,V,W,Y
(b)T,Z,U,W,X
(c)T,X,U,V,W
(d)T,U,Y,W,Z

ans (d)

32.There are 100 men in town. Out of which 85% were married, 70% have a phone, 75% own a car, 80% own a house. What is the maximum number of people who are married, own a phone, own a car and own a house ? ( 3 marks)

Sol: 15%

33. There are 10 Red, 10 Blue, 10 Green, 10 Yellow, 10 White balls in a bag. If you are blindfolded and asked to pick up the balls from the bag, what is the minimum number of balls required to get a pair of atleast one colour ? ( 2 Marks)

Sol :6 balls.

34. Triplet who usually wear same kind and size of shoes, namely, Annie, Danny, Fanny. Once one of them broke a glass in kitchen and their shoe prints were there on floor of kitchen. When their mother asked who broke Annie said, ?I didn?t do it?; Fanny said ?Danny did it?; Danny said ?Fanny is lieing?; here two of them are lieing, one is speaking truth. Can you find out who broke it ? (3 Marks)

Sol : Annie

35. 4 players were playing a card game. Cards had different colours on both sides. Neither of cards had same colour on both sides. Colours were 2 Red, 2 Blue, 2 Green, 2 Yellow. Cards were lying in front of each player. Now, each player knew the colour on other side of his card. They are required to tell their colour.
Statement given by each of them was :

Annie : Blue or Green
Bobby : Neither Blue nor Green
Cindy : Blue or Yellow
Danny : Blue or Yellow
colours of cards that are visible to all were Red, Blue, Green, Blue in order of their names. Exactly two of them are telling truth and exactly two of them are lieing. Can you tell the colour on other face of card for each player ? (6 Marks)

Sol : Annie : Yellow (Lieing)
Bobby : Yellow (Telling truth)
Cindy : Blue (Telling truth)
Danny : Green (Lieing)

36. In a game i won 12 games, each game if i loose i will give u one chocolate, You have 8 chocolates how many games played.

Ans: 32

38. 75 persons Major in physics, 83 major in chemistry, 10 not at major in these subjects u want to find number of students majoring in both subjects

Ans 68.

39. if A wins in a race against B by 10 mts in a 100 Meter race. If B is behind of A by 10 mts. Then they start running race, who will won?

Ans A

40. A+B+C+D=D+E+F+G=G+H+I=17 given A=4.Find value of G and H?

Ans: G = 5 E=1

41. One guy has Rs. 100/- in hand. He has to buy 100 balls. One football costs Rs. 15/, One Cricket ball costs Re. 1/- and one table tennis ball costs Rs. 0.25 He spend the whole Rs. 100/- to buy the balls. How many of each balls he bought?

Ans:F=3,T=56,C=41

42. The distance between Station Atena and Station Barcena is 90 miles. A train starts from Atena towards Barcena. A bird starts at the same time from Barcena straight towards the moving train. On reaching the train, it instantaneously turns back and returns to Barcena. The bird makes these journeys from Barcena to
the train and back to Barcena continuously till the train reaches Barcena. The bird finally returns to Barcena and rests. Calculate the total distance in miles the bird travels in the following two cases:
(a) The bird flies at 90 miles per hour and the speed of the train is 60 miles per hour.
(b) the bird flies at 60 miles per hour and the speed of the train is 90 miles per hour

Ans: time of train=1hr.so dist of bird=60*1=60miles

43. A tennis championship is played on a knock-out basis, i.e., a player is out of the tournament when he loses a match.
(a) How many players participate in the tournament if 15 matches are totally played?
(b) How many matches are played in the tournament if 50 players totally participate?

Ans: (a)16
(b)49

44.When I add 4 times my age 4 years from now to 5 times my age 5 years from now, I get 10 times my current age. How old will I be 3 years from now?

Ans:Age=41 years.

45.A rich merchant had collected many gold coins. He did not want anybody to know about them. One day, his wife asked, "How many gold coins do we have?" After pausing a moment, he replied, "Well! If I divide the coins into two unequal numbers, then 37 times the difference between the two numbers equals the difference between the squares of the two numbers." The wife looked puzzled. Can you help the merchant's wife by finding out how many gold R

Ans:37

46. A set of football matches is to be organized in a "round-robin" fashion, i.e., every participating team plays a match against every other team once and only once. If 21 matches are totally played, how many teams participated?

Ans:7

47. Glenn and Jason each have a collection of cricket balls. Glenn said that if Jason would give him 2 of his balls they would have an equal number; but, if Glenn would give Jason 2 of his balls, Jason would have 2 times as many balls as Glenn. How many balls does Jason have?

Ans: 14

48. Suppose 8 monkeys take 8 minutes to eat 8 bananas.
a) How many minutes would it take 3 monkeys to eat 3 bananas?
(b) How many monkeys would it take to eat 48 bananas in 48 minutes

Ans: a)48
B)6

49. It was vacation time, and so I decided to visit my cousin's home. What a grand time we had!
In the mornings, we both would go for a jog. The evenings were spent on the tennis court. Tiring as these activities were, we could manage only one per day, i.e., either we went for a jog or played tennis each day. There were days when we felt lazy and stayed home all day long. Now, there were 12 mornings when we did nothing, 18 evenings when we stayed at home, and a total of 14 days when we jogged or played tennis. For how many days did I stay at my cousin's place?

Ans: 22 days

50. A 31" x 31" square metal plate needs to be fixed by a carpenter on to a wooden board. The carpenter uses nails all along the edges of the square such that there are 32 nails on each side of the square. Each nail is at the same distance from the neighboring nails. How many nails does the carpenter use?

Ans:124

## What do you Need?

If your server supports PHP you don't need to do anything.
Just create some .php files in your web directory, and the server will parse them for you. Because it is free, most web hosts offer PHP support.

However, if your server does not support PHP, you must install PHP.
Here is a link to a good tutorial from PHP.net on how to install PHP5: http://www.php.net/manual/en/install.php

## Lesson 3: Using Loops In C programming

Loops are used to repeat a block of code. Being able to have your program repeatedly execute a block of code is one of the most basic but useful tasks in programming -- many programs or websites that produce extremely complex output (such as a message board) are really only executing a single task many times. (They may be executing a small number of tasks, but in principle, to produce a list of messages only requires repeating the operation of reading in some data and displaying it.) Now, think about what this means: a loop lets you write a very simple statement to produce a significantly greater result simply by repetition.

One caveat: before going further, you should understand the concept of C's true and false, because it will be necessary when working with loops (the conditions are the same as with if statements). This concept is covered in the Previous Tutorial. There are three types of loops: for, while, and do..while. Each of them has their specific uses. They are all outlined below.

All the above loops are explained with syntax and examples

## Break and Continue Kyewords (Importance and How to use)

Two keywords that are very important to looping are break and continue.
The break command will exit the most immediately surrounding loop regardless of what the conditions of the loop are. Break is useful if we want to exit a loop under special circumstances. For example, let's say the program we're working on is a two-person checkers game. The basic structure of the program might look like this:

```while (true)
{
take_turn(player1);
take_turn(player2);
}```

This will make the game alternate between having player 1 and player 2 take turns. The only problem with this logic is that there's no way to exit the game; the loop will run forever! Let's try something like this instead:

```while(true)
{
if (someone_has_won() || someone_wants_to_quit() == TRUE)
{break;}
take_turn(player1);
if (someone_has_won() || someone_wants_to_quit() == TRUE)
{break;}
take_turn(player2);
}```

This code accomplishes what we want--the primary loop of the game will continue under normal circumstances, but under a special condition (winning or exiting) the flow will stop and our program will do something else.

Continue is another keyword that controls the flow of loops. If you are executing a loop and hit a continue statement, the loop will stop its current iteration, update itself (in the case of for loops) and begin to execute again from the top. Essentially, the continue statement is saying "this iteration of the loop is done, let's continue with the loop without executing whatever code comes after me." Let's say we're implementing a game of Monopoly. Like above, we want to use a loop to control whose turn it is, but controlling turns is a bit more complicated in Monopoly than in checkers. The basic structure of our code might then look something like this:

```for (player = 1; someone_has_won == FALSE; player++)
{
if (player > total_number_of_players)
{player = 1;}
if (is_bankrupt(player))
{continue;}
take_turn(player);
}```

This way, if one player can't take her turn, the game doesn't stop for everybody; we just skip her and keep going with the next player's turn.

## Do-While Loop inc C Programming (syntax and Example)

DO..WHILE - DO..WHILE loops are useful for things that want to loop at least once.

The structure is
` `
`do `
`{ `
``` } while ( condition );
```

Notice that the condition is tested at the end of the block instead of the beginning, so the block will be executed at least once. If the condition is true, we jump back to the beginning of the block and execute it again. A do..while loop is almost the same as a while loop except that the loop body is guaranteed to execute at least once. A while loop says "Loop while the condition is true, and execute this block of code", a do..while loop says "Execute this block of code, and then continue to loop while the condition is true".

Example:
```#include <stdio.h>

int main()
{
int x;

x = 0;
do ```
```  {
/* "Hello, world!" is printed at least one time
even though the condition is false */
printf( "Hello, world!\n" );
} while ( x != 0 );
getchar();
} ```
Keep in mind that you must include a trailing semi-colon after the while in the above example. A common error is to forget that a do..while loop must be terminated with a semicolon (the other loops should not be terminated with a semicolon, adding to the confusion). Notice that this loop will execute once, because it automatically executes before checking the condition.

## Using For Loop in C Programming Syntax and Simple Program

FOR - for loops are the most useful type. The syntax for a for loop is

`for ( variable initialization; condition; variable update ) `
```{
Code to execute while the condition is true
}```
The variable initialization allows you to either declare a variable and give it a value or give a value to an already existing variable. Second, the condition tells the program that while the conditional expression is true the loop should continue to repeat itself. The variable update section is the easiest way for a for loop to handle changing of the variable. It is possible to do things like x++, x = x + 10, or even x = random ( 5 ), and if you really wanted to, you could call other functions that do nothing to the variable but still have a useful effect on the code. Notice that a semicolon separates each of these sections, that is important. Also note that every single one of the sections may be empty, though the semicolons still have to be there. If the condition is empty, it is evaluated as true and the loop will repeat until something else stops it.

Example:
```#include <stdio.h>

int main()
{
int x;
/* The loop goes while x < 10, and x increases by one every loop*/
for ( x = 0; x < 10; x++ ) ```
```    {
/* Keep in mind that the loop condition checks
the conditional statement before it loops again.
consequently, when x equals 10 the loop breaks.
x is updated before the condition is checked. */
printf( "%d\n", x );
}
getchar();
} ```
This program is a very simple example of a for loop. x is set to zero, while x is less than 10 it calls printf to display the value of the variable x, and it adds 1 to x until the condition is met. Keep in mind also that the variable is incremented after the code in the loop is run for the first time.

## Different characteristics of Capability Maturity Model (CMM)

Capability maturity model or CMM as it is often abbreviated. It is a development model developed after a prolonged study of the data collected from various organizations from all over the world.

Characteristics of Capability Maturity Model
1.The development of this model was funded by the USDD (United States department of defence).

2.The capability maturity model became the foundation for the development of software engineering institute or SEI as it is popularly known as.

3.The term “maturity” emphasises process optimization and level of formality.

4.Processes are optimized from ad-hoc practices to steps that have been formally defined.

5.Nowadays this model is being used effectively for management of result metrics.

6.Capability maturity model has proved to be great help in active optimization of the processes.

7.This model allows improvement in the development processes of an organization.

8.It is an effective and good approach towards improvement of any organization’s development processes.

9.This model is securely based upon the frame work of process maturity which was developed in 1989.

10.Initially it was used for objective assessment of the processes carried out by the contractors of the government to keep a track on the project.

11.CMM is not only used in the field of software engineering but, it is also applied to organizational processes of a business.

12.It is used in other fields like:
- Software development
- System engineering
- Software maintenance
- Project management
- System acquisition
- Risk management
- Information technology
- Human capital management and
- Services

Where is Capability Maturity Model used?

Capability maturity model is being extensively used in various organizations like in commerce, government offices, software development organizations and industry.

What was the need for Capability Maturity Model?
- In the 20th century the use of computers was wide spread.

- Computerized processes were thought to be less costly, effective and flexible way to carry out tasks.

- As more and more organizations started adopting computerized processing systems, the demand for software development eventually rose.

- As a result CMM was developed, of course with lots of failures.

- The computers were a new technology at that time and so there was a lot of pressure on developers to deliver quality products within a stipulated period of time.

- The US military was in havoc that because all their projects were running out of budget and time.

- So in order to know the reason behind all this, they funded the study at SEI. Active study started at SEI.

- It was watts Humphrey who actually came up with the actual idea of CMM.

- He based his approach on the evolution of software development practices.

- He concentrated on all the processes as one instead of concentrating on just one software development process.

- Since then the CMM has become popular among various organizations and is used as a powerful tool for improving overall performance of the business.

Though CMM proved to be a very effective tool for business but many times it caused problems in software development.

- CMM didn’t allow use of multiple software development practices. It was superseded by CMMI.

- These days still the capability maturity model is being used as the model with the capability of handling general processes when it comes to public domain.

1.CMM is still maintaining its position as a model of maturity of process.

2.CMM provides a place to start the development.

3.It uses a common language and the development is based upon a shared vision.

4.It effectively develops a frame work for actions according to their priority.

5.For an organization it defines the ways for improvement.

6.It is used an aid for better and effective understanding.

CMM has 5 aspects:
- Maturity level
- Key process area
- Goal
- Features
- Practices.

## While Loop in C Programming (Syntax and Example)

WHILE - WHILE loops are very simple.
The basic structure is

while ( condition )
Code to execute while the condition is true
}

The true represents a boolean expression which could be x == 1 or while ( x != 7 ) (x does not equal 7). It can be any combination of boolean statements that are legal. Even, (while x ==5 || v == 7) which says execute the code while x equals five or while v equals 7. Notice that a while loop is like a stripped-down version of a for loop-- it has no initialization or update section. However, an empty condition is not legal for a while loop as it is with a for loop.

Example:
```#include <stdio.h>

int main()
{
int x = 0;  /* Don't forget to declare variables */

while ( x < 10 ) ```
```  { /* While x is less than 10 */
printf( "%d\n", x );
x++;             /* Update x so the condition can be met eventually */
}
getchar();
} ```
This was another simple example, but it is longer than the above FOR loop. The easiest way to think of the loop is that when it reaches the brace at the end it jumps back up to the beginning of the loop, which checks the condition again and decides whether to repeat the block another time, or stop and move to the next statement after the block.

## Basic If Syntax

The structure of an if statement is as follows:
```if ( statement is TRUE )
Execute this line of code
```
Here is a simple example that shows the syntax:
```if ( 5 < 10 )
printf( "Five is now less than ten, that's a big surprise" );
```

Here, we're just evaluating the statement, "is five less than ten", to see if it is true or not; with any luck, it's not! If you want, you can write your own full program including stdio.h and put this in the main function and run it to test.

To have more than one statement execute after an if statement that evaluates to true, use braces, like we did with the body of the main function. Anything inside braces is called a compound statement, or a block. When using if statements, the code that depends on the if statement is called the "body" of the if statement.

For example:
```if ( TRUE ) {
/* between the braces is the body of the if statement */
Execute all statements inside the body
}
```
I recommend always putting braces following if statements. If you do this, you never have to remember to put them in when you want more than one statement to be executed, and you make the body of the if statement more visually clear.

## Else

Sometimes when the condition in an if statement evaluates to false, it would be nice to execute some code instead of the code executed when the statement evaluates to true. The "else" statement effectively says that whatever code after it (whether a single line or code between brackets) is executed if the if statement is FALSE.

It can look like this:
```if ( TRUE ) {
/* Execute these statements if TRUE */
}
else {
/* Execute these statements if FALSE */
}
```

## Else if

Another use of else is when there are multiple conditional statements that may all evaluate to true, yet you want only one if statement's body to execute. You can use an "else if" statement following an if statement and its body; that way, if the first statement is true, the "else if" will be ignored, but if the if statement is false, it will then check the condition for the else if statement. If the if statement was true the else statement will not be checked. It is possible to use numerous else if statements to ensure that only one block of code is executed.

Let's look at a simple program for you to try out on your own.
```#include <stdio.h>

int main()                            /* Most important part of the program!
*/
{
int age;                          /* Need a variable... */

scanf( "%d", &age );                 /* The input is put in age */
if ( age < 100 ) {                  /* If the age is less than 100 */
printf ("You are pretty young!\n" ); /* Just to show you it works... */
}
else if ( age == 100 ) {            /* I use else just to show an example */
printf( "You are old\n" );
}
else {
printf( "You are really old\n" );     /* Executed if no other statement is
*/
}
return 0;
}
```

## Lesson 2: Using If statements in C, C++

### Basic Syntax of IF - ELSE Statement in C , C++ with example

The ability to control the flow of your program, letting it make decisions on what code to execute, is valuable to the programmer. The if statement allows you to control if a program enters a section of code or not based on whether a given condition is true or false. One of the important functions of the if statement is that it allows the program to select an action based upon the user's input. For example, by using an if statement to check a user-entered password, your program can decide whether a user is allowed access to the program.

Without a conditional statement such as the if statement, programs would run almost the exact same way every time, always following the same sequence of function calls. If statements allow the flow of the program to be changed, which leads to more interesting code.

Before discussing the actual structure of the if statement, let us examine the meaning of TRUE and FALSE in computer terminology. A true statement is one that evaluates to a nonzero number. A false statement evaluates to zero. When you perform comparison with the relational operators, the operator will return 1 if the comparison is true, or 0 if the comparison is false. For example, the check 0 == 2 evaluates to 0. The check 2 == 2 evaluates to a 1. If this confuses you, try to use a printf statement to output the result of those various comparisons (for example printf ( "%d", 2 == 1 );)

When programming, the aim of the program will often require the checking of one value stored by a variable against another value to determine whether one is larger, smaller, or equal to the other.

There are a number of operators that allow these checks.

Here are the relational operators, as they are known, along with examples:
```>     greater than              5 > 4 is TRUE
<     less than                 4 < 5 is TRUE
>=    greater than or equal     4 >= 4 is TRUE
<=    less than or equal        3 <= 4 is TRUE
==    equal to                  5 == 5 is TRUE
!=    not equal to              5 != 4 is TRUE
```
It is highly probable that you have seen these before, probably with slightly different symbols. They should not present any hindrance to understanding. Now that you understand TRUE and FALSE well as the comparison operators, let us look at the actual structure of if statements.

## What is the difference between scripted testing and exploratory testing?

Though exploratory testing and scripted are considered being a part of each other, there is a lot of difference between the two.

The scripted testing is performed by a set of test scripts which can be defined as a set of instructions that are to be performed on the software system or application under the test to test a particular functionality as required.

There are following ways of executing test scripts:

1. Automated testing:
- It can be easily repeated and is faster than manual testing.
- It is very useful when it is required to run the same tests over and over again.
- It is performed as a part of regression testing.
- Automated tests are poorly written and they may break during the execution.
- They only test what has been programmed into them.
- They only ensure that old bugs do not reappear.
- Manual testing and automated testing should be mixed together and used for exploratory testing.

2. Manual testing:
- This is the oldest and the most rigorous forms of testing.
- The test cases are reviewed by the whole testing team before using them.
- The test cases are either created at the basic functionality level or at the scenario level.

3. Short programs or test scripts written in a programming language (C#, C++, expect, TCL, java, Perl, PHP, python, power shell) or a special automated functional GUI test tool (like Borland silk test, HP quick professional test, rational robot etc) can be used to test functionality of a software system or application.

4. Short programs that have been extensively parameterized or data driven testing.

5. Table driven testing or keyword driven testing i.e., using reusable tests created in a table.

CHARACTERISTICS OF SCRIPTED TESTING
- Scripted testing is considered to be as a waste of resources by most of the testers.

- According to them the scripted manual testing inhibits the mind of the tester to use their creativity.

- Also, this testing requires heavy documentation as well as considerable amount of resources to create them.

- They often get out dated since the changes in the system are inevitable.

- Though being so criticized manual scripted testing is used by many organizations.

- The test cases are made repeatable and easy enough for a tester to perform testing with minimum supervision.

- Manual scripted testing is used in contracts where contractual agreement states that written requirements and specifications of the software must be met.

- Scripted test cases are useful where the tests are used as benchmark and have to be executed in the same way, every time.

CHARACTERISTICS OF EXPLORATORY TESTING
- In contrast to scripted testing, exploratory testing is a usual approach to software testing and can be defined as a test designing, test execution and simultaneously learning process.

- Exploratory testing is a kind of software testing that is emphasized and focused up on the responsibility and the personal freedom of the software tester.

- Exploratory testing is a kind of software testing that is emphasized and focused up to optimize the quality and effectiveness of his /her work continually by taking in to consideration mutually supportive activities like test designing, test related learning, test result interpretation and test execution.

- The activities run in parallel to each other.

- Exploratory testing basically heeds to exploiting the creativity of the tester or the programmer.

- During the testing of the software, the tester comes across various new things to learn together with experiencing them.

- Exploratory testing can be thought of as a black box testing methodology or technique instead of thinking of it as an approach to testing that can be used for any type of testing methodology and also at any phase of development of the software system or application.

## What kind of Applications You Can Write with C#

The .NET Framework has no restrictions on the types of applications that are possible, as discussed
earlier. C# uses the framework and therefore has no restrictions on possible applications. However,
here are a few of the more common application types:

Windows applications. Applications, such as Microsoft Office, that have a familiar Windows
look and feel about them. This is made simple by using the Windows Forms module of the
.NET Framework, which is a library of controls (such as buttons, toolbars, menus, and so on)
that you can use to build a Windows user interface (UI). Alternatively, you can use Windows
Presentation Foundation (WPF) to build Windows applications, which gives you much greater
flexibility and power.

Web applications. Web pages such as those that might be viewed through any Web browser.
The .NET Framework includes a powerful system for generating Web content dynamically,
enabling personalization, security, and much more. This system is called ASP.NET (Active
Server Pages .NET), and you can use C# to create ASP.NET applications using Web Forms.
You can also write applications that run inside the browser with Silverlight.

Web services. An exciting way to create versatile distributed applications. Using Web services
you can exchange virtually any data over the Internet, using the same simple syntax
regardless of the language used to create a Web service or the system on which it resides. For
more advanced capabilities, you can also create Windows Communication Foundation (WCF)
services.

Any of these types may also require some form of database access, which can be achieved using the
ADO.NET (Active Data Objects .NET) section of the .NET Framework, through the ADO.NET Entity
Framework, or through the LINQ (Language Integrated Query) capabilities of C#. Many other
resources can be drawn on, such as tools for creating networking components, outputting graphics,
performing complex mathematical tasks, and so on.

## .net(dotNet) Framework Platform Architecture

.Net Framework Platform Architecture :
C# programs run on the .NET Framework, an integral component of Windows that includes a virtual execution system called the common language runtime (CLR) and a unified set of class libraries. The CLR is the commercial implementation by Microsoft of the common language infrastructure (CLI), an international standard that is the basis for creating execution and development environments in which languages and libraries work together seamlessly.

Source code written in C# is compiled into an intermediate language (IL) that conforms to the CLI specification. The IL code and resources, such as bitmaps and strings, are stored on disk in an executable file called an assembly, typically with an extension of .exe or .dll. An assembly contains a manifest that provides information about the assembly's types, version, culture, and security requirements.
When the C# program is executed, the assembly is loaded into the CLR, which might take various actions based on the information in the manifest. Then, if the security requirements are met, the CLR performs just in time (JIT) compilation to convert the IL code to native machine instructions. The CLR also provides other services related to automatic garbage collection, exception handling, and resource management. Code that is executed by the CLR is sometimes referred to as "managed code," in contrast to "unmanaged code" which is compiled into native machine language that targets a specific system. The following diagram illustrates the compile-time and run-time relationships of C# source code files, the .NET Framework class libraries, assemblies, and the CLR.
Language interoperability is a key feature of the .NET Framework. Because the IL code produced by the C# compiler conforms to the Common Type Specification (CTS), IL code generated from C# can interact with code that was generated from the .NET versions of Visual Basic, Visual C++, or any of more than 20 other CTS-compliant languages. A single assembly may contain multiple modules written in different .NET languages, and the types can reference each other just as if they were written in the same language.
In addition to the run time services, the .NET Framework also includes an extensive library of over 4000 classes organized into namespaces that provide a wide variety of useful functionality for everything from file input and output to string manipulation to XML parsing, to Windows Forms controls. The typical C# application uses the .NET Framework class library extensively to handle common "plumbing" chores.

## Introduction to the C# Language

C# is an elegant and type-safe object-oriented language that enables developers to build a variety of secure and robust applications that run on the .NET Framework. You can use C# to create traditional Windows client applications, XML Web services, distributed components, client-server applications, database applications, and much, much more. Visual C# 2010 provides an advanced code editor, convenient user interface designers, integrated debugger, and many other tools to make it easier to develop applications based on version 4.0 of the C# language and version 4.0 of the .NET Framework.

C# Language:

C# syntax is highly expressive, yet it is also simple and easy to learn. The curly-brace syntax of C# will be instantly recognizable to anyone familiar with C, C++ or Java. Developers who know any of these languages are typically able to begin to work productively in C# within a very short time. C# syntax simplifies many of the complexities of C++ and provides powerful features such as nullable value types, enumerations, delegates, lambda expressions and direct memory access, which are not found in Java. C# supports generic methods and types, which provide increased type safety and performance, and iterators, which enable implementers of collection classes to define custom iteration behaviors that are simple to use by client code. Language-Integrated Query (LINQ) expressions make the strongly-typed query a first-class language construct.
As an object-oriented language, C# supports the concepts of encapsulation, inheritance, and polymorphism. All variables and methods, including the Main method, the application's entry point, are encapsulated within class definitions. A class may inherit directly from one parent class, but it may implement any number of interfaces. Methods that override virtual methods in a parent class require the override keyword as a way to avoid accidental redefinition. In C#, a struct is like a lightweight class; it is a stack-allocated type that can implement interfaces but does not support inheritance.
In addition to these basic object-oriented principles, C# makes it easy to develop software components through several innovative language constructs, including the following:
• Encapsulated method signatures called delegates, which enable type-safe event notifications.
• Properties, which serve as accessors for private member variables.
• Language-Integrated Query (LINQ) which provides built-in query capabilities across a variety of data sources.
If you have to interact with other Windows software such as COM objects or native Win32 DLLs, you can do this in C# through a process called "Interop." Interop enables C# programs to do almost anything that a native C++ application can do. C# even supports pointers and the concept of "unsafe" code for those cases in which direct memory access is absolutely critical.
The C# build process is simple compared to C and C++ and more flexible than in Java. There are no separate header files, and no requirement that methods and types be declared in a particular order. A C# source file may define any number of classes, structs, interfaces, and events.

The following are additional C# resources:

## How to write Resume ? Tips

Words are the name of the game when it comes to resumes, and job seekers need to be strategic in their choice of them. Many of us often use keywords on our resumes, but how do you know which words to choose and which ones to leave out? In answer to those questions, we’ve compiled a brief list of some of the most overused words on resumes. Avoid them whenever possible and choose a more creative alternatives. After knowing which words to avoid, you’ll be ready to construct an eye-catching resume.

1. Accomplished. Yes, we all know every job seeker is accomplished, otherwise you would have been fired from every job you’d ever had if you never accomplished anything. Instead try: peak performer.

2. Results-Driven. Everyone’s professional resume starts out with “Results-driven (insert your job title here)”. The only problem is, in the job-search game you don’t want to sound like everyone else; you want to stand out from the crowd. Instead try: performance-driven.

3. Successful. This is another overused word. We all want to communicate how successful we’ve been so a new employer will think highly of us, but consider some alternative wording versus coming out and saying “hey there, I’m a success.” Instead try: best in class, award-winning, or top performer.

4. Skillful or Skilled. These are so boring; I hate to see resumes with these words on them. I’m sure you can come up with something much more creative for your resume. If you can’t think of anything, try my recommendations, or if you don’t like them use a thesaurus. Instead try: talented, sharp, or resourceful.

5. Problem-Solver. Isn’t this a given? We’re ALL problem solvers; if you’re human, you’re a problem solver. Does it really need to be said on your resume? I think not. Instead try: troubleshooter, forward-thinking, or visionary leader.

6. And last but not least Dedicated and Dependable. Again I have to say boring, boring, boring. Spice up your resume with something creative. Instead try: high potential, quality-driven, or dynamic.

As a job seeker, what are some other words that you think are overused on resumes these days?

## Hashing line segments C Program Code

Below the information to understand the program completely.

Input:
R = a rectangular region with bottom-left corner at (0,0) and top-right corner at (X,Y), X and Y being user-specified.
n = Number of line segments whose endpoints have integer coordinates and lie in R.
Task:  Use hashing to store the line segments one by one in a suitable data structure T. While generating, the two endpoints of each segment should be randomly selected and a newly generated segment should be inserted in T only if it is not already there in T.

#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<malloc.h>

typedef struct nodetype
{
int x1;
int x2;
int y1;
int y2;
struct nodetype *next;
}node;

node* lastnode(node *);
int findduplicate(node **,int,int,int,int,int);
void display(node **,int);

main()
{
int X,Y,x1,y1,x2,y2,n,i=0,j,c,exist,s=1;
node  **A=NULL,*ptr=NULL,*last=NULL;

printf(“*****************************************************************************\n”);
printf(“\t\tPROGRAM:\tHASHING LINE SEGMENTS\n”);
printf(“\t\tPROGRAMMER:\tKALPATARU MALLICK\n”);
printf(“*****************************************************************************\n”);

printf(“\n Enter the Second co-orinates of the Rectangle as integer value (X,Y) respectively :”);
scanf(“%d%d”,&X,&Y);
printf(“\n Enter the no. of segments must be less than or equals to (Y+1)^2*(Y+1)^2-2(X+1)*(Y+1) :\n”);
scanf(“%d”,&n);

A=(node **)malloc(sizeof(node *)*n);
for(j=0;j<n;j++)
A[j]=NULL;

while(i<n)
{
x1=rand()%(X+1);
y1=rand()%(Y+1);
x2=rand()%(X+1);
y2=rand()%(Y+1);
if((x1!=x2)||(y1!=y2))
{
exist = findduplicate(A,n,x1,x2,y1,y2);
if(exist==0)
{
i++;
ptr=(node *)malloc(sizeof(node));
ptr->next=NULL;

ptr->x1=x1;
ptr->x2=x2;
ptr->y1=y1;
ptr->y2=y2;

c=rand()%n;

if(A[c]==NULL)
{
A[c]=ptr;
}
else
{
last=lastnode(A[c]);
last->next=ptr;
}
}
}
}
printf(“\n\nThe cordinates of all segments are:\n “);
display(A,n);
printf(“\n”);
}

int findduplicate(node **A,int n,int x1,int x2,int y1,int y2)
{
int j;
for(j=0;j<n;j++)
{
if (A[j] == NULL)
continue;
{
{
return 1;
}
}
}
return 0;
}

{
{
}
}

void display(node **A,int n)
{
int k;
if(n==0)
printf(“\n no segments created\n”);
for(k=0;k<n;k++)
{
printf(“\n%d”,k+1);
if(A[k]!=NULL)
{
{
}
}
}
}

Note :The Above code is compiled on a linux environment

Share your review and thoughts with us

## Searching using system calls Program in C Code

Write a C program that takes a file name as a command line parameter and sorts a set of integers stored in the file (use any sorting method). You can assume that the file will always be there in the current directory and that it will always contain a set of integers(maximum no. of integers is 1000). The sorted output is written to the display and the input file is left unchanged. Compile the C file into an executable named “sort1″. Now write a C program that implements a command called “sort” that you will invoke from the shell prompt. The syntax of the command is “sort “. When you type the command, the command opens a new xterm window, and then sorts the integers stored in the file using the program “sort1″. Look up the man pages for xterm, fork and the different variations of exec* calls (such as execv, execve, execlp etc.) to do this assignment.

#include<stdio.h>

int main(int argc, char *argv[])
{

FILE *fp1;
int A[1000],T[1000];
int j,i=0;

/* check that we have a file name specified as a command-line argument */
if (argc<2)
{
printf(“\nPlease enter filename as argument when running this program.\n”);
printf(“For example: listprog file.txt\n\n”);
return -1;
}

fp1= fopen(argv[1], “r”);
if (!fp1)
{
printf(“\nUnable to open file: %s; exiting.\n\n”, argv[1]);
return -2;
}

for(j=0;(j<1000)&&(feof(fp1)== 0);j++)
{
if(feof(fp1)== 0)
{
fscanf(fp1,”%d”,&A[j]);
i++;
}
else
printf(“\nError”);
}

sort(A,i);
display(A,i);
fclose(fp1);

return 0;
}

display(int A[],int n)
{
int i;
for(i=0;i<n;i++)
printf(“\n%d”,A[i]);

}

sort(int a[],int n)
{
int i,j,t;
for(i=n-2;i>=0;i–)
{
for(j=0;j<=i;j++)

{
if(a[j]>a[j+1])
{
t=a[j];
a[j]=a[j+1];
a[j+1]=t;
}
}

}

}

## Algorithm Design PPT PDF SLIDES

Algorithm Design PDF SLIDES

Author: Kevin Wayne
Text Book: Algorithm Design by Jon Kleinberg and Ã‰va Tardos.