SAPIENT DRIVE AT 14 THROUGH AMCAT FOR 2017 BATCH CALL BASED THROUGH AMCAT

SAPIENT DRIVE AT 14 THROUGH AMCAT FOR 2017 BATCH CALL BASED THROUGH AMCAT

DRIVE DATE 14 -4-2018

2870, Building Virgo, Bagmane Constellation Business Park, Outer Ring Road, Doddanekundi Circle, Marathahalli, Bengaluru, Karnataka 560037

FOR INTERVIEW PATTERN CHECK THESE LINKS

Sapient has a very lenghty process for campussing. It has 3 steps:

1. Online Aptitude 2. Tech/Domain interview 3. HR interview 1) Online Aptitude. It contained four sections. * English * Quantitative Aptitude * Technical Aptitude * Logical Ability (Reasoning) 2) Tech interview. They asked questions mainly from Data Structure and C++. They were simple like Sorting(algo+program), Linked List, Polymorphism, Abstraction, Encapsulation, factorial. They also gave some puzzles like Tower of Hanoi, 8 Queen problem, no of squares. It was about an hour long interview. They rate every student out of 10 with overall cut-off 7 and cut-offs in both sections. It was quite easy and they were very friendly. HR interview: It was very easy.they asked questions like * What will you do if you get stuck in some program? * My partner and I were given a task. we both did it in different processes. What will I do then to solve the problem? * How do I update myself? * They also asked about projects and VTs. * They even asked to solve some reasoning questions like Complete dearrangement, no of squares. They mainly want to see your approach to a problem and your willingness to learn. I got the job. Hope my experience will help you to get a job too.
******************************************************************************************

There were 3 rounds for recruitment process.

1) Online Aptitude

2) Technical Round

3) HR round

You will get the questions one by one on the screen. Once you go to the next one, you can’t come back. No negative marking was there.

Online Aptitude: It contained four sections.

English: There were 25 questions that had to be solved in 25 min. Questions were related to Error finding, Synonyms and Ant synonyms, Comprehension.

Questions were not too tough, if you are little bit well in English, you can solve the problems easily. Comprehension was on last.

Quantitative Aptitude: You will have to solve 25 questions in 35 min, You can refer to R.S Aggarwal book.

Hide quoted text: Questions were on Logarithmic, time and distance, pipes and Cistern, Time and Work, Boat Streams, Trains, Permutation-Combination.
Technical Aptitude: It also contained 25 questions to be solved in 35 min, Questions were related to C outputs, Pointers, C++, Sorting related to time complexity, stable sorting.

Logical Ability (Reasoning): It also contained 25 questions that had to be solved in 35 min. Those were not tough, you can solve those easily. Questions were related to Blood relation, series, Directions, Sentences arrangement, Word arrangement, Statement Conclusion.

Cut off was 500 out of 600. I don’t know how they calculated 600. They gave some relaxation in English section and changed the cut off from 500 to 450.

8 were selected in first round. They started the technical round just after the announcement.
Technical round: In technical rounds they asked questions related to C, Data structure, C++, OOPs concept, Some puzzles, You don’t need to go deep for those all. Actually they were looking at our problem solving abilities. If you don’t know answers just Say I don’t know but your expression must have to be right.

They asked the questions like.

There are 9 cubes, 8 of them are of same sizes, one is slightly heavier, You have to find which one is heavier, you can use anything but whatever you use, you cannot use more than three times. Use Weight machine.

How can you print the values of nodes of a binary tree on the level basis? Use BFS approach

There is a single linked list, you can traverse till second last node and you have to print the node values in reverse order.
Array Implementation of stack.

Class and example of a class related to table

Two ropes of height 50 m are tied with the roof of a building of height 40 m, You have to cut the maximum ropes in height. There is no stair.

1) What is virtual function?

2) What is Hash Table?
3) Difference between DBMS and RDBMS.

6 were selected for HR round.

HR Round:

In HR round, They asked the questions like
1) Tell me something about urself, your academics, your family background, your hobbies, your interest?

2) How was your technical round?

3) Why did you get fewer marks in +2 as I have just 58.77% in +2?

4) Where do you see urself after 3 years?

5) Where do you see urself after 5 years?

6) Have you ever worked in a Team?

