581 Posted Topics
Re: You can use something like if [code] if (isalpha(a))//Here 'a' is just a variable in which a character is filled in { cout<<"Invalid"; } [/code] Youshould include the header cctype for this function. It detects if the input is an alphabet and if it is it executes the statement. | |
Re: What is a pipe which is mentioned above. I dont know much so i get this doubt | |
Re: I guess you can write your password into a txt file and then access it when ever you want. But the bad part is that anyone else can directly open up the txt file and know what your password is. | |
Re: [QUOTE=Mark515;587966]it doesnt work![/QUOTE] Well mark, niek_e is only giving you an example on how it is done. You can try experimenting in that code to get the answer though. Something like this will work out fine. [CODE]#include <iostream> using namespace std; static const int password=1705898; int main() { int secondnumber; … | |
Re: Till what have you got to? I mean paste in the program that you have worked on until now. | |
Re: Try typing 8 instead of 08 [code]case 08:[/code] and replace it by [code]case 8:[/code] That is the only reason it is invalid | |
Re: [QUOTE=Black Magic;586955][CODE=C++]#include <iostream> using namespace std; double FindArea(double& l, double& w); int main() { double width, lenght, area; cout << "How Wide Is Your Yard? : "; cin >> width; cout << endl << "How Long Is Your Yard? : "; cin >> lenght; area = FindArea(width, lenght); cout << … | |
Re: [QUOTE=niek_e;585947]You need to know about - 2-dimensional arrays - random number generating - user input What do you have so far?[/QUOTE] Yes The two dimensional array can be a pointer pointing to a one dimensional array. So that it will be very easy to allocate. And use a forever loop … | |
Re: What problems do you have in writing the code. Post your code and then we can see. Whats wrong with it. | |
Re: Well i have worked out the code. And found that with some small corrections this code is working out. The first mistake is in the declaration in line 6 doesnt match the declaration in line 23 [code]unsigned int romnum (string);[/code] Instead of that you can try using a character . … | |
Re: You can try to bruteforce it out and just increment by 0.01 maybe that will work out. But the answer wouldnt be exact. So u can try in for an approx val. Then test it up. If the value you got. is squared is lesser than the main number of … | |
Re: [code]for (i=25; 25>=i; i=i-2) { //if (i%2!=0) cout<<i<<" "; } cout<<endl; [/code] if you observe carefully.. You will find the error. this is what you have written: [code]for (i=25; 25>=i; i=i-2)[/code] in the above observe this [code]25>=i;[/code] it should actually show the lower parameter of your problem. | |
Hi all, I am currently working on a program which tests whether 2 numbers multiplied produces a PALINDROME. An example of a palindrome is 16461 which can be read same from both ways hence i devised a test. [CODE=cplusplus]#include <iostream> #include <string> using namespace std; char pali(char orig[100]); int main() … | |
Re: Hello, I would like to know which Operating System you are actually using. For example if you are using a windows based operating system and the command prompt the command for the clear screen is [CODE]system(cls);[/CODE] Where as for some other operating systems it is [CODE]system(clear);[/CODE] So if you are … | |
Re: You can try taking in a vector char array. That way enough Memory will be allocated depending upon the input .. So you will not need to make such a huge array. | |
Re: Hello , I have solved out the code in your program and you can take in the code below. But there are a few backfalls to the program which i was not able to correct because i am still a beginener in programming. they are 1) The keyword should contain … | |
Hello Everyone , I am writing a code in which i search a char array and look at what is missing in the array i mean what letters are missing in the array. I worked out a small code but i seem to have some error in the answer though … | |
Re: Hello Trckst3, I have noticed some faults in your program code. 1) Firstly you wont be needing the Libraries [CODE]#include <iomanip> #include <algorithm>[/CODE] In your program. 2) The Bubble Sort Function in your program is faulty. I will give you a small reference(idea) in which you can proceed in, Take … | |
Re: Well in the code that you have mentioned i dont see the code of the ambulance call . All i just see is other code. There is some other code though. You should paste the code that you have worked out on the compiler so that we can sovle it. | |
Re: I only got 2 errors with the upper program: 1) the main () cannot be void with my compiler so i put in int main() 2) The function Clrscr(); is invalid. If you wanted to use the clear screen function then you can type cls; instead of it. Thats it … | |
Re: Hey for the menu's instead of using the If (Conditons ) And testing it to a char . You should try using the Switch operator as it is a cleaner code then the If.. AND else if.. | |
Re: Absolute value also gets off the decimal places from the number. For eg: abs(3.42) returns 3 | |
Re: Well i would like you to be more clear in the question . Do you want a number that is lesser than 10 Or do not want spaces in between while entering. Because. If there is a space between 2 numbers and you use the command cin>> then it will … | |
Re: Well this happens to me too. Most of the time. And therefore i use multiple cin.get() codes and also if possible i add another cin statement into the code to view the answer. So try adding the following [code] std::cin >> x; [/code] | |
Re: its very easy to remove the percentage out. Lets consider the marks entered as 'x' therefore we need to remove 20% from the marks entered .............. That is 20% of X Let "newX=20% of X" therefore you can use this "newX= (20/100)*X" So we know know X and the marks … | |
Re: You can have namespaces and include some of your functions in a separate namespace. Then use the namespace i guess. If you can make function.h containing the namespace "namespace1" then i think... (This will be the code for that ) #include <function.h> using namespace namespace1; int main(){ function 1(); } | |
Re: [QUOTE=dolphin.rise;566046]I have a confusion : Is there any specific advantage of using int main() over void main() in c++ programs. Can anybody solve it ?[/QUOTE] Well,I think main() is probarbly Generalised and the computer basically will not expect a specific type from the program. Where as int main () tells … | |
Re: Try the else statement. I dont know but i get the correct answers when i made a few adjustments in the code. [code=cplusplus]cout << "please select which pattern: "; cin >> pattern; if ( pattern == '1' ) { target1 = 1; target2 = 0; } else ( pattern == … | |
Re: Well you actually forgot to put in some main code. [CODE]#include<iostream> using namespace std; int main() { int NumOfSold,SolValue; float average; cout<<"enter the number of sold items\n"; cin>>NumOfSold; cout<<"enter the sold value for each item\n"; cin>>SolValue; average=SolValue/NumOfSold; cout<<NumOfSold<<":"<<SolValue<<endl; cout<<"average:"<<average; }[/CODE] In your code. "Using namespace std;" was not written And … | |
Re: Hello Everyone ., This is my first post in this forum. However to get the prime numbers between 5 to 10000 you can do this First you will need to check whether the number is divisible by 2. [code] bool prime(int x) { If ((x%2)!=0) { if((x%3)!=0) { if ((x%5)!=0) … | |
Re: [CODE]for (i=0;i<=n;i++) int no; no=n*ii; } for (i=0;i<=n;i++) cout<<i<<':'<<no<<endl;[/CODE] This is your existing code : Try this one in the place of it [CODE]for (i=0;i<=n;i++) {int no; no=n*i; cout<<i<<':'<<no<<endl; }[/CODE] Hope this works . |
The End.