Community

C Program Scanf Err...
 
Notifications
Clear all

C Program Scanf Error


CR7
Posts: 1
 CR7
Topic starter
(@cr7)
New Member
Joined: 3 months ago

When i run the program i get error as given below. I don't know what to do now

main.c: In function ‘main’:
main.c:14:28: error: invalid operands to binary & (have ‘int *’ and ‘int’)
     scanf("%d, %d, %d", &a &b &c);
                         ~~ ^

My program is

#include <stdio.h>

int main()
{
    int a,b,c;
    scanf("%d, %d, %d", &a &b &c);
    int sum = a+b+c;
    printf("%d",sum);
    return 0;
}

 

Topic Tags
1 Reply
Sree Hari Sanjeev
Posts: 2
(@sree-hari-sanjeev)
Member
Joined: 3 years ago

You have misplace comma in your program. try this

int main()
{
int a,b,c;
scanf("%d %d %d", &a, &b, &c);
int sum = a+b+c;
printf("%d",sum);
return 0;
}

Reply
Share: