write a program to accept 10 decimal numbers(double data type) in a single dimensional array(say A). Truncate the fractional part of each number of the array and store their integer part in another array(say B). Display both the arrays.
I need it urgently so please answer as soon as possible. Thank you so much!
Answers
Answer:
don't know it's answer
Program is given below.
Explanation:
#include <stdio.h>
int main()
{
double A[10];
int B[10],i;
printf("Enter the values of 10 decimal numbers: \n");
for(i=1;i<=10;i++)
{
scanf("%lf",&A[i]);
}
//Truncating the fractional part of each number of the array A and storing
their integer part in another array B
for(i=1;i<=10;i++)
{
//Here, type casting is done. Double values are converted into int.
B[i]=(int)A[i];
}
//Displaying the values of array A
printf("Values of Array A are: \n");
for(i=1;i<=10;i++)
{
printf("%lf ",A[i]);
}
printf("\n");
//Displaying the values of array B
printf("Values of Array B are: \n");
for(i=1;i<=10;i++)
{
printf("%d ",B[i]);
}
return 0;
}
Refer the attached image for output.