C++ Program to accept a number x. Count number of digits in x and store it in n, form y that has the number of digits n at ten's place and the most significant digit of x at one's place. Display y. sample input: x= 16833, y = 51, since no.of digits of x is 5 and 1 is the msd of x
#include<conio.h>
#include<iostream.h>
main()
{
clrscr();
int x,y,z,i,n=0,num, msd, digit;
cout<<"Enter any number as x"<<endl;
cin>>x;
// computing number of digits.
num=x;
while(num>0)
{
digit=num%10;
n=n+1;
num=num/10;
}
msd=digit;
y=n*10+msd;
cout<<"The value of Y is "<<y;
getch();
return 0;
}
Related Posts : C++ Programs
0 comments:
Post a Comment