- #141
lulu f
- 2
- 0
how we can write aprogram that solve integration by C in rectangular method ,trapezoid ,and simpson
Is this homework? what have you already tried? Please start a new thread, 'cause this is a standalone thing.lulu f said:how we can write aprogram that solve integration by C in rectangular method ,trapezoid ,and simpson
lulu f said:how we can write aprogram that solve integration by C in rectangular method ,trapezoid ,and simpson
dduardo said:Please post your C++ questions or comments here for Tutorial 1.
Smartguy5000 said:I'd like to start learning C++ and I have a dreamspark version of MSVisual Studio 2010 beta, will that be good for a beginner, or should I have a go at something simpler?
Simpler. Visual studio is a really powerful tool, but you spend more time learning visual studio than learning how to code. You want to stick with a really barebones ide ( I like eclipse) or something command line based like MinGW.Smartguy5000 said:will that be good for a beginner, or should I have a go at something simpler?
story645 said:Simpler. Visual studio is a really powerful tool, but you spend more time learning visual studio than learning how to code. You want to stick with a really barebones ide ( I like eclipse) or something command line based like MinGW.
DarkShadows5 said:your tutorials are great so far but i was wondering why every time i run one of the assignments it only shows the window for a split second?
I typed everything in exactly and it does this except however the "hello world" example does not disappear as soon as it appears.
it's quite annoying to have to "try" to hit prtsc key when it pops up to see what it says... lol
vanmaiden said:I didn't see this mentioned in the tutorial, but what is the preprocessor and its function?
TylerH said:Sounds like homework.
Try google. :) http://en.wikipedia.org/wiki/C_preprocessor [Note: The C preprocessor is the C++ preprocessor.]
DarkShadows5 said:haha NVM I figured it out instead of using
return 0;
use
system("PAUSE");
return EXIT_SUCCESS;
and it will pause it so you can view the information.
No, the calculation in the tutorial is incorrect. The value you have is correct.Janno said:Hi, I just started with you C++ tutorial.
In lesson #3 you do write: log(15)/log(2)=4.9
Is that correct? In my calculator is says: 3,9.
Janno said:Rounding up gives 4. And four bytes are just what's needed to store 15 decimal, or
FFFF hexadecimal, or 1111 binary if I'm on the right track.
DrDu said:In fortran, you have a read or write statement and it is part of the language. In C/C++ this seems to be different; you need all kinds of libraries, and it seems to be arbitrarily complicated to correctly handle the end of a line :-)
It would really be grateful for some lucid explanation on how to read and write in these languages.
#include <stdio.h>
int main() {
FILE* fp = fopen("myfile.txt","w");
if (! fp) {
/* handle errors */
} else {
fprintf(fp,"Hello World!\n"); /* prints one line to the file */
fclose(fp);
}
}
#include <iostream> // for std::cerr etc
#include <fstream> // for file handling
const char* FILENAME = "myfile.txt";
int main() {
std::ofstream ofs(FILENAME);
if (! ofs) {
std::cerr << "Error opening " << FILENAME << std::endl;
} else {
ofs << "Hello World!" << std::endl;
ofs.close(); // not mandatory; the "ofs" d'tor would do that anyway
}
}
man fopen
#include <iostream>
using namespace std;
int main()
{
int D1, M1, Y1, D2, M2, Y2, T;
cin >> T;
cout << endl;
for (int i = 1; i <= T; i++)
{
cin >> D1 >> M1 >> Y1 >> D2 >> M2 >> Y2;
cout << endl;
int Days = D1 - D2;
int Months = M1 - M2;
int Years = Y1 - Y2;
if ((Months < 0) || (Days < 0 && Months == 0))
{
Years = Years--;
if (Years > 130)
{
cout << "Case " << "#" << i << ": " << "Check birth date" << endl;
cout << endl;
}
else if (Years < 0)
{
cout << "Case " << "#" << i << ": " << "Invalid birth date" << endl;
cout << endl;
}
else
{
cout << "Case " << "#" << i << ": " << Years << endl;
cout << endl;
}
}
else if (Years > 130)
{
cout << "Case " << "#" << i << ": " << "Check birth date" << endl;
cout << endl;
}
else if (Years < 0)
{
cout << "Case " << "#" << i << ": " << "Invalid birth date" << endl;
cout << endl;
}
else
{
cout << "Case " << "#" << i << ": " << Years << endl;
cout << endl;
}
}
return 0;
}