-8
void functionality()
{
   int ll = 5
   char x = 'A';

   for (int i = 0; i < ll; i++)
   {
      printf("c  ", x);
   }
}

I am learning C language and I wrote the above snippet. However, it is not running with loads of errors. I cannot seem to find the problem of what is happening here since I followed the code from a tutorial and I have double checked everything.

int main()
{
   printf(functionality);
}
dlmeetei
  • 9,905
  • 3
  • 31
  • 38

3 Answers3

4

on the first glance of your code I can see 3 problems:

the line int ll = 5 is missing a ;

AND

the line printf("c ", x); should be printf("%c ", x);

AND

a missing } at the end

For next time, try to also provide the error codes, please.

The main function should look like this:

int main(){
   functionality();
}

The function is void, hence no need to call it in a print statement. Also, we call a function by first stating the name of the function followed by the curly braces. I suggest that you first familiarize yourself with the basic syntax of the language first.

David
  • 1,192
  • 5
  • 13
  • 30
3

These errors are not unknown:

  1. There is no main function, so there's nothing to run.

  2. You are missing a closing } at the end of this function.

  3. You are missing a ; at the end of int ll = 5;

  4. Your printf call is malformed, Did you want printf("%c ", x);?

  5. Where is your #include <stdio.h> (or does your compiler bring that in automatically?).

Bathsheba
  • 231,907
  • 34
  • 361
  • 483
0

you are missing a ; at the end of the line int ll=5

change the c to %c in the printf() function as follows

printf("%c",x);

also make sure you close all the braces properly at the end of the function.

make sure you have a main function in your program,and also include header files