Puzzle Corner
Sign In
Home
Feedback
Blog
Resources
About
Starred
Add Question
All (696)
coding (266)
c++ (157)
algorithms (151)
puzzle (134)
CS Fundamentals (83)
oop (55)
arrays (45)
internet (40)
string (34)
math (31)
databases (28)
system (26)
probability (26)
networking (25)
linkedlist (24)
binarytrees (24)
tree (22)
bit manipulation (19)
sorting (11)
stack (10)
bst (9)
java (8)
xml (8)
sql (7)
next in series (7)
traversal (6)
graph (4)
debugging (4)
lateral thinking (4)
palindrome (4)
mysql (4)
prime (4)
general (4)
unix (3)
CGI (3)
duplication (3)
threading (3)
random (3)
search (3)
fibonacci (3)
encryption (3)
joins (3)
hash (3)
queue (3)
asm (3)
design patterns (2)
Random
What’s wrong with this code?
[
2007-02-26 23:42:22
]   
Assuming the function lookupName is defined, what’s wrong with this code (hint: 2 bugs)?
const char *getName(const char *c) {
std::string name = lookupName(c);
if (name == NULL)
return "Anonymous";
return name.c_str();
}
int main(int argc, char *argv[]) {
const char *name = NULL, *c = NULL;
if (argc >= 2)
c = argv[1];
name = getName(c);
printf("My name is %s ", name);
return 0;
}
link
Author
:
prem
Tags
:
coding
|
c++
Answer
Find missing number
[
2007-02-26 23:42:18
]   
Given a consecutive list of numbers from a to b, one number is removed.
The list is then scrambled. Find the missing number.
int find(int a, int b, int *array);
hint: sum(1 to n) is n(n+1)/2
using the same logic, sum(a to b) is (b-a)/2 * (b+a)
link
Author
:
prem
Tags
:
algorithms
|
arrays
Answer
Generating nth fibonacci number
[
2007-02-26 23:42:18
]   
function generate nth fibonnaci number
- what's the largest n could be?
link
Author
:
prem
Tags
:
algorithms
|
coding
|
fibonacci
Answer
Fibonacci numbers
[
2007-02-26 23:42:17
]   
Write a function to print the Fibonacci numbers.
link
Author
:
prem
Tags
:
coding
|
fibonacci
Answer
Created by
Premchand Jayamohan