Thursday, 25 November 2010

largest of 3 numbers using functions

//largest of 3 numbers using functions
#include<stdio.h>
#include<conio.h>
int max(int a,int b)
{
 if(a>b)
  return(a);
 else
  return(b);
}

void main()
{
 int x,y,z,ans1,ans2;
 clrscr();
 printf("enter any 3 values\n");
 scanf("%d%d%d",&x,&y,&z);
 ans1=max(x,y);
 ans2=max(z,ans1);
 printf("largest value is %d\n",ans2);
 getch();
}

Functions

Tuesday, 23 November 2010

display the following output

//display the following output:
55555
55556
55566
55666
56666
66666

#include<stdio.h>
#include<conio.h>
void main()
{
 int i,j,k;
 clrscr();
 for(i=0;i<=5;i++)
 {
  for(k=i;k<5;k++)
  {
   printf("5");
  }
  for(j=1;j<=i;j++)
  {
   printf("6");
  }
  printf("\n");
 }
 getch();
}