TCS
Company
Programming
Program
The power of compounding
Manish has realized the power of compounding. Since the days he started earning, he has diligently set aside a small corpus which he saves from his monthly salary and deposits in his bank account. Bank pays him interest every month. Manish is also a determined investor and refrains from withdrawing anything from this account because he now believes in power of compounding. Given investment corpus, fixed annual rate of interest and maturity period calculate the amount the Manish will end up saving at the end of his tenure.
Input Format:
First line contains investment corpus P
Second line contains rate of interest per annum R
Third line contains tenure T (in months)
Output Format:
Print the maturity amount after specified tenure in the format "Final_Amount "
Constraints:
P > 0 ; it can be float value
R >=0 ; it can be float value
T >0 ; it can be integer only
Calculation should be done upto 11-digit precision
Maturity amount should be printed, rounded off to its nearest integer value
Read Solution (Total 4)
-
- #include
#include
int main(void) {
float P,R,r,a,b,d,e,c;
int T;
scanf("%f",&P);
scanf("%f",&R);
while(scanf("%d",&T)==1)
{
r=R/100;
a=((float)1+(r/(float)12));
b=pow(a,T);
c=b*P;
e=c*(float)T;
}
if(getchar()==EOF)
{
printf("Final_Amount %.fn",round(e)-1);
}
else
{
printf("Invalid Inputn");
}
return 0;
} - 8 years agoHelpfull: Yes(0) No(3)
- #include
#include
#include
#include
void main()
{
float P,R,r,a,b,d,e,c;
int T;
clrscr();
scanf("%f",&P);
scanf("%f",&R);
while(scanf("%d",&T)==1)
{
r=R/100;
a=((float)1+(r/(float)12));
b=pow(a,T);
c=b*P;
e=c*(float)T;
d=ceil(e);
}
if(d>0)
{
printf("Final_Amount %f",d-2);
}
else
{
printf("invalid input");
}
getch();
} - 8 years agoHelpfull: Yes(0) No(0)
- #include
main()
{
int i,j,n;
printf("enter num of lines u want");
scanf("%d",&n);
for(i=1;i - 7 years agoHelpfull: Yes(0) No(0)
- #include
#include
float calInterest()
{
const int n=12;
float tot=0, p , r;
int t;
scanf("%f",&p);//principal
scanf("%f",&r);//rate of interest percentage
scanf("%d",&t);//tenure or duration in months
if(p - 5 years agoHelpfull: Yes(0) No(0)
TCS Other Question
Between Devil and Deep Sea
A band of pirates have made loot. By their misfortune though, instant Karma is delivered. While they are travelling a treacherous route in the high and the deep seas they are also haunted by a devil, perhaps a spirit who suffered at their hands previously. The pirates now have to make tricky decisions. They run forward to save themselves from the Devil, but the deep seas force them backwards. There is a danger of falling in a whirlpool if they move forward rashly and there is a danger of being caught by the Devil if they move too much back. But move they must.
First they recede backwards B meters and then advance forward F meters, in a straight line. They cover 1 meter in T units of time. This backward and forward movement is performed repeatedly by the Pirates because they have panicked.
Your task is to find out if they will perish at the hands of the Devil or they will get sucked into the whirlpool of the Deep Sea and in how much time. It is also possible that by good fortune they might survive. Write a program to calculate the outcome
Data Decryption
Data is encrypted in order to maintain security. Encrypted data format and corresponding decryption procedure is described below.
A Data Record consists of exactly two lines. Each Record has exactly two 'F' characters. The first 'F' character acts as field delimiter. The second 'F' character marks the end of the Record. First 'F' characters can be present in either of the two lines. However, the second 'F' is always present only in the first line. Also, since the second 'F' character marks end of the record, it is always the last character of the first line.
The decryption procedure is explained using an example Record
13F6803F
2457959
Note the following things
The Record is comprised of two lines
The Record has 2 'F' characters
The second 'F' character appears as the last character in first line
The length of the first line is one character more than the length of the second line
Other than 'F's, the lines can contain only numeric characters
Data has to be read in following order from left to right
Read first character of first line
Then, read first character of second line
Then, read second character of first line
Then read second character of second line
So on and so forth in zig-zag manner until the first 'F' character is encountered
Replace the first 'F' by | (pipe) symbol
So the first field which is now decrypted is 1234, based on the example above
Continue reading rest of the record by following steps 1 - 4
When second 'F' character is encountered, the record is said to be completely read and we have obtained our second field value as 567890539
Your task is to decrypt set of records. The Input and Output sections below specify how the input has to be read and how the output has to be written.
Input Format:
File Name, where file contains records (recollect that each Record is comprised of 2 lines)
Output Format:
Print the decrypted data delimited by pipe symbol ('|')
Constraints:
There can be maximum 100 records in the input file
The Record length including characters in both lines may not exceed 25