Monday, November 29, 2010

// pen pencil algorithm

#include
#include
void main()
{
int num1,num2,sum=0,res=0,m=1,temp=0;
printf("enter the numbers");
scanf("%d%d",&num1,&num2);
while(num2) // works until num2 becomes
{
sum=0; //initialize sum
rem=num2%10;
num2/=10;
sum=num1*rem;
temp=sum*m;
printf("%d",temp);
res=res+temp; //adds two products
m*=10;
}
printf("%d",res);
getch();
}

//largest difference among elements given

//largest difference among elements given
#include
#include
void main()
{
int i,j,big,small,diff;
int a[5];
clrscr();
printf("enter the no");
for(i=0;i<5;i++) big="small=" i="0;i<5;i++)" big="(a[i]">big)?a[i]:big;
small=(a[i]
}
printf("\n%d is the largest difference ", big-small);
getch();
}


Wednesday, November 24, 2010

prg.no:2 to form given data by the form lines

//to form given data by the form lines

#include
#include
Void main()
{
int r,q,I,n,cnt=0;
clrscr();
printf(“\n enter the no:”);
scanf(“%d”,&n);
q=n;
While(q)
{
R=q%10;
q=q/10;
cnt++;
}
for(i=pow(10,cnt),q=n;i>1;i=i/10)
{
r=q/I;
Printf(“%d\n”,r);
}

getch();
}

Sample input: 5789
Sample output:
5789
789
89
9

prg.no:1 square using given input

//to form square using given input

#include
#include
Void main()
{
int i,j,n;
clrscr();
printf(“enter the number from 2 to 9”);
scanf(“%d”,&n);
for(i=0;i {
for(j=0;j {
if(i==0i==n-1j=0j==n-1)
{
printf(“%d”,n);
}



else
{
Printf(“ ”);
}

}
printf(“\n”);
}
getch();
}

Friday, November 19, 2010

#include
#include
void main()
{
printf("helloworld");
getch();
}
திஸ் இஸ் மி பிரஸ்ட் ஸ்டேப் ஒன ப்ளொக்ஸ்
திஸ் இஸ் மி பிரஸ்ட் ஸ்டேப் ஒன ப்ளொக்ஸ்