Translate

Labels

Friday 21 June 2013

FIBONACCI SERIES USING ARRAYS

#include<stdio.h>
#include<conio.h>
main()
{
int a[30];
int x,n;
clrscr();
printf("Enter no.of times to print:");
scanf("%d",&n);
printf("\n FIBONACCI SERIES :");

Thursday 20 June 2013

PROGRAM TO HIDE THE SYNTAX OF C

#define BEGIN main(){
#define END}
#define EQUAL ==
#define READ(N) scanf("%d",&N)
#define WRITELN(N) printf("%d\n",N)

Sunday 16 June 2013

POINTER ARITHMETIC

Address + Number= Address Address - Number= Address Address - Address=Number Address + Address=Illegal

PROGRAM FOR SHUTDOWN TIMER

#include<stdio.h>
#include<conio.h>
#include<process.h>
#include<stdlib.h>
void main()
{
int t,i,s;
clrscr();
printf("enter the time in sec:");
scanf("%d",&t);

PROGRAM TO INSERT AN ELEMENT IN AN ARRAY

#define MAX 10
main()
{
int a[MAX]={11,22,33,44,55,77,88};
int n,x;
printf("Enter an element to be inserted \n");
scanf("%d",&x);
printf("Enter the position at which\n");
printf("this element to be inserted \n");
scanf("%d",&n);
insert(a,x,n);
}

PROGRAM TO STORE A FLOAT VALUE IN THE MEMORY

#include<malloc.h>
main()
{
float *fp;
fp=(float*)malloc(sizeof(float));
/*Initialization of pointer variable*/

PROGRAM TO FIND INTEGRAL VALUE USING SIMPSON'S RULE

#define f(x) 1.0/(1+x*x)
main()
{
int n;
float simps(float,float,int)a,b;
printf("Enter the values of a,b and n\n");
scanf("%f%f%d",&a,&b,&n);
printf("Integral value of f(x) by simpson's 1/3 rule:%f\n",simps(a,b,n));
}

Saturday 15 June 2013

PROGRAM TO FIND THE INTEGRAL VALUE USING TRAPEZOIDAL RULE

#define f(x) 1.0/(1+x*x)
main()
{
int n;
float a,b;
float trapz(float,float,int);
printf("Enter the values of a,b and n\n");
scanf("%f%f%d",&a,&b,&n);
printf("Integral value of f(x) by trapezoidal rule:%f\n",trapz(a,b,n));
}

Friday 14 June 2013

PROGRAM TO FIND EXECUTION TIME OF A PROGRAM

#include<time.h>
main()
{
time_t t1,t2;
clock_t clock(void);
int i,x=0,y=10;
t1=clock();

PROGRAM TO CONVERT 2-D ARRAY TO 1-D ARRAY

#define MAXROW 3
#define MAXCOL 2
main()
{
int a[MAXROW][MAXCOL],B[MAXROW*MAXCOL];
INT I,J,K=0;
printf("Enter the matrix elements in row order\n ");
for(i=0;i<MAXROW;i++);
for(j=0;j<MAXCOL;j++);
{
scanf("%d",&a[i][j]);
b[k++]=a[i][j];
}

Thursday 13 June 2013

PROGRAM TO SOLVE TOWER OF HANOI PROBLEM

main()
{
int source,destination,other,nodisks;
printf("Enter the number of disks:\n");
scanf("%d",&nodisks);
if(nodisks<1)
{
printf("Illegal input\n");
exit(1);
}
source=1;
other=2;
destination=3;

Wednesday 12 June 2013

PROGRAM TO GENERATE PREFECT NUMBERS

main()
{
int n,i,sum=0,count=0;
for(n=4; ;n++)
{
sum=0;
for(i=1;i<n/2;i++)
{
if((n%i)==0)
sum+=i;
}

AUTO VARIABLES HAVING SAME NAME IN DIFFERENT BLOCKS

main()
{
auto float f1=20.4;
{
auto float f1=10.8;
{
auto float f1=5.3;
printf("Inner block : f1=%.2f , f1+10=%.2f\n",f1,f1+10);
}
printf("Middle block : f1=%.2f , f1+10=%.2f\n",f1,f1+10);
}
printf("Outer block : f1=%.2f , f1+10=%.2f\n",f1,f1+10);
}

Tuesday 11 June 2013

PROGRAM TO GENERATE QUEER NUMBERS

main()
{
int i;
printf("The generated queer numbers:\n");
for(i=11;i<2000;i++)
if(queer(i)!=0)
printf("%d",queer(i));
printf("\n");
}

Monday 10 June 2013

CONVERSION OF INTEGERS INTO WORDS

#include<stdio.h>
#include<conio.h>
main()
{
char a[10][10]={"one","two","three","four","five","six","seven","eight","nine","ten"};
char b[10][10]={"eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"};
char c[10][10]={"ten","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety","hundred"};
int s,r,t;
long n;
clrscr();
/*Enter the number below one lakh*/
printf("Enter the number:");
scanf("%ld",&n);

Saturday 8 June 2013

PASCAL'S TRIANGLE

#include<stdio.h>
#include<conio.h>
main()
{
int b,p,q,r,x;
clrscr();
printf("Enter no.of rows:");
scanf("%d",&r);
b=1;
q=0;
printf("\n PASCAL'S TRIANGLE \n");

ACHROMATIC STRING

#include<stdio.h>
#include<conio.h>
main()
{
char ch[100];
int i;
clrscr();
printf("Enter any string:");
/*to accept multi word string gets() is used*/

Friday 7 June 2013

PROGRAM TO IMPLEMENT RE-CALIBRATE COMMAND

#include #include #include void main(){int show; clrscr();//Put on the motor outp(0x3f2,28); // Check whether the FDC is ready show=inp(0x3f4);//Read the status of MAIN STATUS REGISTER show=(show&amp;128); if(show==128)//Check whether FDC is ready

PROGRAM FOR ENABLING AND DISABLING THE KEYBOARD

#include #include #include main() 

 clrscr();
 outportb(0x64,0xAD); /*Code for disabling the KEYBOARD*/
 printf(" Keyboard Disabled");
 delay(10000);

PROGRAM FOR VERIFYING THE DISK SECTOR

#include #include #include void main(void) 

 clrscr();
 union REGS regs;
 struct SREGS sregs; 
 char buff[1000];
 int i; 
 regs.h.ah = 4; 
 regs.h.al = 1;
 regs.h.ch = 1; 
 regs.h.dh = 0; 
 regs.h.cl = 1; 
 regs.h.dl = 0x80; 

PROGRAM FOR READING THE DISK'S DATA ONTO THE BUFFER

#include #include #include void main(void)
 { 
 clrscr();
 union REGS regs;
 struct SREGS sregs;
 char buff[1000]; 
 int i;
 regs.h.ah = 2;
 regs.h.al = 1;
 regs.h.ch = 1; 
 regs.h.dh = 0; 
 regs.h.cl = 1; 
 regs.h.dl = 0x80; 

PROGRAM FOR GETTING THE DISK STATUS

#include #include #include void main(void) 

 clrscr();
 union REGS regs;
 regs.h.ah = 1; 
 regs.h.dl = 0x80;

PROGRAM FOR RESETTING THE FDC IC (FLOPPY DISK CONTROLLER)

#include #include #include void main(void) 
 {
 clrscr();
 union REGS regs;
 regs.h.ah = 0; 

PROGRAM FOR SETTING THE CURSOR SIZE

#include #include #include void main(void)
 {
 clrscr();
 int x,y;
 union REGS regs;
 printf(&quot; Enter the starting line of the cursor(0-4) - &quot;); 
 scanf(&quot;%d&quot;,&amp;x);
 printf(&quot; Enter the ending line of the cursor - &quot;); 
 scanf(&quot;%d&quot;,&amp;y);

PROGRAM FOR SCROLLING THE WINDOW DOWN

#include #include #include void main(void) 
{
 clrscr(); 
union REGS regs;
 regs.h.ah = 07;
 regs.h.al = 5;
 regs.h.bh = 8; 
 regs.h.ch = 0;

PROGRAM FOR SETTING THE CURSOR POSITION AT DESIRED LOCATION

#include #include #include void main(void) 
{
 clrscr();
 int x,y;
 union REGS regs;
 printf(&quot; Enter the X-position - &quot;); 
scanf(&quot;%d&quot;,&amp;x);
 printf(&quot; Enter the Y-position - &quot;);
 scanf(&quot;%d&quot;,&amp;y);

Wednesday 5 June 2013

PROGRAM FOR SCROLLING THE WINDOW UP


#include #include #include void main(void)
 {
 clrscr();
 union REGS regs;
 regs.h.ah = 06;
 regs.h.al = 5;
 regs.h.bh = 8; 
regs.h.ch = 0;