- Strength to Increase Rep
- +0
- Strength to Decrease Rep
- -0
- Upvotes Received
- 0
- Posts with Upvotes
- 0
- Upvoting Members
- 0
- Downvotes Received
- 1
- Posts with Downvotes
- 1
- Downvoting Members
- 1
14 Posted Topics
Re: At a first glance here are a few suggestions: check1 is not running. Your code is faulty because once check1==0 it should come out of the for loops because there is no need for further iterations which it is not. check2 is unable to check the first word for previous … | |
Re: Please use Code Tags [CODE] #include<iostream> #include<iomanip> #include<string> using namespace std; double catererCal(); //function declration double discountCal(); //functin declaration void printBill(); //function declaration int adults; int children; double ameals; double cmeals; char mealtype; char weekend; string mealtype2; double deposit; double dmeals=15.80; double smeals=11.75; double foodtotal; double surcharge; double totalbill; double … | |
Re: line 65 n is wrong and in line 75 for loop is wrong | |
Re: What exactly will the precision method acheive? also explain what is error. | |
Re: added a ondraw() function which draws a filled rectangle when flag is true and its boundary only when flag false. You can change the character easily. call it from main(). [CODE] #include <iostream> #include<iomanip> using namespace std; class Rectangle { private: double height; double width; char ch; bool val; public: … | |
Re: Your while statement does not check anything. The continue and breaks are inappropriate. Scanf is C and input in c has nothing to do in the program. You can use a do while loop like [CODE] # include <stdio.h> # include <iostream> using namespace std; int main() { int a,b,c; … | |
Re: [CODE] #include<iostream> #include<fstream> #include<string> using namespace std; int main() { int count=0; string str; cout<<"Enter string: "; cin >> str; for(int y=0;y<str.length();y++) { if (isdigit(str[y])) /* or if((int)str[y]>47 && (int)str[y]<58) */ { cout<<str<<endl; } } return 0; } [/CODE] | |
Re: >>can u make me a multiplication table using a for loop and arrays in c++??? plsss can u?? Arrays wont be required here. Try this. [CODE] int main() { int num; cout<<"Enter table no.: "; cin>>num; if(num>0) { for (int x=1;x<=20;x++) { cout<<num<<"x"<<x<<"="<<num*x<<endl; } } else { cout<<"Not a valid … | |
Re: You can try this: [CODE] #include<iostream> #include<math.h> using namespace std; int main() { int y=0; cout<<"Number of times"; cin>>y; for(int n=0;n<y;n++) { char str[5]; cout<<"Enter 5 nos.: "; cin>>str; if(!str) return 0; for (int count=0;count<5;count++) { cout<<pow(str[count]-'0',1)<<" "<<pow(str[count]-'0',2)<<" "<<pow(str[count]-'0',3)<<endl; } } return 0; } [/CODE] | |
Re: [CODE] #include<iostream> using namespace std; int sumdigits(int x) { int total = 0; while(x>0) { total+=(x%10); x/= 10; } return total; } int main() { int number=0; cout<<"Enter a number"; cin>>number; int result=sumdigits(number); if(result<10) { cout<<"Total is: "<<result<<endl; exit(0); } while(result>9) { result=sumdigits(result); } cout<<"Total is: "<<result<<endl; return 0; } … | |
Re: You can try out this. Only you cannot press enter after the ending line. #include<iostream> #include<fstream> using namespce std; int main() { int x=0, y=1; char ch; ifstream in("file.txt"); while(in.get(ch)) { if (ch!='\n' && isspace(ch)) { x++; } else if (ch=='\n') { cout<<"Line"<<y<<":"<<x+1<<endl; x=0; y++; } } return 0; } | |
Re: >>Can you think of another way to get populate the scores array, other than a for loop? Thats pretty simple to code. But sice you asked [CODE] #include<iostream> using namespace std; int main() { double marks1[1],marks2[1],marks3[1],marks4[1],marks5[1]; int x=1; while(x<=5) { int total=0; int average; cout<<"Enter 5 marks for student"<<" "<<x<<":"<<endl; … | |
Re: Assuming NumTemperatures is greater than 9. [CODE] void DisplayTemperatures(int Temperatures[], int NumTemperatures, int AverageTemp, int lowTemp, int highTemp) { cout << fixed << setprecision (2); cout << "Hour" << setw(9) << " Temperature\n"; for (int x=0;x<10;++x) { cout<< setw(2) << "0" << x << ":00" << setw(7) << Temperatures[x] << … |
The End.