- #1
akueddy
- 14
- 0
Hi,
I tried to assign inputs to a particular output and I've got some funny results. In this code
ive change the value of rpm to into the address of arrays that I've set. The adress correspond to the delay time for spark to occur.
Heres my c code :
And here's the output :
My questions :
1) Why is the output's value equals to data stored in array 2 when clearly the input(1000) was suppose to point in array 1?
2) Why do i get 8000 microseconds when it is suppose to be 0 microseconds?
I tried to assign inputs to a particular output and I've got some funny results. In this code
ive change the value of rpm to into the address of arrays that I've set. The adress correspond to the delay time for spark to occur.
Heres my c code :
Code:
#include <stdio.h>
void main()
{
int n,x;
int Array[8] = { 5, 4, 3.5, 2, 1.5, 1, 0.5, 0};
int *pArray;
printf("what is the RPM of the engine? 0-8000\n");
scanf("%d", &n);
x = n/1000 ;
pArray = &Array[x];
printf("Spark will be produce at : %d microseconds before top dead centre\n",*pArray);
}
And here's the output :
Code:
C:\Borland\BCC55\Bin>bcc32 pointers5
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
pointers5.cpp:
Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
C:\Borland\BCC55\Bin>pointers5
what is the RPM of the engine? 0-8000
500
Spark will be produce : 5 microseconds before top dead centre
C:\Borland\BCC55\Bin>pointers5
what is the RPM of the engine? 0-8000
1000
Spark will be produce : 4 microseconds before top dead centre
C:\Borland\BCC55\Bin>pointers5
what is the RPM of the engine? 0-8000
7999
Spark will be produce : 0 microseconds before top dead centre
C:\Borland\BCC55\Bin>pointers5
what is the RPM of the engine? 0-8000
8000
Spark will be produce : 8000 microseconds before top dead centre
C:\Borland\BCC55\Bin>
My questions :
1) Why is the output's value equals to data stored in array 2 when clearly the input(1000) was suppose to point in array 1?
2) Why do i get 8000 microseconds when it is suppose to be 0 microseconds?