Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Reverse the part of the number which is present from
position i to j. Print the new number.[without using the array]
eg:
num=789876
i=2
j=5
778986

Answer Posted / mahfooz alam

#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cmath>
using namespace std;
int getdnum(int num)
{
int numd=0;
while(num!=0)
{
numd++;
num=num/10;
}
return numd;
}
int reversenum(int i,int j ,int d,int num)
{
int a=(num/(pow(10,d-i+1)));
int b=(num/(pow(10,d-j)));
int c=num%static_cast<int>(pow(10,d-j));
int n=0;
int k;
for(k=0;k<=(j-i);k++)
{
n+=(b%10)*(pow(10,j-i-k));
b=b/10;
}
n=a*pow(10,d-i+1)+c+n*pow(10,d-j);
return n;

}
int main()
{
int i,j,k,l,m;
cin>>i>>j>>k;
int d=getdnum(i);
m=reversenum(j,k,d,i);
cout<<m<<endl;
return 0;
}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain how do you determine whether to use a stream function or a low-level function?

1026


What is the importance of c in your views?

1094


please give me a VIRTUSA sample palcement papers.... you will only send TECHNICAL SECTION..... that is help for me Advance Thanks........................

1954


What is pivot in c?

974


Explain can the sizeof operator be used to tell the size of an array passed to a function?

1016


Explain the use of keyword 'register' with respect to variables.

969


What are variables and it what way is it different from constants?

1191


code for find determinent of amatrix

1917


the process of defining something in terms of itself is called (or) in C it is possible for the functions to call themselves. A function called a) nested function b) void function c) recursive function d) indifinite function

1265


How are pointers declared in c?

1006


What is the difference between class and object in c?

1089


Is it acceptable to declare/define a variable in a c header?

1060


What is dangling pointer in c?

1133


What is the role of this pointer?

994


What is difference between main and void main?

1117