A company is planning a big sale at which they will give their customers a special promotional discount. Each customer that purchases a product from the company has a unique customerID numbered from 0 to N-1. Andy, the marketing head of the company, has selected bill amounts of the N customers for the promotional scheme. The discount will be given to the customers whose bill amounts are perfect squares. The customers may use this discount on a future purchase. Write an algorithm to help Andy find the number of customers that will be given discounts?
Answers
Answered by
0
Answer:0
Explanation:POGGIES
Answered by
0
C Program
#include<stdio.h>
#include<math.h>
int PerfectSquareBill(int n)
{
int integerValue;
float floatVaue;
floatVaue=sqrt((double)n);
integerValue=floatVaue;
if(integerValue==floatVaue)
return 1;
else
return 0;
}
int main(){
int CustomerBillAmounts[9] = {36, 100, 40, 18, 16, 54, 81, 48, 49};
int i, c = 0;
for(i=0; i<9; i++){
if(PerfectSquareBill(CustomerBillAmounts[i])== 1){
c +=1;
}
}
printf("%d", c); //Displaying the number of customers with perfect squares that will be given the discounts
}
- The definition of an array in C is a way to group together several items of the same type. These things or things can have data types like int, float, char, double, or user-defined data types like structures.
- A variable that can hold numerous values is called an array. You could make an array for it, for instance, if you wanted to store 100 integers. This method is used to determine the square root of the parameter supplied to it, int data[100].
#SPJ2
Similar questions