7) What problems did you face in the team?

8) How did you solve the problems?

9) How did you manage your team? As I was the team leader.

10) How do you solve a problem?

11) Give me real life example that will show how do you solve problem?

12) Why Sapient?

13) How do you get the information related to industries?

Recently, what is happening in Industry? I said “Barak Obama is opposing the outsourcing” as one of my answer, then they asked

14) Then what should we do?
*************************************************************************************************************************************************

Sapient placement papers questions interview procedure Sapient selection procedure consists written test AMCAT Test Technical tests and technical and hr interview procedure

Sapient selection procedure
AMCAT Test -Aptitude, Reasoning, English,C,C++,basic concepts,

Sapient domain round test questions

The next round was a domain round in which he asked these kind of questions.

1) Tell me about yourself?

2) Describe your project?

3) What is the difference between C and C++?

4) What is the difference between for and while loop?

5) Write a program to add two numbers without using + operator.

6) How to you reverse a string without using any looping and inbuilt functions?

7) How many queues will you use to implement a priority queue?

8) Which datastructure would you use to implement an heteregenous array?

Now it was time for Puzzles which had more weightage I guess.

1) You are given a match-box and two candles of equal size, which can burn 1 hour each. You have to measure 90 minutes with these candles. (There is no scale or clock). How do you do?
********************************************************************************************************************************************************************

Hiring Process:
Step 1: Technical Exercise
This consists of 2 problems which can be solved using C or C++ or JAVA. Our focus will be on your problem comprehension and problem solving ability and also your coding skills. You will have one hour to complete this test, so please factor in the time constraint and plan out your approach accordingly. You will be attempting this exercise on paper (not on a computer).

Step 2: Papers are evaluated and the students short listed

Step 3: Short listed students go through a second technical exercise followed by interview at a later date.

The company will be giving a compensation of 3.5 lacs p.a. and sapient offers tremendous career growth to graduates joining us straight from campus. Its a very good company. We were given a booklet on which we had our question to be solved and also pages attached to write the coding. The paper was as given below.

Instructions:
1. Write appropriate comments for your code wherever required.
2. Focus on the approach & demonstrate problem comprehension & logic.
3. Assume anything required & clearly indicate your assumptions.

Ques:-
A organization named Simboisys(I don’t remember the exact name)…. conducts exams for student at its exam centers. The students enroll there exam date and centre from organizations website. There are three exam centers of this organization and given below are the details required of the students enrolling for the exams on the website. The students will be asked for his/her choice of exam centre in increasing order as mentioned below.

Exam Centers:-
Centre A
Centre B
Centre C

Student Attributes:-
Name
Date of exam
First choice
Second choice
Third choice

a) Define the class/structure
b) Write a function allotexamcenter() for allotting the exam center to the enrolling student and pass Candidate[] as a parameter to the function allotexamcenter ().
public float allotexamcenter (Candidate[])

Note: Don’t write any input functions such as main() & assume that the data structures have already been defined.

Remember:
Always while writing the solution in the paper mention the logic clearly before or after writing the code. Also give proper comments in the code and clearly mention the assumptions that you have taken while coding.

I have given the first technical paper of Sapient and I m waiting for the results that will be declared after 3 weeks from date of 1st technical paper through email. Well it again totally depends on luck even though paper goes well only option left is to pray to GOD bcoz campus seletion is totally a game of luck.

Best Luck to all those aspiring for SAPIENT……..
By Chitra
********************************************************************************************************************

Sapient Programming Questions 9707
Sapient Latest Placement paper Programming Questions|Sapient whole Test Paper with answers

Sapient Interview:
You should be strong with C/C++ concepts, OOPs concepts, Data Structures, DBMS, Software Engineering, Operating Systems. They can ask any question from these subjects as a CSE/IT student should be aware with these topics always. They also ask about summer training and other projects which you have done.

Sapient Written:

Watch out all the previous problems of Sapient and try to solve them implementing your own logic. Don’t copy answers from net and other sources as they are fed up with those answers and want new logic or if same logic is used, then a new way of implementing that problem. Prepare at least two solutions of all problems and read carefully question paper as they always use to make some changes in problems. Now days they have started giving new problems. You should be completely clear with your logic and concept as during interview you will be grilled over it mainly. Write comments properly and show some cuttings in your sheet too as it was asked during interview why there is very little cutting in your paper.

