write a program to find 2 power of a 5digit number with out
using big int and exponent ?



write a program to find 2 power of a 5digit number with out using big int and exponent ?..

Answer / Jitendra Pratap Singh

In C++, you can use bit manipulation to calculate the square of a 5-digit number without using BigInt or exponent. Here's an example:

```cpp
#include <iostream>
using namespace std;

void square(int num) {
int square = num << 1;
if (num & 1) { // If the least significant bit is set, add the number itself
square |= num;
}
}

int main() {
int num;
cout << "Enter a 5-digit number: ";
cin >> num;
square(num);
cout << "The square of the given number is: " << square << endl;
return 0;
}

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More OOPS Interview Questions

what is data abstraction with example.

1 Answers  


What is differance between Abstract and Interface

3 Answers  


What is difference between #define and const?

3 Answers   emc2,


What does <> mean pseudocode?

1 Answers  


What is abstraction in oop with example?

1 Answers  


1234554321 1234 4321 123 321 12 21 1 1 12 21 123 321 1234 4321 1234554321

2 Answers  


#include <iostream> using namespace std; struct wow { int x; }; int main() { wow a; wow *b; a.x = 22; b = &a; a.x = 23; cout << b->x; return 0; }

1 Answers  


What is the correct syntax for inheritance? 1) class aclass : public superclass 2) class aclass inherit superclass 3) class aclass <-superclass

6 Answers   Wipro,


What is byval and byref? What are differences between them?

1 Answers   HCL, Wipro,


Question: Implement a base class Appointment and derived classes Onetime, Daily, Weekly, and Monthly. An appointment has a description (for example, “see the dentist”) and a date and time. Write a virtual function occurs_on(int year, int month, int day) that checks whether the appointment occurs on that date. For example, for a monthly appointment, you must check whether the day of the month matches. Then fill a vector of Appointment* with a mixture of appointments. Have the user enter a date and print out all appointments that happen on that date.

1 Answers  


Get me a number puzzle game-program

1 Answers  


What is difference between data abstraction and encapsulation?

1 Answers  


Categories