Thursday, July 30, 2009

C++ programming?

write a C++ program to decide if the coefficients of a quadratic equation have real roots. The three choices will be to write the message “zero divide” when A is zero, write the message “no real roots” if the discriminant is negative and find the two roots when there is no error condition. DO NOT FIND THE ROOT IF THERE IS AN ERROR CONDITION.


use a NESTED DECISION to do the three parts of the algorithm above.


write a sentinel-controlled loop based on a character value to control the loop, q or Q will terminate the loop, any other value will continue processing. Read the value from the keyboard and write to the monitor. Use the inputs given below.


4. document the program properly, Use format for both the roots. Be sure to set the iosflags, setprecision, and showpoint. Use a setprecision of 3. also use setw for each numeric output.


libraries needed: iostream, cmath, iomanip. Add the .h, math.h for other compilers

C++ programming?
You forgot to post the question you wanted answered, you only posted your assignment.
Reply:Carefull. Last time she posted and I asked where the question was, she reported it. :)


Linking problem in VS2005 when compilig C++ code?

Hi, I just started using VS2005 for compiling my old C++ code, Actually I was trying to use the new VS2005 interface for my old code, I am getting error when ever I am linking a exe with a static library which in terms linked to other static libraries. But when I convert the exe type to static library its linking correctly. Can you please suggest me what could be the solution for this problem?

Linking problem in VS2005 when compilig C++ code?
nitpicking: you cannot have a linking problem when compiling code. you can only have linking problems when linking object files and/or libraries.





if you "convert" the exe to a library, then other libraries are ignored (a library usually does not include other libraries, unless you specifically say so). therefore the linker does not complain if other libraries are missing.





only exe files need all dependencies; if a dependency is missing, the linker will complain and stop linking.





if you don't post the error messages, it's hard to offer good help.


How to shut down or restart pc(windows) using a C program?

only C, not C++





please give me the code for starting %26amp; restarting pc


and tell the libraries to be included

How to shut down or restart pc(windows) using a C program?
You can use -





ExitWindowsEx (EWX_REBOOT, 0);





You might want the optional flag EWX_FORCE. This won't work from a command prompt on 95/98. You need to include windows.h and link with user32.lib for it.





If you don't have user32.lib you need to dynamically link to the function. Ask that as another question. If the user dosen't have the correct privileges this won't work. You need to call another function, ask that as another question.





Note: Microsoft will come around to your house and stand in front of the power button on your PC, because you're not allowed to turn it off. Naughty you. :o)


How are library functions usually packaged within a C program?

Thank u!!

How are library functions usually packaged within a C program?
with the complier..


..for various third aprty libraries, the object code of the fucntion (the .o file) is archived as a .a file on UNIX, and is copied in directories like /lib etc.
Reply:it is packed in a library shiped with compiler

garden centre

How to shut down or restart pc(windows) using a C program?

only C, not C++





please give me the code for starting %26amp; restarting pc


and tell the libraries to be included


and how to do linking if needed


i don't have user32.lib and windows.h


from where can i get it


thanks

How to shut down or restart pc(windows) using a C program?
windows.h and user32.lib can de found online at microsoft by downloading the visual c++ express edition. You can also get these files by downloading mingw and it w32-lib package.





To restart the computer in C do:


ExitWindowsEx(EWX_REBOOT,0);





to shutdown:


ExitWindowsEx(EWX_POWEROFF,0);
Reply:winuser.h


= http://doc.ddart.net/msdn/header/include... .html


Are library functions actually a part of C language.Explain?

Thank U!!!

Are library functions actually a part of C language.Explain?
Oh yes... see when u r so much into programming mindset... wouldnt it be irritating to repeat the bulky codings for a simple input and output statements... so only developers have written a common source codes for these and have included them in files called header files and they r called library functions 'cos they can be referenced by anybody any time......(called header 'cos they r at the top position), and its simple now... just include them in ur programs and u don have to repeat codes for clrscr(),printf(),scanf(),getch()... etc...


p.s: it is a chance we have '.h' as the extension for these files...
Reply:yes very much
Reply:Not all of them,..ANSI standrad C lists a set of library functions..(that are machine architecture independent) that are counted as part of C language..


while there are several other libraries that are not necessarially part of C language


What is the best method for inserting data into an Access or SQL database using C# and .NET?

I am a Classic ASP programmer learning .NET and C# (and trying not to pull out my hair).





I'm used to setting recordsets via ADO in C-ASP, should I do the same in C#? I already know that I can add references to the ADO libraries and create recordsets, but I'm not sure if this is the best practice.





If you need more detail, let me know...

What is the best method for inserting data into an Access or SQL database using C# and .NET?
first add





using System.Data;


using System.Data.SqlClient;





import statements at the top of the code page.





Then copy the following functions to your code:





public static SqlConnection GetConnection(string strConn)


{


SqlConnection conn=null;


try


{


conn = new SqlConnection(strConn);


conn.Open();


}


catch (SqlException ex)


{


Console.Write("SQL ERROR: " + ex.Message);


}


catch (Exception ex)


{


Console.Write("ERROR: " + ex.Message);


}


return conn;


}





public int ExecuteNonQuery(string strConn,string query)


{


SqlConnection conn = GetConnection(strConn);


int result=0;


SqlCommand cmd = new SqlCommand(query, conn);





try


{


//Configure the SqlCommand object


cmd.Connection = conn;


cmd.CommandType = CommandType.Text;


//Set type to StoredProcedure





cmd.CommandText = query;


result = cmd.ExecuteNonQuery();





}


catch (Exception ex)


{


Console.Write("Error running a query " + query + ": " + ex.Message);


}


finally


{


conn.Close();


}


return result;


}





And then do the following:





string query="INSERT INTO Table1(Field1,Field2)VALUES("test","test...


string strConn="Your database connection string here";


int output=ExecuteNonQuery(strConn,query);








if output=0 the insert failed, otherwise succeeded.





If you are dealing with access database, use the same functions but replace SqlConnection and SqlCommand with OleDbConnection and OleDbCommand
Reply:Stick with ADO.NET and SQL statements. It is indeed the best way to go. ADO.NET should work pretty much the same as you're used to and SQL statements distribute the work to be done onto the database server.
Reply:Use foxy's method, that is exactly what I was going to post. You can use the ADO libraries, but they are horrendously slow in .Net. When LINQ becomes available for Access, that is going to be the way to go.
Reply:If you're using MsSQL I'd recommend to look at Microsoft's new LINQ query and programming language fusion. It doesn't work for Access yet, but I think the thing is brilliant.


LINQ is available in Visual Studio 2008
Reply:I am with the other poster who suggested sticking with the ADO object library. It is time tested, and supported by all of the products you mention. If you are already familiar with recordsets, you should have no problem implementing them in C#. My motto is always : when in doubt, stick with what you know. Good luck. If you need any help or advice, just let me know. Be glad to assist in any way I can.