Sapient Programming Questions

Program 1. Reservation. there are 67 seats in train . there are only 5 seats in a row and in last row there are only 2 seats. One person can reseve only 5 seat at a time. If person reserving seat , the care is atken that he may get all in row. if seats are not available in row then the arrangement is so that person group get nearby seats. the following class is given public class seat { char name; int seat; boolean isSeatempty } 1.Draw require class digram and object diagram. 2.Write function seatallot(int noofperson) to allocate seat with seat nuber printed for the each name.

Program 2. Stringreplace The forum is going on and administartor find that some people use abusing or bad lnaguage in discussion.so he decided that when he uses such language it was replacedc with beap. question: 1. draw class digram,and use appropriate data structure. 2. write function replacestring()

1) Write a program for the problem: the array of inetegers indicating the marks of the students isgiven, U have to calculate the percentile of thestudents aaccording to this rule: the percentile of a student is the %of no of student having marks less then him. For eg:suppose

Student Marks
A 12
B 60
C 80
D 71
E 30
F 45

percentile of C = 5/5 *100 = 100 (out of 5 students 5 are having marks less then him) percentile of B = 3/5*100 = 60% (out of 5, 3 have markses less then him) percentile of A = 0/5*100 = 0%.

2) The code was given for a problem and u have to identitfy the logical error in it. That was simple. The code was to merge the Danagrams of 2 words. The danagram of a word is the letters of word arranfed insequential order. eg danagram of abhinav is aabhinv. merging of danamagram is to merge the danagrams of 2 or more words such that the highest no of occurance are coming for each alphabet.eg
Paper: Sapient Placement Paper & Pattern 9 April 2008

Round 1:

1) Abusive Words

A message was given in which we have to replace abusive words like (stupid, fool) with # or with other letter. No. of # depends on conditions like it can be equal to the length of the word like stupid is to be replaced with ###### but in my question an abusive word has to be replaced by ### (3 #) only. The word is listed in some look up table in Max_list_word.
Logic will remain same but there will be slight variations, so read the questions carefully.

2) Train Reservation

There are 67 seats in a train in which there are rows of five seats and last row contain only two seats. A person can allocate maximum 5 seats on his name. Also last 2 seats are to be allocated first if reservation for 2 seats is demanded. Also customer should be allocated seats in a row or nearby seats if not possible.
The following class is given
public class seat
{
char name;
int seat;
boolean isSeatempty
}

Write function seatallot(int noofperson) to allocate seat with seat nuber printed for the each name.

Round 2:

1) Compression of a string

Take any string and we have to compress it so it can be passed over a congested network easily. If string is AASSGGTHMMEG then compressed string will be A2S2G2THM2EG. But in my question compressed string should be 2A2S2GTH2MEG. So again read the problem carefully. If compressed string contains letters other than alphabets or digits i.e. if compressed string is like 2A3DY(3!%#^*2@)A2S then all these non alphanumeric characters should be cleaned off.
We have to make functions:
Compress()
Clean()
) Post mail Question

Conditions are given like if you cover some distance you have to pay this amount, if postal weight is this then u have to pay this amount.Thus five to six conditions are given, you have to write the program to get the cost of post-mail per company depending upon its destination and weight.Very simple program just use if and else loop.Given: getdistance() is function which gives you the distance between two cities.

Conditions are:
Weight<15 gm and Distance<100 km then cost=Rs. 5 Additional cost of mail should be calculated according to the following slab Weight 15-50 gm = Rs. 2/gm >50 gm = Rs. 3.5/gm
Distance 100-500 km = Rs. 1/km

>500 km = Rs. 2/km

(Here charges are factious to just give you an idea of the question)
If the cost of the mails exceed Rs. 1000 then 20% discount is offered to the company.

Report has to be generated per company displaying there mail details for a single day.
Mails with weight less than 15 gm and distance less than 100 km are :
Mails with weight 15-50 gm are:
Mails with distance 100-500 km are:
Mails with weight greater than 50 gm are:
Mails with distance greater than 500 km are:
Total cost due to mails to company:
Also mail reports should be printed in sorted order for each company.
Instructions:
Write appropriate comments for your code wherever required.Focus on the approach & demonstrate problem comprehension & logic. Assume anything required & clearly indicate your assumptions.
Qs.1: A company has many employees & each employee is led by only 1 person except for the CEO (who has no boss). The cost to the company of an employee is the sum of his salary plus the cost to the company of all the people led by him. Given is the following structure :
Employee

