Computer Science, asked by pratip427, 8 months ago

Date.
Write
a program to accept 10 different decimal num.
bers in a single dimensional array (say A) Truncate
the fractional part of each number of the array A
and store their integer part in another arday (say B)​

Answers

Answered by SP85
1

To store 10 numbers

import java.util.Scanner;

public class KboatSDANumbers

{

public void displayNumbers() {

Scanner in = new Scanner(System.in);

int arr[] = new int[10];

System.out.println("Enter 10 numbers");

for (int i = 0; i < arr.length; i++) {

arr[i] = in.nextInt();

}

for (int i = 0; i < arr.length; i++) {

if (arr[i] < 0)

System.out.print(arr[i] + ", ");

}

for (int i = 0; i < arr.length; i++) {

if (arr[i] >= 0)

System.out.print(arr[i] + ", ");

}

This is truncade

#include<iostream.h>

#include<conio.h>

int main()

{

float x;

int a[15],b[15];

clrscr();

cout<<"\nEnter the number:";

cin>>x;

int y=x;

float z=(x-y);

cout<<"\nInteger part :"<<y;

cout<<"\nFractional part :"<<z;

getch();

return 0;

}

}

}

So please follow me for any helps

Similar questions