Professional Documents
Culture Documents
Printing Alphabets:
void main()
{
int c,ch=97,i,j;
char c1;
clrscr();
for (c=97;c<122;c++)
printf("%c",c);
}
2. Decimal To Binary Conversion:
#include<stdio.h>
##include<conio.h>
void main()
{
int m,k=1,s=0,l,n;
clrscr();
printf("\nEnter the value:\t");
scanf("%d",&n);
while (n>0)
{
m=n%2;
n=n/2;
l=m*k;
s=s+l;
k=k*10;
}
printf("\n%d",s);
getch();
}
}
s[j]='\0';
printf("\n String aft d deletion: %s",s);
getch();
}
Integers:
1. How to Separate the digits in a No :
Example: n=12345
n=n/10 - > n=1234
n=n%10 - > n=5
% -> gives remainder.
%10 -> gives last digit;
/10 -> gives the no without last digit.
%100 -> gives last two digits
/100 -> gives No without last two digits.
Similiarly for 1000,10000 etc;
2. Find the No of digits in a no:
Void main()
{
int n,len=0;
printf( Enter the No: );
scanf(%d,&n);
while (n!=0)
{
n=n/10;
len++;
}
Printf(No of digits = %d,len);
}