#cant figure it out

35 messages · Page 1 of 1 (latest)

fleet tusk
#

what the

kind dust
#

i saw the n which was supposed to be nn

fleet tusk
#

yeah, but your code needs help urgently

#

there are many things wrong in this code @kind dust

#

like main function should return 0

kind dust
#

oh i am new to c

fleet tusk
#
#include <stdio.h>

int func() {
  int x = 0;
  int y = 0;
  int z = 0;
  int n = 0;
  printf("Enter N");
  scanf("%d", &n);

  if (x < n) {
    x++;
    y += 2;
  }

  return x;
}

int main() {
  int someInt = func();
  printf("%d", someInt);

  return 0;
}
#

this code would be better i think

#

what's the pourpose of this code?

fleet tusk
#
#

These are good sources to start

kind dust
#

thankkku

kind dust
fleet tusk
#

oh okay

#

if you need help don't be afraid to ask

kind dust
#

okayyyy thanks alot u are the man

#

"#include <stdio.h>

int func() {
int x = 1;
int y = 1;
int z = 0;
int n = 0;
printf("Enter N");
scanf("%d", &n);

while (x < n) and ((y+2) < n-1)
z += z + x/z
x += 1;
y += 2;
}

return x;
}

int main() {
int someInt = func();
printf("%d", someInt);

return 0;
}

fleet tusk
#
#include <stdio.h>

int func() {
  int x = 1;
  int y = 1;
  int z = 0;
  int n = 0;
  printf("Enter N");
  scanf("%d", &n);

  while ((x < n) && ((y + 2) < n - 1)) {
    z += x / z;
    x++;
    y += 2;
  }

  return x;
}

int main() {
  int someInt = func();
  printf("%d", someInt);

  return 0;
}
#

@kind dust

#

remember close parenthesis

#

and if you use "+=" there's no need to use x +

kind dust
#

What is the int main in the last lines

#

The second one u made I think

fleet tusk
#

int main() is the main function

#

int means it returns an int number

#

and is on it where you should place all functions or vars to run code

fleet tusk
#

here's more information

kind dust
#

Ur code doesn’t run

#

/tmp/ZNjtYJGcrf.c:16:1: error: expected identifier or '(' before 'return'
16 | return x;
| ^~~~~~