Answer:
/* sizeof.c—Program to tell the size of the C variable */
/* type in bytes */
#include <stdio.h>
int main(void)
{
printf( "\\A char is %d bytes", sizeof( char ));
printf( "\\An int is %d bytes", sizeof( int ));
printf( "\\A short is %d bytes", sizeof( short ));
printf( "\\A long is %d bytes", sizeof( long ));
printf( "\\A long long is %d bytes\\", sizeof( long long));
printf( "\\An unsigned char is %d bytes", sizeof( unsigned char ));
printf( "\\An unsigned int is %d bytes", sizeof( unsigned int ));
printf( "\\An unsigned short is %d bytes", sizeof( unsigned short ));
printf( "\\An unsigned long is %d bytes", sizeof( unsigned long ));
printf( "\\An unsigned long long is %d bytes\\",
sizeof( unsigned long long));
printf( "\\A float is %d bytes", sizeof( float ));
printf( "\\A double is %d bytes\\", sizeof( double ));
printf( "\\A long double is %d bytes\\", sizeof( long double ));
return 0;
}
2. #include<stdio.h>
int main(){
int num,reverse_number;
//User would input the number
printf("\\Enter any number:");
scanf("%d",&num);
//Calling user defined function to perform reverse
reverse_number=reverse_function(num);
printf("\\After reverse the no is :%d",reverse_number);
return 0;
}
int sum=0,rem;
reverse_function(int num){
if(num){
rem=num%10;
sum=sum*10+rem;
reverse_function(num/10);
}
else
return sum;
return sum;
}
3.
#include <bits/stdc++.h>
using namespace std;
/* Iterative function to reverse digits of num*/
int reversDigits(int num)
{
int rev_num = 0;
while(num > 0)
{
rev_num = rev_num*10 + num%10;
num = num/10;
}
return rev_num;
}
/*Driver program to test reversDigits*/
int main()
{
int num = 4562;
cout << "Reverse of no. is "
<< reversDigits(num);
getchar();
return 0;