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


Please Help Members By Posting Answers For Below Questions

Is c still relevant?

637


Why we not create function inside function.

1744


What is the difference between far and near in c?

599


Is r written in c?

722


main() { struct s1 { char *str; struct s1 *ptr; }; static struct s1 arr[] = { {"Hyderabad",arr+1}, {"Bangalore",arr+2}, {"Delhi",arr} }; struct s1 *p[3]; int i; < BR> for(i=0;i<=2;i++) p[i] = arr[i].ptr; printf("%s ",(*p)->str); printf("%s ",(++*p)->str); printf("%s ",((*p)++)->str); }

910






What does main () mean in c?

610


What are the key features in c programming language?

607


what does static variable mean?

649


What are static variables in c?

627


What is the size of array float a(10)?

651


Hai,I have done with my bachelor of commerce and planing to ms,please suggest me how to convince vo for shifting from commerce to computers. Visa on 8 DEC 2014  Npu university

1594


C program to find all possible outcomes of a dice?

1851


What are the restrictions of a modulus operator?

629


Why is main function so important?

611


What are the features of c languages?

624