Hello,
This is my first post. I'm learning C++ right now, and I have an assignment with two programs. I'm lost like you would not believe.
First Program: Calculate values of a function z = sin(x) + cos(y), x and y change from 0, pi/6, pi/3 to pi and display in table format.
I understand how to put it together, but I cant get it to work... :(
This is what I have so far:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
#include <cstdlib>
#include <iostream>
#include "math.h"
using namespace std;
int main(int argc, char *argv[])
{
int array[6][6];
double x, y;
double a, b;
double pi = 3.14;
for(int i = 0; i < 7; i++)
{
cout << i << "\t";
}
cout << "\n\n";
for(int i = 0*pi/6; i < 7*pi/6; i++)
{
for(int j = 0*pi/6; j < 7*pi/6; j++)
{
array[i][j] = (sin(i/6)) + (cos(j/6));
cout << array[i][j] << "\t";
}
cout << "\n";
}
|
I am wayyyyy off, and I am confused how to get it in a table:
0 pi/6 2pi/6 3pi/6 4pi/6 5pi/6 pi
0
pi/6
2pi/6
3pi/6
4pi/6
5pi/6
pi
Next Problem:
Write a program to find how many times the word "the" occurs in an article. Here's what I have....
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
#include <cstdlib>
#include <iostream>
#include <string>
#include "ctype.h"
using namespace std;
int main(int argc, char *argv[])
{
char article[1000] = "The proposal was the product of months of negotiations between the Gang of Six committee members: three Democrats and three Republicans. The other Republicans involved in the negotiations, Sens. Chuck Grassley of Iowa and Mike Enzi of Wyoming, voted no on the compromise measure.";
cout << article << "\n\n";
system("PAUSE");
return EXIT_SUCCESS;
}
|
Im using Dev C++ as a compiler.
Its due tomorrow at 12:30pm, and I've spent the last week going through my c++ reference guides and online sites searching for help. I don't want a solution, I want an explanation of how it should be done that way I can learn. Thank You.