By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,605 Members | 1,473 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,605 IT Pros & Developers. It's quick & easy.

Problem with my program, no output

P: 1
guys i tried constructing a programe and did but the problem when i run it the screen disappears and no output is presented. I am posting in the question as well as the script which i wrote,please send a reply to me abt it.
question is:
using if statement,to print the roots of a quadratic equation,given the condition as follows:
IF ROOTS
b*b-4*a*c>0 {-b(+/-)sqrt(b*b-4*a*c)}/2*a

b*b-4*a*c=0 {-b/2*a} (msg=roots are equal)

b*b-4*a*c<0 roots are imaginary

script which i had typed:
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
float a,b,c,r1,d,r2,e;
cout<<"\n enter the values of three no.s";
cin>>a>>b>>c;
d=b*b-4*a*c;
e=sqrt(d);
r1=(-b+e)/(2*a);
r2=(-b+e)/(2*a);
cout<<"\n root1="<<r1;
cout<<"\n root2="<<r2;
if (d>0)
cout<<"\n "<<r2;
else
{
if (d==0)
cout<<"\n roots are equal"<<r1;
}
if (d<0)
cout<<"\n roots are imaginary";
getch();
}
Nov 9 '06 #1
Share this Question
Share on Google+
3 Replies


P: 2
Remove GetCh()

and try to get input with ALT+F5


guys i tried constructing a programe and did but the problem when i run it the screen disappears and no output is presented. I am posting in the question as well as the script which i wrote,please send a reply to me abt it.
question is:
using if statement,to print the roots of a quadratic equation,given the condition as follows:
IF ROOTS
b*b-4*a*c>0 {-b(+/-)sqrt(b*b-4*a*c)}/2*a

b*b-4*a*c=0 {-b/2*a} (msg=roots are equal)

b*b-4*a*c<0 roots are imaginary

script which i had typed:
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
float a,b,c,r1,d,r2,e;
cout<<"\n enter the values of three no.s";
cin>>a>>b>>c;
d=b*b-4*a*c;
e=sqrt(d);
r1=(-b+e)/(2*a);
r2=(-b+e)/(2*a);
cout<<"\n root1="<<r1;
cout<<"\n root2="<<r2;
if (d>0)
cout<<"\n "<<r2;
else
{
if (d==0)
cout<<"\n roots are equal"<<r1;
}
if (d<0)
cout<<"\n roots are imaginary";
getch();
}
Nov 9 '06 #2

sivadhas2006
100+
P: 142
Hi,

Can I know which editor you are using for progamming?

Regards,
M.Sivadhas.
Nov 9 '06 #3

momotaro
100+
P: 357
add this to the end of u r program:
Expand|Select|Wrap|Line Numbers
  1. scanf("%d", &x);
ps: x is your variable that u should declare!
Nov 9 '06 #4

Post your reply

Sign in to post your reply or Sign up for a free account.