CLICK HERE FOR NEXT PAGE
CLICK HERE PREVIOUS PAGE
Programs

BIGGEST NUMBER

#include<stdio.h>
main()
{
int x,y,big=0,sbig=0;
clrscr();
x=0;
while(x<10)
{
scanf("%d",&y);
if(y>=big)
big=y;
if(y!=big)
{
if(y>=sbig)
{
sbig=y;
}
}
x++;
}
printf("the first biggest=%d\nthe second biggest=%d",big,sbig);
getch();
}

To Find Binary Value Number Program:

main()
{
int n,i=0,j,a,g=1;
clrscr();
scanf("%d",&n);
j=n;
while(j>1)
{
a=j%2;
g=a+g*10;
j=j/2;
}
n=g;
printf("The bin value is %d\n\n",g);
while(n>0)
{
n=n/10;
i++;
}
while(i<8)
{
printf("0");
i++;
}
printf("%d",g);
}

While Loop Program:
void main()
{
int a=1;
clrscr();
while(a<=20)
{
if(a%2==0)
printf("%d is even\n",a);
else
printf("%d is odd\n",a);
a=a+1;
}
}                                                      FOR MORE PROGRAMS

 

FIBONOCC PROGRAM

#include<stdio.h>
main()
{
int i,j,k,count,a;
clrscr();
scanf("%d",&a);
i=j=1;
k=count=0;
for(;count<=a;count++)
{
printf("%d\n",i);
i=j+k;
k=j;
j=i;
}
getch();
}

/
COMPARE TWO STRINGS USING POINTERS
void main()
{
char a[20],b[20];
int m;
clrscr();
printf("Enter the first string\n");
scanf("%s",a);
printf("Enter the second string\n");
scanf("%s",b);
m=scmp(a,b);
if(m==0)
printf("The given strings are equal");
else
printf("The given strings  are not equal");
getch();
}
scmp(char *t,char *s)
{
int m=1;
while(*s && *t!='\0')
{
if(*t==*s)
m=0;
s++;
t++;
if(*t!=*s)
m=1;
break;
}
return m;
}

 

COPY ONE STRING TO ANOTHER USING POINTERS

void main()
{
char source[20];
char target;
clrscr();
printf("Enter the string\n");
scanf("%s",source);
xstrcpy(target,source);
printf("the source string is %s\n",source);
printf("The target string is %s\n",target);
getch();
}
xstrcpy(char *t,char *s)
{
while(*s!='\0')
{
*t=*s;
s++;
t++;
}
*t='\0';
}