Decimal to N-Base Conversion
Hide problem statement «
Problem statement
N-base notation is a system for writing numbers which uses only n
different symbols. These symbols are the first n symbols from the
given notation list (including the symbol for o). Decimal to n-base
notations are (0:0, 1:1, 2:2,13:3, 4:4, 5:5, 6:6, 7:7, 8:8, 9:9, 10:A,
11:B and so on up to 35:Z.
Implement the following function:
def DectonBase (nu num)
BOLLE
The function accepts positive integers in and num'. Implement the
function to calculate n-base equivalent of 'num' and return the same
as a string.
Steps:
1. Divide the decimal number num by n. Treat the division as
an integer division,
2 Write down the remainder (in n-base notation)
3. Divide the quotient again by in. Treat the division as an
integer division,
4. Repeat step 2 and 2 until quotient is a
5. The n-base value is the sequence of the remainders from the
Masco
Assumption = 36
Example:
IN DEN
Answers
Answer:
Problem statement
Implement the following function:
float CumulativeDiscount(float arr[], int n);
The function accepts a float array'arr' comprising n' discount
percentages applied on marked price of an object. Order of discounts
in 'arr' is same in which discounts are applied on the object. Implement
the function to calculate the cumulative discount percentage and
return the same
Discounted price = Marked Price * (100 - discount%)/100
Discount% = 100 - (Discounted Price * 100 / Marked Price)
For, eg, if marked price is $100 and discounts 10%, 20%, 30% are
applied in this sequence then,
After 10% discount, price = $100 (100 - 10) / 100 = $90
After 20% discount, price = $90 * (100 - 20) / 100 = $72
After 30% discount, price = $72 * (100 - 30) / 100 = $50.4
For final discounted price, discount% = 100 - (50.4 * 100 / 100)
49.60%
Thus, cumulative discount% is 49.60%.
Assumption:
+ n 20
0 =< Discount% < 100
Consider marked price to be $100
Note: Do not round off your result, it will be automatically rounded off
up to 2 decimal places and then displayed.
Sample Input
arr: 40.00 20.00
.
Sample Output
52.89
Answer:
#include<stdio.h>
#include<string.h>
#include<conio.h>
int main(){
int n,num,i=0;
int arry[10];
scanf("%d",&n);
scanf("%d",&num);
int div,qtion,rem;
qtion=num/n;
rem=num%n;
arry[0]=rem;
i++;
while(qtion!=0){
num=qtion;
qtion=num/n;
rem=num%n;
arry[i]=rem;
i++;
} int j=0;
for(j=i-1;j>=0;j--){ if (arry[j]>=10){char value=arry[j]+55;
printf("%c",value);}
else{ printf("%d",arry[j]);
}
}
return 0;
}
Step-by-step explanation: not use fuction but you can modifid it and do that to