Find the error in my code. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
12th Apr 2019, 1:38 PM
Neetu
Neetu - avatar
10 Answers
+ 9
#define is a macro that when used in the expression/statement is replaced. So your statement becomes const int 19 = 7; Which results in an error
12th Apr 2019, 5:12 PM
blACk sh4d0w
blACk sh4d0w - avatar
+ 9
constant value cant be changed
25th May 2019, 4:24 PM
Prashanth Kumar
Prashanth Kumar - avatar
+ 8
#define a 19 const int b = 3 In both cases a y b are constant numbers and you couldn't override them.
12th Apr 2019, 2:59 PM
Javier Felipe Toribio
Javier Felipe Toribio - avatar
+ 8
Constant value does not change
2nd Jun 2019, 7:53 PM
Bharat Bhushan
Bharat Bhushan - avatar
+ 6
You replace a by 19. So in your code really stands written: 19 = 7; And you can't assign a number to another number, only to a name.
12th Apr 2019, 1:58 PM
HonFu
HonFu - avatar
+ 4
You can't redeclare const variable inside int main or anywhere, delete const int a or change a to something else
12th Apr 2019, 1:57 PM
Elva
Elva - avatar
+ 2
You cannot redeclare a preprocessor macro as constant in a function.
13th Apr 2019, 1:16 AM
Nafis
Nafis - avatar
+ 1
You define 'a' as 19 already So no matter you define it constant or anything it take it as 19
13th Apr 2019, 1:22 PM
Tony Stark
Tony Stark - avatar
+ 1
#include <stdio.h> const a=19; int main() { const int a=7; printf("a=%d",a); }U should write const keyword
8th Jun 2019, 5:25 AM
Bittu Kumar
Bittu Kumar - avatar
0
Two problem... 1) u have initiated a macro value named as a and then Changing value to 7 2)int main() should have a return value
30th Aug 2019, 2:05 PM
Satyam Singh
Satyam Singh - avatar