+ 1

Why this programme shows error at output?

#include<stdio.h> int main( ) { int a,x=2,3,4,5; a=1,2,3,4,5; printf("%d%d",x,a); return 0; }

16th Sep 2020, 6:57 PM
Anusha
Anusha - avatar
2 Antworten
+ 5
Actually you have included headerfile wrongly . When you defined values int a,x=2,3,4,5; here 2 is assigned to x but 3,4,5; where these value will store . May be some Compilers won't give warnings or errors but its wrong to define values randomly in one variable . So its error
16th Sep 2020, 7:03 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 1
x =2,3,4,5; here 2 is assigned to x but 3,4 5 are missing their letf operand.. So syntax error.. x = (2,3,4,5); works. Also for a = (1,2,3,4,5); Here x=2, x=3, x=4,x=5 happens so finally x retains value 5. And still give warning as 2,3,4 are unused values.. Edit: header not studio, it is stdio.h
16th Sep 2020, 7:02 PM
Jayakrishna 🇮🇳