c long double format specifier

March 4, 2011 at 21:04:07
Specs: Windows XP
I used this format in .c in place of the program written in .cpp given next to that of .c. The program is executing unexpected result. Please help. The main program link is http://acm.uva.es/p/v101/10110.html

In .c>>>>>>>>>>>>>
#include<stdio.h>
#include<math.h>
main()
{
long double num,n2;
long n1;
scanf("%lf",&num);
printf("%lf",num);
while(num!=0)
{
n1=(long)(sqrt(num));
n2=sqrt(num);
printf("\n%lf \n%ld",n1,n2);
if(n1==n2)
printf("yes\n\n");
else
printf("no\n\n");
scanf("%lf",&num);
}
}

In .cpp>>>>>>>>


#include<iostream>
#include <cmath>

using namespace std;
int main()
{
long double num,n2;
long n1;
cin>>num;
while(num!=0)
{
n1=long (sqrt(num));
n2=sqrt (num);
if(n1==n2)
cout<<"yes"<<endl<<endl;
else
cout<<"no"<<endl<<endl;
cin>>num;
}
return 0;
}

my email add: vorershisircsepstu@<removed>

edited by moderator: Removed email address -Razor2.3


See More: c long double format specifier

Report •


#1
March 6, 2011 at 22:23:05
Your cpp program has certain syntactical errors...u need to correct them..U can run the program without using the namespace. Also you must change the while condition...it might get into the infinite loop..

Report •

#2
March 7, 2011 at 01:54:46
I want to do it in .c . Can you make it for me?

Report •

#3
March 7, 2011 at 17:34:00
Well, I could, but that'd defeat the purpose of your homework, wouldn't it?

How To Ask Questions The Smart Way


Report •

Related Solutions

#4
March 7, 2011 at 22:55:13
To do it in .c is my homework and I am really worried about it. Pleaser solve it for me if you can do it.

Report •

#5
July 7, 2011 at 00:31:35
fed up of doin homework by just copy-pestin from this site!!!!

Report •


Ask Question