Sunday, 13 September 2015

C PROGRAMMING-- REVERSE OF NO.

#include<stdio.h>
#include<conio.h>
void main()
{ clrscr();
int n,r;
printf("enter the no.=\n");
scanf("\n%d",&n);
printf("reverse=\n");
while(n>0)
{ r=n%10;
n=n/10;
printf("%d",r);
}
getch();
}

C PROGRAMMING-- SUM OF DIGITS

#include<stdio.h>
#include<conio.h>
void main()
{ clrscr();
int r,s=0,n;
printf("Enter the no=\n");
scanf("\n%d",&n);
while(n>0)
{ r=n%10;
n=n/10;
s=s+r;
}
printf("sum of digits=%d\n",s);

getch();
}

C PROGRAMMING-- SIZE OF

#include<stdio.h>
#include<conio.h>
void main()
{ clrscr();
int a,d,e,f;
float b;
char c,ch;
printf("integer-a\nfloat-b\ncharacter-c\nENTER CHOICE=\n");
scanf("%c",&ch);
switch(ch)
{ case 'a': d=sizeof(a);
printf("size=%d\n",d);
break;
case 'b': e=sizeof(b);
printf("size=%d\n",e);
break;
case 'c': f=sizeof(c);
printf("size=%d\n",f);
break;
default:printf("wrong input\n");
}
getch();
}

C PROGRAMMING-- ASCII CODES

#include<stdio.h>
#include<conio.h>
void main()
{       clrscr();

char a;
printf("enter the character=\n");
scanf("%c",&a);
printf(" ASCII CODE=%d",a);
getch();
}

C PROGRAMMING-- ARMSRONG NO.


#include<stdio.h>
#include<conio.h>
void main()
{ clrscr();
int n,r,x,s=0,n1;
printf("ENTER THE NO.=\n");
scanf("\n%d",&n);
n1=n;
while(n>0)
{ r=n%10;
n=n/10;
x=r*r*r;
s=s+x;
}
if(n1==s)
{  printf("ARMSTRONG NO.!!!\n");
}
else
{
printf("not a armstrong no.=\n");
}
getch();
}

HOW TO COPY TO TURBO C++

Open a new file in turbo c++, save it blank with any name (say abc.cpp).then go to bin folder of turbo c++. open your file (abc.cpp) using a text editor. paste your code there and then save it. relaunch tc and then open your file.

C PROGRAMMING --TABLE OF A NO.

USING FUNCTION

#include<stdio.h>
#include<conio.h>
void table(int);
void main()
{ clrscr();
int n;
printf("enter the no.=");
scanf("%d",&n);
table(n);
getch();
}
void table(int x)
{ int i,t;
for(i=1;i<=10;i++)
{ t=x*i;
printf("%d\n",t);

}
}

WITHOUT USING FUNCTION

#include<stdio.h>
#include<conio.h>
void main()
{ int i,n;
clrscr();
printf("enter the no.=");
scanf("%d",&n);
for(i=n;i<=(n*10);i=i+n)
{ printf("%d\n",i);
}
getch();

}