Sapient Programming Questions |   10704

Sapient Programming Questions

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<<words<<" ";

getch();
}<<"]:";
<<"]:";

<<"]:";
<<"]:";

 

feedback