Variable n not initaialised | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
27th Mar 2020, 4:57 AM
Akash Deep Deep
Akash Deep Deep - avatar
3 Answers
+ 3
I think it is required to input n instead of a, b, c as a, b, c can be calculated using n. Also, you need to print rev instead of "rev" to check for reversed value of n. //modified code: int n,rev; Scanner sc=new Scanner(System.in); System. out. println("enter any three digit no"); int a,b,c; n=sc.nextInt(); a=n%10; n=n/10; b=n%10; n=n/10; c=n%10; rev=a*100+b*10+c; System.out.println(rev);
27th Mar 2020, 5:58 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 1
You have not assigned any value to n
27th Mar 2020, 5:16 AM
Taranjeet
Taranjeet - avatar
0
It does not require to initialise n
27th Mar 2020, 5:44 AM
Akash Deep Deep
Akash Deep Deep - avatar