Posts
 
Reputation
Joined
Last Seen
Ranked #551
Strength to Increase Rep
+5
Strength to Decrease Rep
-1
100% Quality Score
Upvotes Received
2
Posts with Upvotes
1
Upvoting Members
2
Downvotes Received
0
Posts with Downvotes
0
Downvoting Members
0
2 Commented Posts
0 Endorsements
Ranked #864
~19.4K People Reached
Favorite Forums
Favorite Tags

35 Posted Topics

Member Avatar for orwell84

If max is the number of primes ,you originally want then why are you looping to maxprimes (or is it[I] MAXPRIMES[/I]) ( @siddhant3s : [QUOTE] if you can make it run, get us back. [/QUOTE] ) [CODE] //while (count < maxprimes) //shouldn't it be (count < max) [/CODE] But even …

Member Avatar for orwell84
0
113
Member Avatar for blue3hree

Even this line needs some correection: [CODE=c] scanf("&d", &items); [/CODE] In your second program, why do you think [CODE=c] float ratio, score=0, items; [/CODE] the number of items should be in floats.The reason why i ask is this: [CODE=c] for(count=0; count!=items; count++) [/CODE] Mixing integers and floats may lead to …

Member Avatar for zalezog
0
227
Member Avatar for daeuse

[CODE=c] char Repeat ; . . cin >> Repeat ; [/CODE] Possibly you take BMI as input which leaves a '\n' in buffer which is accepted by [ICODE]Repeat[/ICODE] and you don't get a yes / no chance. Either clear the buffer using standard C++ way or use strings [ICODE]string Repeat;[/ICODE] …

Member Avatar for daeuse
0
215
Member Avatar for ueoptimum

Search for aheader file which contains these functions under Turbo C [CODE=C] getch(); clrscr (); gotoxy (35,12); [/CODE]

Member Avatar for zalezog
-1
130
Member Avatar for RobBrown

hmm, let's C:twisted: [CODE=c] void userInput (int matrix[R_SIZE][C_SIZE], int row, int col) //gathering user input { /*You are using a for loop in main().This function just accepts input for a paticular row and column*/ /* This is the trouble >> scanf("%d", &matrix[R_SIZE][C_SIZE]); Here is the major problem.This should have resulted …

Member Avatar for anandi ilu
-1
750
Member Avatar for gretty

[QUOTE=gretty;955772]Hello I have a program that prints a menu & the user is prompted to input a choice(1,2 or 3) if they input anything else, the output should be "Invalid Choice". [B] My Problem[/B] is that if a user inputs anything other than 1,2 or 3, then the program crashes, …

Member Avatar for mrnutty
0
232
Member Avatar for gretty

[QUOTE=gretty] I am supposed to use a binary search ... [/QUOTE] Binary Search would come into picture only iff you have a sorted input like dell, bell etc and corresponding sorted array to search for. Your examples don't have a sorted string in most of the cases. But if we …

Member Avatar for VernonDozier
0
441
Member Avatar for jake43

[QUOTE] void selection_sort(double input_array[], int input_size); void display_array(double input_array[], int input_size); [/QUOTE] True. But the program still wouldn't work This line [CODE] int small, temp; [/CODE] small (its the index)is Ok but temp stores the value of the element in the double[] input_array, so you will always have a truncated …

Member Avatar for mrnutty
0
208
Member Avatar for dzhugashvili

I doubt whether this will help..:S , your read_in file remains intact, your read_out now is: [CODE=c++] #include <iostream> #include <string> using namespace std; int main() { string word; // even while((cin >> word)) works while(getline(cin, word)) for (int i = 0; i < word.length(); i++) cout << word[i] << …

Member Avatar for dzhugashvili
0
323
Member Avatar for gretty

I didn't want to poke but [I]firstPerson[/I]'s method doesn't take into account the frequency of characters, so for inputs like s1 = roorsseett s2 = sosretetet returns true. letter s1 s2 r 2 1 o 2 1 . . or inputs like s1 = rorre s2 = oroee returns true. …

Member Avatar for mrnutty
0
519
Member Avatar for hollywoood

You haven't said anything about the desired output of your program, the total you were expecting, what testsdid you do , if you ae using compound interest, then the formula looks wrong to me. Whether the interest rates are given directly or you are supposed to divide by 100 and …

Member Avatar for hollywoood
0
772
Member Avatar for hollywoood

[CODE] double interest = .00575; [/CODE] I think the monthly interest is given. [CODE] double monthlyInterest = interest * 12; [/CODE] is actually the yearlyInterest which comes to ~ 7 %. Well, if you are calculating the total with the 'monthly' interest, the formula should have been [CODE] total = …

