0
#include <stdio.h>
#include <conio.h>
#include <math.h> 
 // +-*/
void readArray(int *a, int n) //fuctie care citeste un tablou
{
    for(int i=0; i<n; i++) 
    {
        printf("A[%i]=",i);
        scanf("%i",&a[i]);
    }
}

void printArray(int *a, int n)
{
    for(int i=0; i<n; i++)
    {
        printf("%i ",a[i]);
    }
}

void patratPerfect(int *a,int n)
{
    for(int i=0; i<n; i++)
    {
        int _sqrt = sqrt(a[i]);
        if(pow(_sqrt,2) == a[i])
        {
            printf("%i ",a[i]);
        }
    }
}

bool putereNumarului(int nr,int nrP)
{
    for(int i=1; i<nr; i++)
    {
        if(pow(nr,i) == nrP)
            return true;
    }

    return false;
}

void putere5(int *a,int n)
{
    for(int i=0; i<n; i++)
    {
        if(putereNumarului(5,a[i]))
            printf("%i ",a[i]);
    }
}

int main(int argc,char* argv[])
{
    int a[10];
    readArray(a,10);
    printArray(a,10);
    printf("\nPatrate perfecte:\n");
    patratPerfect(a,10);
    printf("\nPuterea cinciului:\n");
    putere5(a,10);
    getch();
    return 0;

The error is on line 34

Edited by dan1992: n/a

3
Contributors
4
Replies
6
Views
5 Years
Discussion Span
Last Post by Stazloz
0

IT would be helpful if you actually stated what the error was, but I suspect it's due to using bool (as well as true and false ) either in C90 mode or in C99 mode while failing to include <stdbool.h>. But please note that being able to spot that has nothing to do with your completely unhelpful question, which is why you should work a little harder to help others help you.

Edited by Narue: n/a

0

I use Turbo C, it gives me syntax error and is not included stdbool.h

0

If you use Turbo C then C99 features are not available. Your version of C does not support the bool data type at all. You must simulate it's behavior with another integer type:

int putereNumarului(int nr,int nrP)
{
    for(int i=1; i<nr; i++)
    {
        if(pow(nr,i) == nrP)
            return 1;
    }
 
    return 0;
}
0

Use:
#define true 1
#define false 0
at the beginning of your source.
You would be surprised by the amount of compilers that do not provide full c99 support.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.