Data members: Name Salary isBoss nameOfBoss getSalary getName
a) Define the class/structure

b) Write a function getCostToCompany() to calculate the cost to the company of an employee whose name is passed as a parameter to the function getCostToCompany()public float getCostToCompany(String name)
Note: Don’t write any input functions such as main() & assume that the data structures have already been defined.Qs. 2: Generate an ordered sequence of 4 unique alphabets, where an ordered sequence is one which is arranged in ascending alphabetic order.
Eg. Ordered : ABCD, BCHU, KRXZ
Unordered : DCBA, BNMA

Write a program to generate sets of such 4-alphabet sequences.
Note: Don’t write any input functions such as main().

Sapient Technical Question Paper

#include
#include
#include
void compress(char c[],char res[])
{
int count=1;
int i=0,j=0;
while(i
{
if(c!=c[i+1])
{
res[j++]=c;
if(count>=1)
res[j++]=count+’0′;
count=1;
}
else
count++;
i++;
}
res[j-1]=’\0′;
}
void correction(char errormessage[],char correctmessage[])
{
int i=0,j=0;
while(i
{
if((errormessage>=’a’&&errormessage<='z')|| (errormessage>=’A’&&errormessage<='Z')|| (errormessage>=0+’0’&&errormessage<=9+'0')) correctmessage[j++]=errormessage; i++; } } void main() { clrscr(); char c[20]="aaaabbbbjjja",res[20]=" "; compress(c,res); printf("%s",c); printf("\n%s",res); char errormessage[40]="a@3b%5c*1d$4e4",correctmessage[40]=" "; correction(errormessage,correctmessage); printf("\n%s",errormessage); printf("\n%s",correctmessage); getch(); } /* The code was to merge the Danagrams of 2 words. The danagram of a word is the letters of word arranfed in sequential order. eg danagram of abhinav is aabhinv. merging of danamagram is to merge the danagrams of 2 or more words such that the highest no of occurance are coming for each alphabet.eg merging of aabhinv and abbhhixz is aabbhhinvxz. */ #include #include #include void danagram(char c[]) { char temp; for(int i=0;i { for(int j=i+1;j { if(c>c[j])
{
temp=c;
c=c[j];
c[j]=temp;
}
}
}
}
void merge(char c[],char d[],char e[])
{
int i=0,j=0,k=0;
while(i!=strlen(c)-1 || j!=strlen(d)-1)
{
if(c>=d[j])
e[k++]=d[j++];
else
e[k++]=c[i++];
}
while(c!=NULL)
e[k++]=c[i++];
while(d[j]!=NULL)
e[k++]=d[j++];
}
void main()
{
clrscr();
char c[20]=”manoj”,d[20]=”biranchi”,e[40];
danagram(c);
danagram(d);
printf(“%s”,c);
printf(“\n%s”,d);
merge(c,d,e);
printf(“\n After merge =%s”,e);
getch();
}

