Sunday, March 21, 2010

Digital Clock Using Java Script

Interchanging two number without using third variable

#include
main()
{ void swap(int,int);
int num1,num2;
char ch;
do{
clrscr();
printf("\n Enter two numbers one by one:-\n");
scanf(%d %d",&num1,&num2);
printf("\n Before swaping The Two Numbers are:-%d , %d",num1,num2);
swap(num1,num2);
printf("\n Want to continue? (Y/N):");
ch=getch();
}
while(ch=='y' || ch=='Y');

getch();
}
void swap(int n1,int n2)
{
n1=(n1+n2)-n1;
n2=(n1+n2)-n2;
printf("\n After swaping two numbers become %d , %d",num1,num2);
}

Saturday, March 20, 2010

This is what I feel ........

I always try to concentrate the mind on the present moment.....
Sometime I say Sorry ,It's does not mean that I'm wrong and other person is right,
any relationship is more valuable for me than my ego.
I love to see Sunshine....... I want to touch the sky with my determination.

Multiplication of two matrices using functions

#include
void input_matrix(int[][],int,int);
void output_matrix(int[][],int,int);
void multiply(int[][],int[][],int[][],int,int,int);
main()
{
int mat1[100][100],mat2[100][100],mat3[100][100];
int m,n,l;
char ch;
do
{
clrscr();
printf("\nEnter the no.of rows and columns of 1st matrix:-\n");
scanf("%d %d",&m,&n);
input_matrix(a,m,n);
out_matrix(a,m,n);
printf("\nEnter the no.of rows and columns of 2nd matrix:-\n");
scanf("%d %d",&n,&l);
input_matrix(b,n,l);
out_matrix(b,n,l);
multiply(a,b,c,m,n,l);
printf("\n Do you want to continue?(Y=yes,N=No)\n");
ch=getch();
}
while(ch=='y' || ch== 'Y');

getch();
}
void input_matrix(int a[100],int m,int n)
{
int i,j;
printf("\n Enter the elements of the matrix:-\n");
for(i=0;i {for(j=0;j scanf("%d",&a[i][j]);
}
}
void output_matrix(int a[100],int m,int n)
{
int i,j;
printf("\n Your entered matrix is:-\n");
for(i=0;i {for(j=0;j printf("%d",a[i][j]);
printf("\n");
}
}
void multiply(int a[100],int b[100][100], int c[100][100],int m,int n,int l)
{
int i,j,k;
for(i=0;i for(j=0;j {c[i][j]=0;
for(k=0;k c[i][j]=c[i][j]+a[i][k]*b[k][j];
}
}

Friday, February 5, 2010

Union in C Language

#include
#include
#include
void main()
{struct student
{
int name;
struct student *next;
}*std,*r,*q;
q='\0';
int m,i,a;
printf("How many students:-\n");
scanf("%d",& m);
printf("Enter %d Elements:\n",m);
for(i=1;i<=m;i++)
{scanf("%d",&a);
std=(struct student*)malloc(sizeof(struct student));
std->name=a;
std->next='\0';
if(q=='\0')
{q=std;
}
else
{r=q;
while(r->next!='\0')
r=r->next;
r->next=std;
}
}
r=q;
while(r!='\0')
{printf("%d \t %d \n",r->name,r->next);
r=r->next;
}
}

Storing Data Using Pointer in C language

#include
#include
#include
void main()
{struct student
{
int name;
struct student *next;
}*std,*r,*q;
q='\0';
int m,i,a;
printf("How many students:-\n");
scanf("%d",& m);
printf("Enter %d Elements:\n",m);
for(i=1;i<=m;i++)
{scanf("%d",&a);
std=(struct student*)malloc(sizeof(struct student));
std->name=a;
std->next='\0';
if(q=='\0')
{q=std;
}
else
{r=q;
while(r->next!='\0')
r=r->next;
r->next=std;
}
}
r=q;
while(r!='\0')
{printf("%d \t %d \n",r->name,r->next);
r=r->next;
}
}

Structure In C Language

#include
#include

void main()
{
struct student{int roll;
char name[20];
int marks;
}stud[5];

int i=0,no,flag=0;
char ch='y';
printf("\nEnter information of 20 student:-");
for(i=0;i<5;i++)
{printf("\nEnter the roll number of the student %d :-",i+1);
scanf("%d",& stud[i].roll);
printf("\n Enter the name of the student %d:-",i+1);
scanf("%s",& stud[i].name);
printf("\n Enter the marks of the student %d:-",i+1);
scanf("%d",& stud[i].marks);
}
while((ch=='Y')||(ch=='y'))
{clrscr();
printf("\nEnter student rollno to display:-\n");
scanf("%d",& no); flag=0;
for(i=0;i<5;i++)
{if(stud[i].roll==no)
printf("Roll Number:- %d Name:- %s Total Marks :- %d",stud[i].roll,stud[i].name,stud[i].marks);
flag=1;

}

if(flag==0)
printf("the Roll Number %d is not present in the list",no);
printf("\n Enter Y to continue");
printf("\n Enter any othr key to exit");
ch=getche();
}
}