Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Retrieve the index of a float number in two differents arrays in c

Status
Not open for further replies.

john120

Banned
Joined
Aug 13, 2011
Messages
257
Helped
11
Reputation
22
Reaction score
10
Trophy points
1,298
Activity points
0
Hello can you help me to think how I can retrieve a float number in when I change the below arrays into float?I am retrieving the index using to enter an integer number but when I use to change the arrays to float type and enter a float number I am getting errors:
see the code below:
main()
{
// float k[10]={2, 4, 6, 8, 10,12,14,16,18,20};
//int j[10]={3,5,7,9,11,13,15,17,19,21};

const int k[]={10,12,17,22,27,32,37,42,47,52,57,62,67,72,77,82};
const int j[]={13,15,20,24,31,35,40,45,50,55,60,65,70,75,80,85};


int i,t;
int q;
printf("Enter any number Q\n");
scanf("%d",&q);




for(t=0;t<16;t++)
{
for(i=0;i<16;i++)
{

if((q<=j[t])&&(q>=k[t])&&(t==i))
{
printf("%dis present at location %d. \n",q,i+1 );
break;

}
}

}

}

This program operate as follows:when I enter a number for example 14;the index is 2 because 12<=14 and 14,=15;
69;the index is 13 because 67<=69 and 69<=70;
and so on;so what I want is to use float numbers in the above arrays and retrieve the index of that float number using the above structure:

Please help.

Thanks.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top