write a program that takes 5 digit no and calculate 2 power
that no and print it.

Answers were Sorted based on User's Feedback



write a program that takes 5 digit no and calculate 2 power that no and print it...

Answer / venkataramakrishna.danduri

#include <iostream.h>

void main()
{
int b = 0;
int num5digit;
cin>>num5digit;
b = 1<< num5digit;
cout<<"b = "<<b;
}

Is This Answer Correct ?    0 Yes 0 No

write a program that takes 5 digit no and calculate 2 power that no and print it...

Answer / kathir

#include<iostream.h>
void main()
{
int a,n=0;
cout<<"Enter the 5 didgit no:"<<endl;
cin>>a;
n=(a*a);
cout<<"The two power given no is:"<<n<<endl;

}

Is This Answer Correct ?    4 Yes 6 No

write a program that takes 5 digit no and calculate 2 power that no and print it...

Answer / yeah

#include<iostream.h>
#include<math.h>
void main()
{
int a,n=1,i;
cout<<"enter Num";
cin>>a;
//n=pow(2,a);
for(i=0;i<a;i++)
n*=2;
cout<<n;
}

Is This Answer Correct ?    3 Yes 6 No

Post New Answer

More C++ General Interview Questions

Define copy constructor.

0 Answers  


Which is best c++ or java?

0 Answers  


What is c++ stringstream?

0 Answers  


Give example of a pure virtual function in c++?

0 Answers  


Why we use #include conio h in c++?

0 Answers  






What is c++ hash?

0 Answers  


Is there any function that can skip certain number of characters present in the input stream?

0 Answers  


Does c++ vector allocate memory?

0 Answers  


What is a parameterized type?

1 Answers  


What is the difference between #import and #include in c++?

0 Answers  


Is it possible to use a new for the reallocation of pointers ?

0 Answers  


how can i access a direct (absolute, not the offset) memory address? here is what i tried: wrote a program that ask's for an address from the user, creates a FAR pointer to that adress and shows it. then the user can increment/decrement the value in that address by pressing p(inc+) and m(dec-). NOW, i compiled that program and opened it twice (in 2 different windows) and gave twice the same address to it. now look what happen - if i change the value in one "window" of the program, it DOES NOT change in the other! even if they point to the same address in the memory! here is the code snippet: //------------------------------------------------------ #include <stdio.h> //INCLUDE EVERY KNOWN HEADER FILE #include <conio.h> //FOR ANY CASE... #include <iostream.h> #include <dos.h> #include <process.h> main() { int far *ptr; //FAR POINTER!!! long address; char key=0; //A KEY FROM THE KEYBOARD int temp=0; clrscr(); cout<<"Enter Address:"; cin>>hex>>address; //GETS THE ADDRESS clrscr(); (long)ptr=address; temp=*ptr; //PUTS THE ADDRESS IN THE PTR cout<<"["<<hex<<(unsigned long)ptr<<"]="<<*ptr<<" = "<< (char)(*ptr); //SHOWS: [address]=value=ASCII symbol. while (key!=27) //WHILE YOU DONT PRESS ESC. { while(!kbhit()) //WHILE KEY IS NOT PRESSED { if (temp!=*ptr) { temp=*ptr; clrscr(); cout<<"["<<hex<< (unsigned long)ptr<<"]="<<*ptr<<" = "<<(char)(*ptr); }; //IF THE VALUE HAS CHANGED, CLEAR THE SCREEN AND SHOW //AGAIN if (key=='p') {key=0; (*ptr)++; } //INCREMENT VALUE if (key=='m') {key=0; (*ptr)--; } //DEC. VALUE }; key=getch(); //IF A KEY IS PRESSED, READ IT FROM THE //KEYBOARD }; return 0; //IF ESC WAS THE KEY, EXIT THE PROGRAM } //---------------------------------------------------------

0 Answers  


Categories