+ 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(); }
11 Antworten
+ 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;
}
+ 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).
+ 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
+ 2
First of all main function "must to return" a integer so you need to change void forma int
+ 2
@sayan maybe his compiler is making a fuss on conio
+ 2
@sayan he must tell which compiler he is using and 2 hehe i hear some conio haters coming
+ 2
@sayan there you are for conio
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.
0
tenks friends
- 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
- 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 ...