#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

Recommended Answers

All 4 Replies

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.

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

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;
}

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.