Member Avatar for zalezog
0
921
Member Avatar for des6043

Well,It also gives me an error. [CODE] syntax error before else [/CODE] every where when you have else statements coming ahead of else if statements. May be we can alter the structure of the program , if suppose you have a candidate getting less than 35, you still get into …

Member Avatar for des6043
0
158
Member Avatar for DoEds

[quote] I dont know how work with the overtime... here's my code.. [CODE=c]#include <stdio.h> int main() { int day,hRate,wHours,; int total = 0; int i = 1; float cTax,gross,salary,nSalary,aTotal; float tax = .12; printf("Enter Hourly Rate: "); scanf("%d",&hRate); printf("Enter number of days you've worked: "); scanf("%d",&day); if (i <= day) …

Member Avatar for DoEds
0
172
Member Avatar for gcah

[quote] int index=0; while(arr[index] != 15) //15 as an example the value we r looking for { index++; } [/quote] What if '15' does not exist in the array, what happens then ? How far will index go ? or, if there are multiple copies of '15'?

Member Avatar for gcah
0
4K
Member Avatar for Cromarte888

Another approach could be 1.Make another userGuess string. 2. First , fill all the characters in userGuess string with underscores( _ ). 3.Make changes in the userGuess string. [CODE=cplusplus] guess(); //call member function of letter chosen ltrpos = gameWord.find(gameGuess); cout << "You have chosen the letter " << gameGuess << …

Member Avatar for Cromarte888
0
232
Member Avatar for pltndragon

[QUOTE=pltndragon;922048] Why doesn't it calculate the average properly, or how do you get it to calculate the average without changing using the lowest grade in the calculation. Thanks. [/QUOTE] [CODE=cplusplus] //Get lowest lowest = scores[0]; //Without the for loop code works fine. //for ( int count = 1; count < …

Member Avatar for NathanOliver
0
2K
Member Avatar for lotrsimp12345

