473,385 Members | 1,588 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

y=sin(t)^n

I kinda need help in writing a program to a practice problem.Let me mention this is first year at uni and i am a beginner with programming in C.

The problem is I need to write a program which will generate
y=sin(t)^n which is sin(t)to the power n
The value of y is stored in a floating arrayaccording to the values of t and n.integer n varies between 0 and 10 and integer t between 0 and 60.The program then repeatedly asks for two integer inputs which are stored in i and j.I have to use printf to print the value of z[i][j] to the screenwhen either i or j equals to -1 the program terminates.when the values of i and j are out of range then the program prints a warning message and ignores the input and asks for new ones.



Would really apprecaite if somebody helps as early as possible beacuse I am getting no where
Oct 21 '06 #1
3 1464
Hey banfa I might be a little impatient here but the thing is i cant even get started with this problem and ya i know that you ask ppl to wait a while but the fact that i am gettin no where with this is bugging me.hope this wudnt cause u much problem and i have seen ppl gettinh help in othjer threads so was just wondering if i could get some help.
Oct 22 '06 #2
arne
315 Expert 100+
Hey banfa I might be a little impatient here but the thing is i cant even get started with this problem and ya i know that you ask ppl to wait a while but the fact that i am gettin no where with this is bugging me.hope this wudnt cause u much problem and i have seen ppl gettinh help in othjer threads so was just wondering if i could get some help.
What's the problem that "you can't even get started" ?
Don't know how to structure your program?
Don't know how to code it?
Oct 22 '06 #3
The following implementation returns an array which stores what you are looking for

#include <cstdlib>
#include <iostream>
#include <cmath>

using namespace std;

int main(int argc, char *argv[])
{
int n,t;

n=10;//Number of columns
t=60;//Number of rows

float y_arr[n][t];//Declare the array

//Fill the array
for(int i=0;i<n;i++){
for(int j=0;j<t;j++){
y_arr[i][j]=pow(sin(j),i);
}
}

//Print the matrix to the screen
for(int i=0;i<n;i++){
for(int j=0;j<n;j++)
cout<<y_arr[i][j]<<" ";
cout<<endl;
}

system("PAUSE");
return EXIT_SUCCESS;
}
Oct 23 '06 #4

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

Similar topics

7
by: franky.backeljauw | last post by:
Hello, I have the following code: <code> class X { ___ sin(); } X sin( X ) { return sin( y, x ); }
14
by: Alexander Stippler | last post by:
Hi, simple question. Why does this not work: #include <algorithm> #include <cmath> #include <iostream> int main()
6
by: Victo | last post by:
I tried to use pow() and sin(). but even I included <math.h>, I can't use the 2 functions.... Why's that???? for example,
10
by: Gregc. | last post by:
G'day I am trying to work out the length of the hypotenuse. Attached is the code that I am using: #include <stdio.h> #include <math.h> double hypUsingTrig(double e) {
15
by: Morgan Cheng | last post by:
Hi, I am writing a program that will take a lot of Math.Cos & Math.Sin operation. I am afraid this will be source of performance impact. Anybody knows how Math.cos & Math.Sin is implemented?...
0
by: outofstep | last post by:
Hit me up on AIM/YIM (oipaloi). I'm not a code monkey and would like to get some advice. Or hit up this thread right here. I'm using DEV C++ as my compiler. I'm trying to calculate...
8
by: asd | last post by:
Hello all. I was doing some kind of development and in the test file I have something like this: ///// Test File ///// double x = sin(45); The output for that statement is:
70
by: Adam | last post by:
Hi, I am using the following code: printf("%g", sin(M_PI)) and getting 1.22461e-16 instead of zero. Does anyone have any idea why, and what I can do about it? Thanks, Adam
318
by: King Raz | last post by:
The shootout site has benchmarks comparing different languages. It includes C# Mono vs Java but not C# .NET vs Java. So I went through all the benchmark on the site ... ...
3
by: mariab | last post by:
hi, i'm having the problem with my first socket program...i have been staring at it for an hour but i cant find whats wrong with it...can u check it out pls? #include <stdio.h> #include...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.