0

Why does the following code displays error???

#include<stdio.h> #include<conio.h> void main(){ int x[]={1,3,5,7,9}; clrscr(); y=x; y=y*2; printf("value is ℅d", *y); getch(); }

21st Nov 2016, 5:57 PM
Sai Nath
Sai Nath - avatar
3 Réponses
+ 4
x is an array of 5 integers and y is not even declared change y=x; into int *y=&x;
21st Nov 2016, 6:13 PM
Burey
Burey - avatar
+ 3
this works removed clrscr() function changed 'y=x;' to 'int* y=x;' changed 'y=y*2;' to 'y=y+2;' #include<stdio.h> #include<conio.h> int main(){ int x[]={1,3,5,7,9}; int* y=x; y=y+2; printf("value is %d", *y); return 0; }
21st Nov 2016, 6:19 PM
Burey
Burey - avatar
0
ok wat if we add int y; as declaration statement....even then it is coming wrong.
21st Nov 2016, 6:16 PM
Sai Nath
Sai Nath - avatar