Better solution

Status
Not open for further replies.

goelvivek

Right off the assembly line
Some good question asked at rgec meerut.You can download their solution at
*www.goelc.blogspot.com/
please provide me better solution for these questions
Phase 1
Q:1‐>WAP TO FIND OUT THAT IS NO IS POWER OF TWO OR NOT. (WITHOUT USING LOOP)
Q:2‐> WAP TO PRINT THE ALL COMBINATION OF STRING “ABC”.
Q:3‐>WAP TO DO THE SUM OF ALL DIGITS OF A NO UNTILL ANS HAS ONLY ONE DIGIT(WITHOUT
USING LOOP)
EX:‐5699
=>5+6+9+9=29
=>2+9=11
=>1+1=2
Q:4‐>WAP TO PRINT STRUCTURE LIKE
1
2 2
3 3 3
4 4 4 4
Q:5‐>WAP TO REMOVE THE FROM THE SENTENCE ENTER BY THE USER.
EX:‐> THIS IS THE TABLE.
=>THIS IS TABLE




PHASE 2
Q:1‐>WAP TO PRINT THE FILE NAME FROM WHICH PROGRAM IS EXECUTED.
Q:2‐>WAP TO MAKE A STRING PALINDROME
EX:‐>IIT
=> ITI
Q:3‐>WAP TO PRINT SPARSE MATRIX
EX:‐>
1 2 3 4
12 13 14 5
11 16 15 6
10 9 8 7
 

QwertyManiac

Commander in Chief
P1:

1. Number & Number-1 == 0 (For Number to be power of 2)

2. Permutation Algorithm at Wikipedia or look for an example with standard C++ here.

3. You're using recursion instead of loop. Clever enough I'd say.

4. Triangles, meh. Anything that gives that output will do. :))

5. String Class function - replace (C++). Replace "THE " with "" and for safety, check "THE" with "" too. ("" is null string, and the second "THE" is without the trailing space)

Will check up on Phase 2 later, but by the looks of it, its good enough. Not checked in detail as I haven't attempted the last two ones yet.
 
Status
Not open for further replies.
Top Bottom