K
Kevin Handy
Girish said:I will be greatful if any one answers these questions?
Thank You.
1. Write a "Hello World" program in 'C' without using a semicolon.
Ok. 'a "Hello World" program in 'C' without using a semicolon'
2. Write a C++ program without using any loop (if, for, while etc) to
print numbers from 1 to 100 and 100 to 1;
int main()
{
cout << "numbers from 1 to 100 and 100 to 1;" << endl;
}
Why are you asking C++ questions in a C newsgroup?
3. Find if the given number is a power of 2.
What's the given number?
4. Multiply x by 7 without using multiplication (*) operator.
y = pow(10.0, log10(x)+log10(7));
5. Write a function in different ways that will return f(7) = 4 and
f(4) = 7
char* a_function_in_different_ways()
{
return "f(7) = 4 and f(4) = 7";
}
6. Remove duplicates in array
for (loop = 0; loop <= elements; loop++)
array[loop] = 0;
elements = 0;
It also has the added feature of removing the non-duplicates too.
7. Finding if there is any loop inside linked list.
trace = first
while(trace)
{
if (trace.value = loop)
printf("Here it is!");
trace=trace.next;
}
8. Remove duplicates in an no key access database without using an
array
Just delete everything.
It also has the added benefit of removing non-duplicates too.
9. Convert (integer) number in binary without loops.
convert("(integer) number in binary without loop");
Are we supposed to rot13 it, or what?
10. Write a program whose printed output is an exact copy of the
source. Needless to say, merely echoing the actual source file is
not allowed.
int main()
{
printf("an exact copy of the source.\n");
}
11. From a 'pool' of numbers (four '1's, four '2's .... four '6's),
each player selects a number and adds it to the total. Once a
number is used, it must be removed from the pool. The winner is the
person whose number makes the total equal 31 exactly.
So?
No computer in this question. Only several people playing
in the water.
13. Swap two numbers without using a third variable.
temp = a;
a = b;
b = temp;
See, i never used "a third variable" in that code sequence.
I guess you could
temp2 = "a third variable"
temp = a;
a = b;
b = temp;
but it just adds bloat. Or is it supposed to be in a comment?
Do I win any prizes?