#include <iostream>
#include <vector>
using namespace std;


int main ()

{

	int N =0;
	int Range=0;
	int NumberOfCases=0;

	cout << "Enter N" <<endl;
	cin >> N;

	cout << "Enter Range" <<endl;
	cin >> Range;

	cout << "Number of cases" <<endl;
	cin >> NumberOfCases;

	vector<double> range_time_Vector(Range);
	int K = N;
	for(int i=0; i < Range; ++i);

}

{
	double time_sum = 0.0;
		double time_average = 0.0;

		for (int m=1 ; m <= NumberOfCases; ++m);
	
}

{
		cout << "for m=" << m << "  K=" << K << endl;
		
		}

Recommended Answers

All 4 Replies

for(int i=0; i < Range; ++i);

}

{
double time_sum = 0.0;
double time_average = 0.0;

for (int m=1 ; m <= NumberOfCases; ++m);

}
{
cout << "for m=" << m << " K=" << K << endl;

}

This is incorrect.

It won't be hard to fix :) It's your curly brackets and ;'s. Hope that's not too much of a giveaway.

Edit: There's other stuff, too. But I think this is the most pressing issue.

Edit2: You should use code tags, too.

This is incorrect.

It won't be hard to fix :) It's your curly brackets and ;'s. Hope that's not too much of a giveaway.

Edit: There's other stuff, too. But I think this is the most pressing issue.

Edit2: You should use code tags, too.

I'm not the best at guessing, so could you just tell me please:icon_cheesygrin:

Well,

Think about what your braces are saying.

The first one starts by saying "Close a chunk (scope)". The next says "Open a new chunk". After you declare the conditions for your second loop you cloase that new chunk! The second loop is inside that chunk and so the code following the close curly brace is not connected to anything. (This isn't the BEST explaiation but it poitns you in the right direction... think about what your braces are saying :))

Also, with your for loops, there is something wrong with them. You are declaring some conditions for the loops, but as soon as you finish declaring them you close the loop in teh same way that you finish a line! :O

I'm not going to do your code for you because
a) it's against the rules
b) you'll learn more this way
and
c) I don't want to deprive you of the feeling of going "OH!" and discovering your error. (It's already a bit tarnished, but you'll still get a bit of a fix)


Edit: Actually, go through your whole program thinking "what scope am I in. When did it begin, when does it end. What is the current scope encompassing."

Well,

Think about what your braces are saying.

The first one starts by saying "Close a chunk (scope)". The next says "Open a new chunk". After you declare the conditions for your second loop you cloase that new chunk! The second loop is inside that chunk and so the code following the close curly brace is not connected to anything. (This isn't the BEST explaiation but it poitns you in the right direction... think about what your braces are saying :))

Also, with your for loops, there is something wrong with them. You are declaring some conditions for the loops, but as soon as you finish declaring them you close the loop in teh same way that you finish a line! :O

I'm not going to do your code for you because
a) it's against the rules
b) you'll learn more this way
and
c) I don't want to deprive you of the feeling of going "OH!" and discovering your error. (It's already a bit tarnished, but you'll still get a bit of a fix)


Edit: Actually, go through your whole program thinking "what scope am I in. When did it begin, when does it end. What is the current scope encompassing."

I got it!

for(int i=0; i < Range; ++i)
      {
          double time_sum = 0.0;
          double time_average = 0.0;
          for (int m=1 ; m <= NumberOfCases; ++m)
          {
             cout << "for m=" << m << "  K=" << K << endl;
          }
      }
      return 0;
}

Thanks for letting me figure it out. i complied and everything and it check out

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.