- Strength to Increase Rep
- +0
- Strength to Decrease Rep
- -0
- Upvotes Received
- 1
- Posts with Upvotes
- 1
- Upvoting Members
- 1
- Downvotes Received
- 0
- Posts with Downvotes
- 0
- Downvoting Members
- 0
17 Posted Topics
I dont know that high math, but I think I can do better. [CODE] bool isPrime(int n) { bool prime ; int lim; if ( n == 0 || n == 1 || n % 2 == 0) return(false); prime = true; lim = (int)sqrt(n); for(int i=3; i<= lim && …
[CODE] The logic should be like this : while ( input != 13 ) { if input is '(' or '{' or '[' or ')' or '}' or ']' { if input is '(' or '{' or '[' push it into the stack. else if input is ')' or '}' …
I can tell you on unix. To create a parent, you run a process. To create a child for this process, use fork. further is family of exec() function's.
I too failed to solve "A 'C' program without using any loop (if, for, while,etc...) to print numbers." unless it is somthing like [code] printf("1, 2, 3, 4....\n"); [/code] ;) Google nither helped. Any ideas ?
This is/was an interview question I got two weeks ago. Find where the loop begins in simple linked list. I hope this figure will help understand what I mean : [code] [LEFT][1] ->[2] ->[3] ->[4] ->[5] ^ | | U [10] [6] ^ | | U [9]<- [8]<- [7][/LEFT] [/code] …
By saying "how i can find a loop in simple linked list" do you mean like in my little drawing ? ( In a "normal linked list cell 10 would have point to NULL") [code] [1] ->[2] ->[3] ->[4] ->[5] ^ | | U [10] [6] ^ | | U …
[code] void insertSortedList (Node **head, int value) { /* creating a new node */ Node *ptr = createNode (value); Node **pCurrent = head; /* adding the new node to the correct place in the list */ while (*pCurrent != NULL && (*pCurrent)->val < ptr->val) pCurrent = &( (*pCurrent)->next ); ptr->next …
I am not sure I understand you. But if you want to replace found words in the puzzle with dots, here goes : first change : [CODE] char puzzle[MAXLENGTH][MAXLENGTH]; [/CODE] to [CODE] typedef struct { char ch; int isdot; }PUZZLE_S ; PUZZLE_S puzzle[MAXLENGTH][MAXLENGTH]; [/CODE] while reading the puzzle from the …
>> my program doesn't brake, when '0' is entered as the buss number Because you break from the for loop, but not from the while loop. I suggest a flag like "tocont" [CODE] tocont = 1; while ( tocont ) { for(int i=0;i<4;i++) { if(nr==0) { tocont = 0; break; …
Your coping the same value (temp) for all the fileds : [CODE] strcpy(newCat->categoryID, temp); newCat->drinkType = temp[0]; strcpy(newCat->categoryName, temp); strcpy(newCat->categoryDescription, temp); [/CODE] You should use the pointers you saved like for example : [CODE] strcpy(newCat->categoryDescription, catDescription); [/CODE] Another thing : Automatic variables inside a fucntion are initailzed to garabge. [CODE] …
Maybe its installed but not in your path. try to run as root. find / -name gcc I cant belive it wasnt installed with default installtion.
first of all you did'nt initalize i !!! The a close look at this program. [CODE] int product(int n); int main(void) { char buf[100]; int num; printf("Enter number for porduct : "); fgets(buf, sizeof(buf), stdin); num = atoi(buf); num = product(num); printf("num = %d\n", num); printf("Press enter to end ....\n"); …
The declatrion of class is good. [CODE] class project { public: project(); int get_value(); void sort_values(int value[]); void search_values(int value[]); private: int value[15]; }; [/CODE] So, why did declare "int value[15]" again in function main. And what is this : [CODE] project::project() { value[15]; } [/CODE] what does that do …
You have at least two errors : 1) The function call. 2) Variable declartion. The a look at this program. [code] /* function prototype. For every call to print, the compiler will check number of arguments, and thier data type. */ void print(const char buf[], int num); int main(void) { …
Why do you hate fgets. Its my faviorate function. [CODE] char* fgets(char *s, int n, FILE *stream); [/CODE] fgets reads at most the next n-1 characters into the array s, stopping if a newline is encounterd; the newline is included in the array, which is terminated by '\0'. fgets returns …
[quote=turkish_girl]my delete operation doesn't work.the element which is added last is being deleted.ı want to delete the one ı want; not the last entered.how can ı do that?can you help me?thank you very much for your consideration...[/quote] Take a close look at the code I replaced. Try to compile with …
One error : [CODE] ptr.credit [/CODE] ptr is a pointer to array. The permssion problem with : [CODE] ptr[i].credit [/CODE] credit was declared private in class course. So only members of this class may acess credit. Two solution : a: Change credit to public . This is ugly. b: let …
The End.
dude543