Monday, June 13, 2011

Symbol Table Creation


#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<string.h>


struct list
{
char la[50];
char mne[50];
char op[50];
}a[50];

Greatest Number


#include<stdio.h>
#include<conio.h>
void main()
{float a,b;
clrscr();
printf("enter two nos to find the greatest");
scanf(" %f %f",&a,&b);
if(a>b)
printf("\n%f is greater",a);
else if(b>a)
printf("\n%f is greater",b);
else
printf("both are equal");
getch();
}

Factorial


 #include<stdio.h>
 #include<conio.h>
 void main()
 {
 int n,fac =1,i;
 printf("Enter the number for which the factorial is to be found :") ;
 scanf("%d",&n);
 for (i=1;i<=n;i++)
 fac*=i;
 printf("The factorial of %d is %d",n,fac);
 getch();
 }

Finding Roots Of An Equation


#include<stdio.h>
#include<conio.h>


void main()
{
int a,b,c;
clrscr();
printf("enter three nos to find the result of the equation\n1.a+b+c and 4a+4b-2c");
scanf("%d%d%d",&a,&b,&c);
printf("result 1:%d\nresult 2:%d",a+b+c,(4*a)+(4*b)-(2*c));
getch();
}

Arithmetic Operations


#include<stdio.h>
#include<conio.h>
void main()
{float a,b;
char n;
clrscr();
printf("enter any two numbers to find its sum/multiplication/division/subtracton");
scanf(" %f %f",&a,&b);

Concatenate A Couple Of Strings


#include<stdio.h>
#include<conio.h>
#include<string.h>


void main()
{char str1[20],str2[20];
int i;
clrscr();
puts("enter 2 strings (max 20 characters)");

Display Primary Colours In Text


#include<stdio.h>
#include<conio.h>
void main()
{char c;
clrscr();
printf("enter the 1st letter of the colour you want it to b displayed");
scanf(" %c",c);
switch(c)
{case 'r':printf("red");break;
 case 'b':printf("blue");break;
 case 'g':printf("green");break;

Bubble Sort


//Bubble Sort- C Program
#include<stdio.h>
#include<conio.h>
void main()
{int a[5],i,t,j;
clrscr();
printf("enter elements ");
for(i=0;i<5;i++)
scanf(" %d",&a[i]);
for(i=0;i<5-1;i++)
 for(j=0;j<5-1;j++)

Sunday, June 12, 2011

Relocatable Loader


//relocatable loader
/*
THIS IS THE INPUT FILE.SAVE IT AS "linput.txt"( USE NOTEPAD).
H COPY000000 001073
T 00000010 15140033 481039 100036 280030 300015 481061 311003 200030 211033 200033
T 000011 19 045412036 481061 380033 412000 454196 100003 200000
T 000031 15 135140030 430030 141013 301044 241064 210030 301057 543039 212064 381045
T 000058 05 056 100036 520000 151
T 000065 19 080340030 141079 301064 503039 152079 220036 381064 430000 25
E 000000 */
#include<conio.h>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
struct obj_code
{int locctr;
char add[10];
}obcode[300];
void main()

BANKER'S ALGORITHM TO DETECT DEADLOCKS


#include<iostream.h>
#include<conio.h>
#define MAX 5
class bankers
{
 private:
 int al[MAX][MAX],m[MAX][MAX],n[MAX][MAX],avail[MAX];
 int nop,nor,k,result[MAX],pnum,work[MAX],finish[MAX];
 public:
 bankers();
 void input();
 void method();
 int search(int);
 void display();
};