Before seeing the solution make sure that you tried enough. Don’t paste the whole code, just find out the logic. If you stuck in trouble, just inform me on comment.
/**Bismillahir Rahmanir Rahim.**/ #include <stdio.h> int main() { long double X; char s[120]; scanf("%LE", &X); sprintf(s,"%LE", X); if(s[0] != '-') printf("+"); printf("%.4LE\n", X); return 0; }
I couldn't understand what is sprintf and why u made the condition and why in the last printf u wrote %4.LE instead of %LE ?
ReplyDeleteThanks :) Alsalam Alaykom
Walaikum Assalam.
Delete* sprintf converts double into string.
* When you print +5, your PC shows you just 5.
* So, i make this condition when the number is positive, it prints a "+" at first.
* I use %.4LE, because it prints four digit after decimal point(.).
and you are welcome. :)
Thank you very much,brother.You codes are helping me as a great guideline.
ReplyDeleteand You are most welcome...........
Delete:)
bro number system convert korer naki akta function ase....janale khosi hvo...ar sprintf ar moto ar ki kono function ase?
Delete#include
ReplyDeleteint main()
{
long double num;
scanf("%LE", &num);
if(num>=0.0000E+00)
printf("+");
printf("%.4LE\n", num);
return 0;
}
ai code ta 10% wa dissi kno?akto bolben?
Have a case in this problem, that is -0.0000 and you need print +0.0000, but your code produces +-0.0000, (I think that is it case, but to take the doubt, check the toolkit).
Deletealsalam alaykom
ReplyDeletethank you very much for helping us and actually remind me to tools in language that's help me in problems
This comment has been removed by the author.
ReplyDelete#include
ReplyDeleteint main()
{
double X;
scanf("%lf",&X);
printf("%.4E\n",X);
return 0;
}
vaiia ai dike %LE er kaj ki??
ReplyDeleteaita C++ -a kivabe korbo??
ReplyDelete