Pls can sm one help debug dis code | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Pls can sm one help debug dis code

#include<stdio.h> #include<conio.h> void main() { float p,r,t,si; printf("Enter Principal(Rupee), Rate(% Per Annum) and Time(Years):"); scanf("%f%f%f",&p,&r,&t); si=(p*r*t)/100; printf("\nSimple Interest= Rs. %f",si); getch(); }

9th Aug 2017, 1:07 AM
Daniel Isaac
Daniel Isaac - avatar
11 Answers
+ 11
#include <iostream> int main() { float p,r,t,si; std::cout << "Enter Principal(Rupee), Rate(% Per Annum) and Time(Years) : "; std::cin >> p >> r >> t; si = (p*r*t)/100; std::cout << "\nSimple Interest= Rs. " << si; return 0; }
9th Aug 2017, 3:47 AM
Hatsy Rei
Hatsy Rei - avatar
+ 8
@sayan chandra conio.h has never been part of the standard library, be it C or C++, and it never will be. "If a C compiler complains about conio, it is not a legit C compiler" would mean all C compilers running on Linux are "not legit". Same goes for void return type for main(). You really have to stop suggesting people to use Turbo C++ (and maybe Google things a bit).
9th Aug 2017, 6:47 AM
Hatsy Rei
Hatsy Rei - avatar
+ 3
main must return int int main () return 0; scanf doesn't run in playground, but does in a computer conio.h is non standard c, getch () may not work
9th Aug 2017, 1:38 AM
Andrés04_ve
Andrés04_ve - avatar
+ 2
First of all main function "must to return" a integer so you need to change void forma int
9th Aug 2017, 1:36 AM
Daniel
Daniel - avatar
+ 2
@sayan maybe his compiler is making a fuss on conio
9th Aug 2017, 5:10 AM
Abdur-Rahmaan Janhangeer
Abdur-Rahmaan Janhangeer - avatar
+ 2
@sayan he must tell which compiler he is using and 2 hehe i hear some conio haters coming
9th Aug 2017, 5:46 AM
Abdur-Rahmaan Janhangeer
Abdur-Rahmaan Janhangeer - avatar
+ 2
@sayan there you are for conio
9th Aug 2017, 7:24 AM
Abdur-Rahmaan Janhangeer
Abdur-Rahmaan Janhangeer - avatar
0
FYI, for all those thinking that main() must return an int. You're not exactly correct. The return type and signature of main is dependent on which compiler is being used. With some compilers a void return type is perfectly valid. Also, some compilers that have int as a return type (including the one used here in the playground) the return 0 statement is optional, as it is implicitly called by the compiler. As @sayan stated your code is perfectly valid, just not for the c++ compiler used here on SL and for many other c/c++ compilers out there. @Hatsy Rei has shown a perfect c++ substitution for your code to be used with the compiler here (though the return statement could be omitted if desired) and many other c++ compilers out there.
9th Aug 2017, 5:15 AM
ChaoticDawg
ChaoticDawg - avatar
0
tenks friends
9th Aug 2017, 7:13 AM
Daniel Isaac
Daniel Isaac - avatar
- 1
1st thing @Daniel issac its a perfect c language code there is nothing to debug it. 1. stdio add conio are purely c headers... 2. when you are using void main() it does not have to return anything whether it returns or not you do not need to worry for that. 3. only of you use int main() there have to be a return value.. 4. the code u gave...is totally a C code. 5. c codes dont run in sololearn... 6. but the code is perfectly fine..NOTHING TO DEBUG
9th Aug 2017, 4:05 AM
sayan chandra
sayan chandra - avatar
- 1
@ ABDUR RAHMAAN if a c compiler is making a fuss on conio.... ITS NOT A LEGIT C COMPILER conio= console input output... its in the c mother code... @ Daniel issac i would suggest you to use turbo c++ or neatbeans ...
9th Aug 2017, 5:44 AM
sayan chandra
sayan chandra - avatar