/*there are 67 seats in train . there are only 5 seats in a row and in lastrow there are only 2 seats. One person can reseve only 5 seat at a time.
If person reserving seat , the care is atken that he may get all in row. if seats are not available in row then the arrangement is so that person group get nearby seats. the following class is given public class seat
{
char name;
int seat;
boolean isSeatempty
}
1.Draw require class digram and object diagram.
2.Write function seatallot(int noofperson)
to allocate seat with seat nuber printed for the each name.
*/
#include
#include
#include
enum boolean{TRUE,FALSE};
class seat
{
char name[50];
int seat;
boolean isSeatempty;
public:
seat()
{
strcpy(name,” “);
isSeatempty=TRUE;
seat=0;
}
boolean isempty()
{
return isSeatempty;
}
void display()
{
cout<<<" ?<< seat=seatno; isSeatempty=FALSE; } }; class berth { seat seat_number[67]; public: void display() { for(int i=0;i<67;i++) { if(i%5==0) cout< cout<<" "< } } void reserve(int numberofseat) { int row; // code if continous seats are available for(int j=0;j<67;j++) { if(j%5==0 &&j>64) //special case of seat no 66 and 67
row=2; // here row contain only 2 seats
else if(j%5==0) // simple case
row=5; // here row contain 5 seats
if(seat_number[j].isempty()==TRUE && row>=numberofseat)
{
seat_number[j].allocate(j+1);
numberofseat–;
if(numberofseat==0)
break;
}
row–;
}
//////////////////////////////////////////
// code if continous seats are not available
if(numberofseat!=0)
{
int i=0,j=0,k=0,index_empty=0,min;
int empty[40]={0}; //seats which are vacant know only list
int diffvalue[40]={0};
//logic of finding seats vacant
for(k=0;k<67;k++) { if(seat_number[k].isempty()==TRUE) empty[i++]=k; } /////////////////////////////// //logic for finding diference between vacant seats for(j=0;j<=(i-numberofseat);j++) { int index=1; for(int n=numberofseat;n!=1;n--) { diffvalue[j]=diffvalue[j]+(empty[j+index]-empty[j+index-1]); index++; } if(j==0) min=diffvalue[0]; if(diffvalue[j] { min=diffvalue[j]; index_empty=j; //gives the minumum value of particular index in the empty list } } ////////////////////////////////////////////////////// // final allocation to nearer seats for( k=0;k { seat_number[empty[index_empty+k]].allocate(empty[index_empty+k]+1); } ////////////////////////////////// } } }; void main() { clrscr(); berth boggy; boggy.reserve(4); boggy.reserve(4); boggy.reserve(3); boggy.reserve(3); boggy.reserve(3); boggy.reserve(3); boggy.reserve(3); boggy.reserve(3); boggy.reserve(5); boggy.reserve(4); boggy.reserve(4); boggy.reserve(4); boggy.reserve(4); boggy.reserve(4); boggy.display(); boggy.reserve(3); boggy.display(); getch(); } #include #include #include char * ones(int X ); char * tens(int X , int Y ); char * copyone(char buff[50],int i) { char temp[50]; strcat(buff,ones(i)); strcpy(temp,buff); return temp; } char * copyten(char buff[50],int i,int j) { char temp[50]; strcat(buff,tens(i,j)); strcpy(temp,buff); return temp; } char * numbertotext(unsigned long int text) { int num,a[11],i ; char temp[200]=" ",buff[50]; for(i=0;text!=0;text=text/10) a[i++]=text%10; for(int t=i-1;t>=0;t–)
cout<<" "< i--; for (;i >= 0;i–)
{
if (a != 0)
{
strcpy(buff,” “);
switch(i)
{
case 0: if (a[1] != 1)
strcat(temp,copyone(buff,a));
break;
case 1: strcat(temp,copyten(buff,a,a[i-1]));
break;
case 2: strcat(temp,copyone(buff,a));
strcat(temp,” hundred”);
break;
case 3: if (a[4] != 1)
{
strcat(temp,copyone(buff,a));
strcat(temp,” Thousand”);
}
else
strcat(temp,” Thousand”);
break;
case 4: strcat(temp,copyten(buff,a,a[i-1]));
if (a[3] == 0)
strcat(temp,” Thousand”);
break;
case 5: if (a[6] != 1)
{
strcat(temp,copyone(buff,a));
strcat(temp,” Lakhs”);
}
else
strcat(temp,” Lakhs”);
break;
case 6: strcat(temp,copyten(buff,a,a[i-1]));
if (a[5] == 0)
strcat(temp,” Lakhs”);
break;
case 7: if (a[8] != 1)
{
strcat(temp,copyone(buff,a));
strcat(temp,” Croes”);
}
else
strcat(temp,” Croes”);
break;
case 8: strcat(temp,copyten(buff,a,a[i-1]));
if (a[7]== 0)
strcat(temp,” Cores”);
break;
case 9: if (a[10] != 1)
{
strcat(temp,copyone(buff,a));
strcat(temp,” Arabs”);
}
else
strcat(temp,” Arabs”);
break;
case 10:strcat(temp,copyten(buff,a,a[i-1]));
if (a[9] == 0)
strcat(temp,” Arabs”);
break;
}
}
}
strcat(temp,” only”);
return temp;
}

char * ones(int X )
{
char stmt[20] ;
switch( X )
{
case 1:strcpy(stmt , “One”);break;
case 2:strcpy(stmt , “Two”);break;
case 3:strcpy(stmt , “Three”);break;
case 4:strcpy(stmt , “Four”);break;
case 5:strcpy(stmt , “Five”);break;
case 6:strcpy(stmt , “Six”);break;
case 7:strcpy(stmt , “Seven”);break;
case 8:strcpy(stmt , “Eight”);break;
case 9:strcpy(stmt , “Nine”);break;
}
return stmt;
}

char * tens(int X , int Y )
{
char stmt[50];
if (X == 1 )
{
switch( Y)
{
case 1:strcpy(stmt, “Eleven”);break;
case 2:strcpy(stmt, “Twelve”);break;
case 3:strcpy(stmt, “Thirteen”);break;
case 4:strcpy(stmt, “Fourteen”);break;
case 5:strcpy(stmt, “Fifteen”);break;
case 6:strcpy(stmt, “Sixteen”);break;
case 7:strcpy(stmt, “Seventeen”);break;
case 8:strcpy(stmt, “Eighteen”);break;
case 9:strcpy(stmt, “Nineteen”);break;
case 0:strcpy(stmt, “Ten”);break;
}
}
else
{
switch( X )
{
case 2:strcpy(stmt, “Twenty”);break;
case 3:strcpy(stmt, “Thirty”);break;
case 4:strcpy(stmt, “Fourty”);break;
case 5:strcpy(stmt, “Fifty”);break;
case 6:strcpy(stmt, “Sixty”);break;
case 7:strcpy(stmt, “Seventy”);break;
case 8:strcpy(stmt, “Eighty”);break;
case 9:strcpy(stmt, “Ninety”);break;
}
}
return stmt;
}
void main()
{
clrscr();
unsigned long int text=2345;
cout<<"Enter the Number :"; cin>>text;
cout<<"\nNumber :"< cout<<"\nText :"; cout< getch(); } /*1) Write a program for the problem: the array of inetegers indicating the marks of the students is given, U have to calculate the percentile of the students aaccording to this rule: the percentile of a student is the %of no of tudent having marks less then him. For eg: suppose Student Marks A 12 B 60 C 80 D 71 E 30 F 45 percentile of C = 5/5 *100 = 100 (out of 5 students 5 are having marks less then him) percentile of B = 3/5*100 = 60% (out of 5, 3 have markses less then him)*/ #include #include # define MAX 6 /*class students { float marks[MAX]; float percentile[MAX]; public: students() { for(int i=0;i { marks=0.0; percentile=0.0; } } students(float marks[MAX]) { for(int i=0;i { this.marks=marks; percentile=0.0; } } void read() { for(int i=0;i { cout<<"Enter the marks of student["<<<"]:"; cin>>marks;
}
}
void display()
{
for(int i=0;i
{
cout.precision(2);
cout<<"\nMarks :"<<<"\T :?< } } void calculate() { float count,same,total; for(int i=0;i { count=0; same=0; total=MAX; for(int j=0;j { if(marks>marks[j])
count++;
if(marks==marks[j])
same++;
}
if(total!=same)
{
total=total-same;
percentile=(count/total)*100;
}
else
percentile=100;
}
}
};*/
void main()
{
clrscr();
float marks[MAX]={10,10,10,10,10,10};
float percentile[6]={0},count,same,total;
for(int i=0;i
{
cout<<"Enter the numbers :"; cin>>marks;
}
for(i=0;i
{
count=0;
same=0;
total=MAX;
for(int j=0;j
{
if(marks>marks[j])
count++;
if(marks==marks[j])
same++;
}
if(total!=same)
{
total=total-same;
percentile=(count/total)*100;
}
else
percentile=100;
cout.precision(2);
cout<<"Marks= "<<<" ?<< << cin>>name;
cout<<"Enter the marks of student["<<<"]:"; cin>>marks;
}
}
void students::display()
{
for(int i=0;i
{
cout.precision(2);
cout<<"\n\nName :"<<<"\NMARKS :?< << } } void students::calculate() { float count,same,total; for(int i=0;i { count=0; same=0; total=MAX; for(int j=0;j { if(marks>marks[j])
count++;
if(marks==marks[j])
same++;
}
if(total!=same)
{
total=total-same;
percentile=(count/total)*100;
}
else
percentile=100;
}
}
void main()
{
clrscr();
float marks[MAX]={20,20,30,10,10,5};
char name[MAX][40]={“a”,”b”,”c”,”d”,”e”,”f”};
students obj(marks,name);
obj.read();
obj.calculate();
obj.display();
getch();
}
/*1) Write a program for the problem: the array ofinetegers indicating the marks of the students is given, U have to calculate the percentile of thestudents aaccording to this rule: the percentile of astudent is the %of no of tudent having marks less then him. For eg:suppose
Student Marks
A 12
B 60
C 80
D 71
E 30
F 45
percentile of C = 5/5 *100 = 100 (out of 5 students 5 are having marks less then him)percentile of B = 3/5*100 = 60% (out of 5, 3 havemarkses less then him)*/#include
#include
void main()
{
clrscr();
int marks[6]={12,60,80,71,30,45};
int percentile[6],more_students_having_marks=0;
int total_student=6-1;
for(int j=0;j<6;j++) { more_students_having_marks=0; for(int i=0;i<6;i++) { if(marks more_students_having_marks++; } percentile[j]=(more_students_having_marks*100)/total_student; } for(int i=0;i<6;i++) cout<<<<" :?< getch(); } #include #include #include #include enum boolean{FLASE,TURE}; class seat { char name[10]; int seatno; boolean isSeatempty; public: void seatallocate(char n[10],int sn) { strcpy(name,n); seatno=sn+1; isSeatempty=FLASE; } seat() { strcpy(name,"\0"); seatno=-1; isSeatempty=TURE; } boolean stateofseat() { return isSeatempty; } void display() { cout<<<" ?; << } cout< } } void displaywithname() { for(int i=0;i<67;i++) { if(i%5==0) cout<<"\n\n"; else cout<<"\t"; if( !b.stateofseat()) b.display(); } } int totalrev() { int no=0; for(int i=0;i<67;i++) { if(b.stateofseat()==0) { no++; } } return no; } void rev(int no,char name[5][10]) { int row=5,totalno,emptyseat[35],sumof[30]={0},next=0; totalno=totalrev(); if(totalno==67) { cout<<"\n NO SEAT IS EMPTY"; getch(); } else if(totalno+no<=67) { for(int i=0;i<67;i++) { if(i%5==0) { if(i==65) row=2; else row=5; } if(b.stateofseat()&&row>=no)
{
b.seatallocate(name[next++],i);
no–;
if(!no)
break;
}
row–;
}
int j=0;
if(no>0)
{
for(int i=0;i<67;i++) { if(b.stateofseat()) { emptyseat[j++]=i; } } int small,index; for(i=0;i<=j-no;i++) { for(int k=1;k { sumof=sumof+(emptyseat[i+k]-emptyseat[i+k-1]); } if(i==0) { small=sumof,index=0; } else if(small>sumof)
{
small=sumof;
index=i;
}
}
for(i=0;i
{
b[emptyseat[index+i]].seatallocate(name[5-no+i],emptyseat[index+i]);
}
}

}
else
{
cout<<"\nLess Number of Seat Left"; getch(); } } }; void main() { boggy b; char name[5][10]={"A12345678","B12345678","C12345678","D12345678","E12345678"}; /* b.rev(2,name); b.rev(4,name); b.rev(2,name); b.rev(3,name); b.rev(4,name); b.rev(3,name); b.rev(3,name); b.rev(4,name); b.rev(4,name); b.rev(4,name); b.rev(3,name); b.rev(3,name); b.rev(4,name); b.rev(3,name); b.rev(3,name); b.rev(2,name); b.rev(1,name); b.rev(2,name); b.rev(5,name); b.rev(5,name); b.rev(2,name); b.display() ; getch(); b.rev(1,name); */ char ch='y'; int no,i; do{ clrscr(); b.display() ; cout<<"\nEnter the Number of Seat(Max of 5 ) : "; cin>>no;
if(no>5)
{
cout<<"\n U Have Enter Wrongh U want to Enter More(y/n) : "; cin>>ch;
continue;
}
for(i=0;i
{
cout<<"\nName : " ; cin>>name;
}
b.rev(no,name);
cout<<"\nDo U want to Enter More(y/n) : "; cin>>ch;
} while(ch!=’n’);
getch();
b.display() ;
b.displaywithname();
getch();
}

/*Qs.1: A company has many employees & each employee is led by only 1 person except for the CEO (who has no boss). The cost to the company of an employee is the sum of his salary plus the cost to the company of all the people led by him. Given is the following structure :

Employee

Data members:
Name
Salary
isBoss
nameOfBoss

Methods:
getSalary
getName

a) Define the class/structure
b) Write a function getCostToCompany() to calculate the cost to the company of an employee whose name is passed as a parameter to the function getCostToCompany()

public float getCostToCompany(String name)

Note: Donn’t write any input functions such as main() & assume that the data
structures have already been defined.*/

#include
#include
#include
enum boolean{TRUE,FALSE};
class Employee
{
char Name[30];
float Salary;
boolean isBoss;
char nameOfBoss[30];
public:
Employee()
{
strcpy(Name,” “);
Salary=0.0;
isBoss=FALSE;
strcpy(nameOfBoss,” “);
}
Employee(char name[30],float s,boolean b,char bossname[30])
{
strcpy(Name,name);
Salary=s;
isBoss=b;
strcpy(nameOfBoss,bossname);
}
Employee(Employee &t)
{
strcpy(Name,t.Name);
Salary=t.Salary;
isBoss=t.isBoss;
strcpy(nameOfBoss,t.nameOfBoss);
}
float getSalary()
{ return Salary;}
char * getName()
{ return Name;}
char * getnameOfBoss()
{ return nameOfBoss;}
void read();
void display();
};
void Employee::read()
{
cout<<"Enter name :" ; cin>>Name;
cout<<"Enter salary :"; cin>>Salary;
cout<<"Enter isboss :" ; cin>>isBoss;
cout<<"Enter boss name :"; cin>>nameOfBoss;
}
void Employee::display()
{
cout<<"Enter name :" ; cout< cout<<"\nEnter salary :"; cout< cout<<"\nEnter isboss :" ; cout< cout<<"\nEnter boss name :"; cout< } class Company { Employee emp[10]; int count; public: Company() { count=0; for(int i=0;i<10;i++) emp; } void read_company() { char ch; do{ emp[count++].read(); cout<<"Continue :"; cin>>ch;
}while(ch!=’n’);
/* Employee t(“1″,100.0f,TRUE,”manoj”);
emp[0]=t;
Employee t1(“2″,200.0f,TRUE,”1”);
emp[1]=t1;
Employee t2(“3″,1000.0f,TRUE,”1”);
emp[2]=t2;
Employee t3(“4″,1000.0f,TRUE,”manoj”);
emp[3]=t3;
count=4;*/
}
void display_company()
{
for(int j=0;j
{
emp[j].display();
cout<<"\n\n"; } } float getCostToCompany(char name[100]); }; float Company::getCostToCompany(char *name) { float ctc=0; for(int temp=0;temp { if(strcmp(emp[temp].getName(),name)==0) ctc=ctc+emp[temp].getSalary(); if(strcmp(emp[temp].getnameOfBoss(),name)==0) ctc=ctc+getCostToCompany(emp[temp].getName()); } return ctc; } void main() { clrscr(); Company obj; obj.read_company(); obj.display_company(); cout< getch(); } /*i'm wrirng in a simple programming style here : in a sentece we have to compare each word from a list and replce it with "###" if it exists in th list.*/ #include #include #include void main() { clrscr(); char msg[200]="they are people who r stupid and dog who used slang which are sucker , f**ker"; cout<<"enter message :"; cin>>
char slangs[10][50]={“stupid”,”dog”,”sucker”,”f**ker”};
char words[40][50];
int i=0,j=0,k=0;
while(msg!=NULL)
{
if(msg!=’ ‘&&msg!=’,’)
words[j][k++]=msg;
if(msg==’ ‘&&msg[i+1]!=’ ‘)
{
words[j][k]=’\0’;
j++;
k=0;
}
i++;
}
for(i=0;i<=j;i++) cout<<<" ?; } } cout< for(i=0;i<=j;i++) cout<