simple c program for 12345 convert 54321 with out using string
Answer Posted / ruchi
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int n,r,s=0,i=0,m,r1,m1,m2,p,d,s1;
clrscr();
printf("enter the number ");
scanf("%d",&n);
m=n;
while(n>0)
{
r=n%10;
n=n/10;
i=i+1;
}
m1=m%10;
d=m/10;
p=m1*pow(10,i=i-1);
while(d>=10)
{
m2=d%10;
d=d/10;
s=(s+m2*pow(10,i=i-1));
}
s1=(s+p+d*pow(10,i=i-1));
printf("%d",s1);
getch();
}
| Is This Answer Correct ? | 3 Yes | 0 No |
Post New Answer View All Answers
In C language, a variable name cannot contain?
What is the Purpose of 'extern' keyword in a function declaration?
What is a pointer in c?
What is exit() function?
What is character set?
Difference between pass by reference and pass by value?
What is difference between static and global variable in c?
Are pointers integers in c?
What is the difference between near, far and huge pointers?
What do the functions atoi(), itoa() and gcvt() do?
Explain low-order bytes.
Can you please compare array with pointer?
What would the following code segment printint k = 8;docout << "k = " << k << " ";while k++ < 5; a) 13 b) 5 c) 8 d) pointers
Write a program to identify if a given binary tree is balanced or not.
What is a stream?