Basic question !! please help!!!

+1 Shantanu Odak · December 5, 2015
I try to build and run this program and the following error occures!!! my code is this


#include <stdio.h>
#include <stdlib.h>

void main()
{
    int a;

   printf("\t  ENTER THE VALUE OF NUMBER\n");
   scanf("%d",a);
   if (a>=18)
   {
     printf("YOU ARE ELIGIBLE TO VOTE");
   }
else
{
    printf("YOU RE NOT ELIGIBLE TO VOTE");
}
}

/images/forum/upload/2015-12-05/db93639c18201988e70b831a1b8b5142.png

Post a Reply

Replies

Oldest  Newest  Rating
0 Ossama Memon · December 29, 2015
you forgot ampersand &. write & before a in scanf
0 Linguist Llama · December 27, 2015
It isn't an easy error to miss, since your compiler is probably warning you about this... Perhaps more time reading the warnings and less time asking people to read the warnings for you would be a good idea?
0 Sharath Krishna · December 16, 2015
YOU MISSED THE & SYMBOL IN THE SCANF FUNCTION BEFORE 'a'
0 Raghav Gupta · December 7, 2015
Try giving space between the double inverted comas and %d
0 Shantanu Odak · December 7, 2015
Such a silly mistake.Thank you!!
0 Eryk Humberto Oliveira Alves · December 6, 2015
like c.student said, you have to put:
scanf("%d",&a);

The reason why you have to do it is because &a represent the address of the variable.
The job of scanf is to go to that memory address and change the value that that address is giving.
It's important that you understand the meaning of &, because you will use it a lot if you are studying C.
0 Denis Balaj · December 6, 2015
The valid one, attention: put & before a in your scanf;

#include <stdio.h>
#include <stdlib.h>

int main(){

      int a;
      printf("\t ENTER THE VALUE OF NUMBER\n");
      scanf(" %d",&a);

      if (a>=18){
            printf("YOU ARE ELIGIBLE TO VOTE");
      }else{
            printf("YOU RE NOT ELIGIBLE TO VOTE");
      }
      return 0;
}
0 c student · December 6, 2015
scanf ("%d", &a);
  • 1

C

107,073 followers
About

One of the most popular languages of all time.

Links
Moderators
Bucky Roberts Administrator