You are on page 1of 3

1.

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();
}

3. Finding String Length Without Using


Strlen function:
char s[20];
int I ,len=0;
printf("Enter the string: ");
gets(s);
for(i=0;s[i]!='\0';i++)
{ len++;
}
printf("\nLength of the string is %c",len);

4. Reversing a string without using


strrev() function:
#include<stdio.h>
#include<conio.h>
void main()
{
char s[20], s1[20];
int i,j,len=0;
clrscr();
printf("Enter the string: ");
gets(s);
for(i=0;s[i]!='\0';i++)
{ len++;
}
for (i=len-1,j=0;;i>=0;i--)
{
S1[j]=s[i];
J++;
}
s[j]='\0';
printf("\nReversed string is %s",s);
getch();
}
5. Deleting a particular character in a string
void main()
{
char s[20],c;
int i,j;
clrscr();
printf("Enter the string:\t");
gets(s);
printf("\nEnter the char to delete:\t");
c=getchar();
printf("%c",c);
for (i=0,j=0;s[i]!='\0';i++)
{
if(s[i]!=c)
{
s[j]=s[i];
j++;
}

}
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);
}

2. Get the String. And try to sort it as


alphabetical order
Ex: Apple Aelpp
3. Replace a particular char in a string
Ex: Apple replace p with s
Assle.
4. Strring comparison without using STRCMP
function.
5. No of occurences of a each char in a string
Ex: Pazhani : p-1,a-2,z-1,h-1,n-1,i-1
6. Splitting the string based on one char
Ex: Pazhani,Prakash,prapaz = one string
Separate char = ,
S1=Pazhnai
S2=Prakash
S3=Prapaz
7. Sum of digits in a no
Ex: 54321= 5+4+3+2+1= 15
8. Replace a particular digit in a no
Ex: replace 5 with 8 in 54543 = 84843
9. Print sum of digits in even position and sum
of digits in odd position
Ex: 5436578
0123456
Sum of Even positions: 5+3+5+8=21
Sum of odd positions : 4+6+7=17
10. Print multiplication table
TRY to work it out all pgms
If u cant pls try to find it via google

Programs to Work out..


1. Get one no as integer. And print no of hours,
no of minutes, no of seconds in tat no
Ex: 1279 21 hours 15 min 4 sec

ALL THE BEST


By
UR WELWISHER

You might also like