cin>>passage; cin would stop reading as soon as it encounters a space ! Use getline instead: getline (cin , passage) while(letter!='\n') { cin.get(letter); while(letter=" "); //<<extra character makes it redundant;) //while(isspace(cin.peek())&&letter=='\n') { cin.get(letter); cout<<"the letter is"<<letter; space++; } } Instead , for (int i = 0 ; i < passage.length() …

Member Avatar for Nick Evan
0
243
Member Avatar for bhagyaraj

The series breaks down to:: 1 - 2 / (2 *1) +3 / (3*2!) -.... i.e 1 - 1 + 1/2! - 1/3! So the first (major) 2 terms of the series cancel out. Now, may be you define a variable [CODE]int sign_carrier = 1 ; long fact = 1; …

Member Avatar for bhagyaraj
0
197
Member Avatar for massivefermion

Since you are just finding the prime factors of a number,how about something like this:: [CODE=c++] //fragment code where num is your real number if(num>0) { for(int i=1;i<=num;++i) { if(i==1) { cout<<i<<" ";//Can be done without it continue;//Don't dare get into a while loop with 1 } while(num%i==0) { cout<<i<<" …

Member Avatar for iamthwee
0
147
Member Avatar for YingKang

[QUOTE] ..problem is after the program works the first time, then the user wants to do it again( which I use a while loop) , for example , choose row 1 B, the form will show X at row 1 B, but not the row 2 A ( which the …

Member Avatar for YingKang
0
3K
Member Avatar for songweaver

I think in the function [CODE] void displayInstructions () //You should be passing //these parameters by reference //float initial, fuel, taxRate; //since you seem to use those values in // float totalHouseCost (float initial, float fuel, float taxRate) //and in float totalHouseCost (float initial, float fuel, float taxRate) //you must …

Member Avatar for zalezog
0
158
Member Avatar for erialclaire_238

[QUOTE] [CODE=c] for(c=0;c<5;c++) { if(d==no[c]) loc=loc+1;<<< change it to loc=i; //But where is i,the control variable is c //Should be loc=c [/CODE] [/QUOTE] This would certainly work if all the numbers are distinct,else you 'll get only the last occurrence of that number in the 'loc'

Member Avatar for skatamatic
-1
98
Member Avatar for FEARmike21

[QUOTE=siddhant3s] [CODE] for(int i;i<len-1;i++)//No initialization of i //you surely meant //for(int i=0; i<len ;i++) { if(str[i]=' ')//is this right?? and what if last character is a space. . . [/CODE] [/QUOTE] Instead use strings.

Member Avatar for siddhant3s
0
152
Member Avatar for nparrish15

First,for a a number in an array call it as [CODE] int num;[/CODE] [CODE=c] //Your expression for evaluating control variable //certainly doesn't give all the factors,referring to //for (int j = 2; j <= floor (sqrt((double)integerIn)); j++) //try for integerIn=999; //999's square root lying between 31 and 32 while one …

Member Avatar for arghasen
0
129
Member Avatar for Himerz

[QUOTE] converts lower case letters to upper case letters. . . not display strange characters [/QUOTE] You were displaying all the letters [CODE=c] for (loopCount= 0;loopCount < numLetters;loopCount++) { //to display CAPITAL letters //You enter inside if block only if it is a small letter. //else you don't display the …

Member Avatar for zalezog
0
140
Member Avatar for bemo55

[QUOTE] capacity: 10 seats [/QUOTE] [QUOTE] [CODE] int seat[40]={0}; /*What for?*/ [/CODE] [/QUOTE] You don't loop through your statements to see whether [I] both the choices work for you [/I] [CODE] if (choice =2) [/CODE] If suppose I have booked a ticket,have you placed a 1 in the index position …

Member Avatar for zalezog
0
133
Member Avatar for FrancisC07

You almost got it right . [CODE=c++] char name[5][50]; for(int i=0;i<5;i++) { cin.getline(name[i], 50); } for(int i=0;i<5;i++) { //or cout<<name[i]<<"\n"; cout<<**(name+i)<<endl; } [/CODE] [CODE]*name[i][/CODE] is equivalent to [CODE]**(name+i)[/CODE] which displays only the first character of the line entered. Also you don't require a buffer as [CODE]cin.getline(...)[/CODE] automatically appends a '\0' …

Member Avatar for zalezog
0
135
Member Avatar for AdRock

Though ,not a good approach but the following approach does work.(if your input contains texts which are separated by more than a couple of newlines,expect some unexpected characters in the output) Inside the while loop [CODE] while (getline(filename, line)) //Loop through lines { char str[BUFSIZ] ;//BUFSIZ // already defined in …

Member Avatar for Murtan
0
2K
Member Avatar for nitu_thakkar

[QUOTE=nitu_thakkar;779631]suppose i want to do shift left operation on x=1010 y=x<<1 it will shift left the value & make x=0100 but how can i store that shifted value... in other variable...? please help me to solve this query[/QUOTE] 1. l x=10; and left shifting the bits once does not give …

Member Avatar for MosaicFuneral
0
142
Member Avatar for GURU1349

[QUOTE=GURU1349;780689]hello people, its the very first time im doing programming stuff.And i have done nothing so far.I found a booklet in my bookcase,it's about C++.,ts just the first booklet of a serie. i use visual c++ 2008 express,i did new>file>C++ i used the same codes as in the booklet,here it …

Member Avatar for Freaky_Chris
0
105
Member Avatar for kaviths

[QUOTE=kaviths;781005][code] #include<iostream.h> using namespace std; class first { int reverse() { char name[]={'k','a','v','i','t','h','a','/0'}; int 1=0; while(name[i] != '/0') { i++; cout<<"value of i is"<<i<<endl; } } int main() { first f; f.reverse(); } }; [/code] my file's name is cpp.cpp and i cannot run it using ./a.out I get a …

Member Avatar for Freaky_Chris
0
91
Member Avatar for aiyer

[QUOTE=aiyer;779430] #include <iostream.h> void afunction() { if(1) { cout<<"Err"; break; } } int main () { afunction(); } and exit early when required. [/QUOTE] I believe that by placing a [ICODE]break[/ICODE] statement you were trying to return back to the [ICODE]main()[/ICODE] function. Placing a [CODE] return;//Instead of break might be …

Member Avatar for Comatose
0
741
Member Avatar for lameassthemity

Ok,this is the else part of your loop cout << "Class Name: "; cin >> Course[currentindex].ClassName; cout << "Class Number: "; cin >> Course[currentindex].ClassNumber; When you use a cin statement ,the cin stops reading the buffer after it encounters a white space or a newline.So when you read something like …

Member Avatar for zalezog
0
134
Member Avatar for winry

You say that you don't know the exact number of digits. Then why not he input to the function be a string such that [CODE] string convertNum(string num) { //1.set counter to 0 //2.Check if it is the end of the string(using counter's position). // 3.if yes goto goto step …

Member Avatar for winry
0
295

The End.