User Tools

Site Tools


qna:lab-session:code2
#include <stdio.h>
 
int findInArray(
       double value,
       int N,
       double a[N]
) {
    for (int i = 0; i < N; ++i) {
        if (a[i] == value) {
            return i;
        }
    }
    return -1;
}
 
int main() {
    double X[] = {1.2, 3.4, 5.6, 7.8};
    double someValue = 3.4;
 
    int index = findInArray(someValue, 4, X);
 
    printf("Found at position %d, value %lf\n", index, someValue);
 
    return 0;
}
qna/lab-session/code2.txt · Last modified: 2024/04/24 15:34 by xallos