Write a C program to reverse a given number.
OUPUT:
enter the number 21334
The reverse of number is 43312
PROGRAMS:
#include<stdio.h>
int sum(int);
int main()
{
int n;
printf("enter the number ");
scanf("%d",&n);
int c=sum(n);
printf("The reverse of number is %d ",c);
}
int sum(int n)
{
int r,rev=0;
while(n!=0)
{
r=n%10;
rev=rev*10+r;
n=n/10;
}
return rev;
}
Structures in C is a user-defined data type available in C that allows to combining of data items of different kinds. Structures are used to represent a record.
Defining a structure: To define a structure, you must use the struct statement. The struct statement defines a new data type, with more than or equal to one member. The format of the struct statement is as follows:
struct [structure name] { member definition; member definition; ... member definition;...