Electrofriends

C program for Macro Processor

by Ranjith | March 29th, 2010.

C program for Macro Processor

#include<stdio.h>
#include<conio.h>
#define getx1y1
printf("Enter the order of Ist Matrix:");
scanf("%d%d",&x1,&y1);
 
#define getx2y2
printf("Enter the order of IIst Matrix:");
scanf("%d%d",&x2,&y2);
 
#define inputa
printf("Enter the value of a:");
for(i=0;i<x1;i++)
for(j=0;j<y1;j++)
scanf("%d",&a[i][j]);
 
#define inputb
printf("Enter the value of b:");
for(i=0;i<x2;i++)
for(j=0;j<y2;j++)
scanf("%d",&b[i][j]);
 
#define addab
for(i=0;i<x1;i++)
{
for(j=0;j<y1;j++)
{
c[i][j]=0;
for(k=0;k<x1;k++)
{
c[i][j]=c[i][j]+a[i][k]*b[k][j];
}
}
}
 
#define output
printf("n The Result is:");
for(i=0;i<x1;i++)
for(j=0;j<y1;j++)
printf("tn%d",c[i][j]);
 
void main()
{
int a[5][5],b[5][5],c[5][5],i,j,k,x1,x2,y1,y2;
clrscr();
getx1y1;
getx2y2;
if((x1==x2)&&(y1==y2))
{
inputa;
[...]

Read More..

C++ program to illustrate the static member function

by Ranjith | March 13th, 2010.

AIM
Write a program to illustrate the static member function.
ALGORITHM
1. Start the process
2. Invoke the class
i. Set the data member and member function as a static
b. Create two objects t1 and t2
3. Call the function t1.setcode
i. Increment the value of data member count
4. Call the function t1.setcode
i. Increment the value of data member count
5. Call the static member function showcount()
i. Display the value of count
6. Create a [...]

Read More..

C++ program to illustrate Hybrid Inheritance.

by Ranjith | March 13th, 2010.

C++ program to illustrate Hybrid Inheritance.

#include<iostream.h>
#include<conio.h>
class stu
{
protected:
int rno;
public:
void get_no(int a)
{
rno=a;
}
void put_no(void)
{
out<<"Roll no"<<rno<<"\n";
}
};
class test:public stu
{
protected:
float part1,part2;
public:
void get_mark(float x,float y)
{
part1=x;
part2=y;
}
void put_marks()
{
cout<<"Marks obtained:"<<"part1="<<part1<<"\n"<<"part2="<<part2<<"\n";
}
};
class sports
{
protected:
float score;
public:
void getscore(float s)
{
score=s;
}
void [...]

Read More..

C Program to implement Hermite curves for a given set of control points.

by Ranjith | October 2nd, 2009.

point p1,p2;
printf(“Enter 2 hermite points:\n”);
scanf(“%d%d%d%d”,&p1.x,&p1.y,&p2.x,&p2.y);
printf(“Enter the tangents at p1,p4″);
scanf(“%d%d”,&r1,&r4);
cleardevice();

Read More..

C Program to implement the midpoint circle drawing algorithm

by Ranjith | October 2nd, 2009.

C Program to implement the midpoint circle drawing algorithm to draw a circle. Modify the algorithm toimplement specified arc or sector.

Read More..

C Program to implement Kite flying

by Ranjith | October 2nd, 2009.

void main()
{
int gd=DETECT,gm;
int x=10,y=480;
initgraph(&gd,&gm,”..\\bgi”);
while(!kbhit())
{
cleardevice();
if(y==0)

Read More..

C program for SJF CPU Scheduling Algorithm

by Ranjith | September 20th, 2009.

OUTPUT:
enter no of processes: 5

enter process1 name: aaa
enter process time: 4
enter process2 name: bbb
enter process time: 3
enter process3 name: ccc
enter process time: 2
enter process4 name: ddd
enter process time: 5
enter process5 name: eee
enter process time: 1

Read More..

C program for Round Robin CPU Scheduling Algorithm

by Ranjith | September 20th, 2009.

INPUT :
enter the process name : aaa
enter the processing time : 4
enter the process name : bbb
enter the processing time : 3
enter the process name : ccc
enter the processing time : 2
enter the process name : ddd
enter the processing time : 5
enter the process name : [...]

Read More..

C Program for Priority CPU Scheduling Algorithm

by Ranjith | September 19th, 2009.

OUTPUT:
enter no of processes: 5
enter process1 name: aaa
enter process time: 4
enter priority:5
enter process2 name: bbb
enter process time: 3
enter priority:4
enter process3 name: ccc
enter process time: 2
enter priority:3
enter process4 name: ddd
enter process time: 5
enter priority:2
enter process5 name: eee
enter process time: 1
enter priority:1
p_name P_time priority w_time
eee 1 1 0
ddd 5 2 1
ccc 2 3 6
bbb 3 4 [...]

Read More..

C Program for Optimal Page Replacement Algorithm

by Ranjith | September 19th, 2009.

OUTPUT :
2 -1 -1
2 3 -1
2 3 -1
2 3 1
2 3 5
2 3 5
4 3 5
4 3 5
4 3 5
2 3 5
2 3 5
2 3 5

no of page faults : 3

Read More..

Share and enjoy

    • Digg
    • Facebook
    • Technorati
    • StumbleUpon
    • Twitter
    • Reddit
    • del.icio.us
    • Yahoo! Buzz
Copyright©2009 www.electrofriends.com All Rights Reserved. Powered by Dhyeya