Saturday, January 31, 2009

Mobile masti

mobimaza

mobimasti

mobango

sonuwap

C PROGRAMING assignments

/* to input any no.upto 9 digits and print its reverse */
/* nishith's program*/
#include
#include
void main()
{
clrscr();
long int a,b=0,i,c,d,e=0,f,g=1,h=0;
printf("enter any no. ");
scanf("%ld",&a);
if (a<0)
{ printf("\nthe no.is negative");
a=-a;
h=1;}
f=a;
for (f;f>0;f=f/10)
{ b=b+1;
g=g*10; }
g=g/10;
printf("\nthe input no. is a %ld digit no.",b);
for (i=b;i>0;i--)
{
c=a%10;
d=c*g;
e=e+d;
a=a/10;
g=g/10;
}
if (h==1) {e=-e;}
printf("\the reverse no. is %ld ",e);
getch();
}



/* interchange of values by use of third variable*/
#include
#include
void main()
{
clrscr();
int num1,num2,num3;
printf("ENTER ANY TWO NUMBERS\n");
scanf("%d%d",&num1,&num2);
num3=num1;
num1=num2;
num2=num3;
printf("the interchanged value of first no. is %d\n",num1);
printf("the interchanged value of second number is %d\n",num2);
getch();
}

/* too input a three digit no. and print the reverse of the no. */
#include
#include
void main()
{
clrscr();
int a,b,c,d;
printf("\n enter a 3 digit no. ");
scanf("%d",&a);
b=a%10;
a=a/10;
c=a%10;
a=a/10;
d=b*100+c*10+a;
printf(" the reverse no. is %d ",d);
getch();
}

/* to input 3 no.s and to find the smallest among them */
#include
#include
void main()
{
clrscr();
int a,b,c;
printf("enter any 3 no.s ");
scanf("%d%d%d",&a,&b,&c);
(a getch();
}

/* to find out the size of the datatypes */
#include
#include
void main()
{
clrscr();
int a;
float b;
double c;
char d;
long int e;
printf("\nthe size of int datatype is %d ",sizeof(a));
printf("\nthe size of float datatype is %d ",sizeof(b));
printf("\nthe size of double datatype is %d ",sizeof(c));
printf("\nthe size of char datatype is %d ",sizeof(d));
printf("\nthe size of long int datatype is %d ",sizeof(e));
getch();
}

/* to input any no. and print its reverse */
/*nishith program*/
#include
#include
void main()
{
clrscr();
long int a,b=0,i,c,d,e=0,f,g=1;
printf("enter any no. ");
scanf("%ld",&a);
f=a;
for (f;f>0;f=f/10)
{ b=b+1;
g=g*10; }
g=g/10;
printf("the input no. is a %ld digit no.",b);
for (i=b;i>0;i--)
{
c=a%10;
d=c*g;
e=e+d;
a=a/10;
g=g/10;
}
printf("\nthe reverse no. is %ld ",e);
getch();
}