No one has voted on any posts yet. Votes from other community members are used to determine a member's reputation amongst their peers.
39 Posted Topics
Re: It is printing the number multiple times, becuse of: [CODE] for ( int j = 2; j <= i/2; j++) { if ( i % j == 0 ) { check_prime = 0; } if ( check_prime != 0 ) { cout << i << endl; } }[/CODE] here you … | |
Re: tried using wchar_t instead of char? | |
Re: From [url]http://www.daniweb.com/techtalkforums/showthread.php?t=27800[/url] [QUOTE=Narue]You're using a Win32 application project when you want a console application project. Win32 applications expect WinMain instead of main.[/QUOTE] use <iostreram> instead of <iostreram.h> | |
Re: >Ok But how can i get the value of the 5th element? does cout<<a[5]; will do? well,it will ouput the 6'th element, since arrays start on 0. >And what if i want to output all the elements? do I write cout<<a[0], a[1], a[2]... a[20]; yes, but [20] dont exist, since … | |
Re: to call the function prime, it is just to add: prime(loop) a simple loop condiction is: (n/2)+1 > i since after 1/2 of the val of n there cant be a fraction of the n number. and the test are simple ennuf: if (n%i == 0) | |
Re: you are adding counter twice in your loop, need to remove one. [code]void primeTest(int n) { int temp = 2; for (int counter=1; counter<=n; counter++) { cout << "Prime number " << counter << " is " << temp << endl; // counter ++; need to be comented out or … | |
Re: Words are generaly seperated by spaces, so look for spaces between charaters. | |
Re: You can do somthing like this: #include <iostream> using namespace std; int main() { char test[] = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.!:;? ";// all the chars you are testing for int size = sizeof(test)/sizeof (char); // size of test array int counter[size]; // make array of int's string s1; cout << "enter stringn"; cin … | |
Re: It might be that you are linking with some dll's that aint in the folder you are executing from or in the system folder. try to look at the propeties for the project in VC and see if they link to some files. and if try to copy them into … | |
![]() | Re: you can do somthing like this: [CODE] #include <iostream> using namespace std; int main() { int num = 50; // test num bool done = false; // for tetsing if done while (!done) { done = true; if(num % 2 == 0) // testing if 2 is a factor of … |
Re: [Code] file<<"%d file\n",rand(); [/CODE] cant be dont this way, it is not printf() that you are using :) try: [CODE] file << rand() << " file\n"; [/CODE] | |
Re: try to use a filname without space :) it worked for me then | |
Re: becuse you dont use CODE tags. [url]http://www.daniweb.com/techtalkforums/announcement8-3.html[/url] | |
Re: well it is kinda har to guess wath you want for req's when I have no idea wath max req's and sutch are, so I'l just poste some name: Weapons: Hammer of Thor (pref do some extra lightning dam :) ) Sling of Goliat Deaths sausage Devils tothpick Jewlery Odins … | |
Re: [CODE] for(int i = 0; i < 512; i++) { output[i].var1 = (double *)i; output[i].var2 = (double *)i; output[i].var3 = (double *)i; } [/CODE] shuld populate it. | |
Re: the probleme is that you have declared log as a float. and a float is not a function and a float variable cant be used as a function. so ether change (150*log(pl/1.5)); to (150*std::log(pl/1.5)); or remove the log float. | |
Re: you can do it that way, but yo loose alot of readability! | |
Re: Dont try to print out a void function. change cout << Backward(line) << endl; to Backward(line); cout << endl; | |
Re: why do you need to have this as a 2d array? if you just want the numbers 1-20, you can change the function StudentAns to: [CODE] void StudentAns(char answer[20]) { for (int quest = 1; quest <=20; quest++) { cout << "Please enter your choice for Question " << quest … | |
Re: [QUOTE=jepapel]How a correct initialazation of arrays would be correct? static const char alphabet[] = "a=10, b=25, c=30"; //and so on i get a compiler error when i initialize like this...[/QUOTE] You can do it like this: [CODE] #include <iostream> struct alphab { int num; char ch; }; int main() { … | |
Re: If I aint totaly wrong Dave ment somthing like this: [CODE] char ch[] = "abcdefghijklmnopqrstuvwxyz"; // character array char testc = 'c'; // wath we are looking for int res = -1; for (int i = 0; ch[i] != '\0'; i++) // loop thru ch, untill it reach the end. … | |
Re: Well you have newer declared i, before refering to it in [Code]if(!count[i] % 2) // if divisible by 2, then returns zero, negates to 1, enters if even[i] = count[i]; else odd[i] = count[i];[/Code] just so you know, you havent declared even or odd as array ether. | |
Re: somthing like this: [CODE] #include <iostream> int main () { char c[6] = "45678"; int num[5]; for (int i = 0; i < 5; i++) { char temp = c[i]; num[i] = atoi(&temp); std::cout << num[i] << std::endl; } system("pause"); }[/CODE] | |
Re: Your main probleme is that you have bad design. Try to figure out how to do somthing before you try to code it :). But, I rewritten your code: [CODE] #include <iostream> // use <iostream> instead for <iostream.h> using namespace std; int main() { int i=0 ; int j=0 ; … | |
Re: Your probleme lies in[CODE] if (myDifficulty = 3) [/CODE] You are only asigning the value 3 (or 1 or 2) to the myDiffculty, change the '=' too '==' and it shuld work. You arent using the enum difficulty.... if you change the testing to: [CODE] if (myDifficulty == Easy) [/CODE] … | |
| |
Re: just change the [CODE]cin.ignore(std::cin.rdbuf()->in_avail() + 1);[/CODE] to [CODE]cin.ignore(std::cin.rdbuf()->in_avail() + 2);[/CODE] | |
Re: desidude: try somthing like this: [CODE] std::string Hex(int num) { std::string s1; char sign[] = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'}; int div, base = 16; while (num >= 1) { div = num % base; num = num / base; s1 = sign[div] + s1; } return s1; } [/CODE] | |
Re: Try this:[url]http://www.daniweb.com/code/snippet190.html[/url] | |
Re: (edit2)Take a look on:[url]http://www.daniweb.com/techtalkforums/thread27267.html[/url] | |
Re: Just put the [CODE] sum = sum+val; count=count++;[/CODE] inside your while loop, and it shuld work. | |
Re: [CODE] long jul =static_cast<long>(floor(365.25 * j_year) + floor(30.6001 * j_month) + j_day + 1720995.0); [/CODE] first of. 1720995.0 shuld be changed to 1720994.5 and second. remove the floor() - and it is doing it corectly. >Could you better describe the problem? As far as I know it is showing 1 … | |
Re: you can use somthing like this to loop thru your array: [CODE] #include <iostream> int main () { int pay[] = {500000,300000,230000,156740}; int size = sizeof(pay) / sizeof (int); // find number of elements in pay[] for (int i = 0; i < size; i++) // loop thru pay[] { … | |
Re: You have multiple errors in your code: [CODE] int getData (int numbers [], int size, int range); //....... size= getData (nums, dMAX); [/CODE]You are calling the function with too few argument's. [CODE] while (loader < size && (fsData >> dataIn)) [/CODE]You havent declared fsData. [CODE] data [loader+=] = dataIn; [/CODE]This … | |
Re: well, as a general tip for this forum, put your code in BB tags so one can see whitespaces. | |
Re: if you starte out whit this numbers: num1 = 4 num2 = 3 num3 = 2 num4 = 1 and if you look at your code you will see the numbers change like this: num1 = 3 num2 = 4 num3 = 2 num4 = 1 num1 = 3 num2 … | |
Re: I found a few things you might want to look at: [CODE]for (WS = Min_Wind; WS >=Max_Wind; WS += 10)[/CODE] you want to do this while WS is lager than Max_Wind? think that WS <= Max_Wind is better. [CODE]for (temp = AirT; AirT < 50; temp -= 5)[/CODE] you are … | |
Re: simple examlpe of getline: [CODE] char input[55]; cin.getline(input,55); [/CODE] | |
Re: Is this in general, or do you have a loop that you want to change? |
The End.