Thursday, 22 August 2013

C PROGRAM TO GENERATE PASCAL TRAINGLE

/* Program to print the Pascal’s triangle recursively */
#include<stdio.h>
int pascal(int,int);
void space(int,int);
main()
{
int num,i,j;
printf(“\nEnter the no. of rows required: “);
scanf(“%d”,&num);
for(i=1;i<=num;i++)
{
space(num-i,3);
for(j=1;j<=i;j++)
{
printf(“%3d”,pascal(i,j));
space(1,3);
}
printf(“\n”);
}
}
int pascal(int row,int column)
{
if(column==0) // The 0th column element is assumed to 0
return 0;
else if(row==1&&column==1)
return 1;
else if(column>row) // assuming the element is zero (no of columns> no of rows)
return 0;
else
return (pascal(row-1,column-1)+pascal(row-1,column));
}
void space(int num,int mul) // for spaces in between elements
{
int i;
num*=mul;
for(i=0;i<num;i++)
printf(” “);
}

c program for tower of hanoi

#include<stdio.h>

void TOH(int n,char x,char y,char z);
void main()
{
 int n;
 printf("nEnter number of plates:");
 scanf("%d",&n);
 TOH(n-1,'A','B','C');
 getch();
}
void TOH(int n,char x,char y,char z)
{
 if(n>0)
 {
  TOH(n-1,x,z,y);
  printf("n%c -> %c",x,y);
  TOH(n-1,z,y,x);
 }
}

Tuesday, 20 August 2013

MY FIRST ASSIGNMENT IN C

THESE ARE THE FOLLOWING ASSIGNMENTS QUESTIONS I HAS,
TO KNOW THE SOLUTIONS FOR THESE CLICK ON THE BELOW QUESTIONS IT SELF.

  1. Write a program to calculate the series 1 + 1/2! + 1/3! + .. upto N terms.
  2. Write a program to check a C program for rudimentary errors like unbalanced parenthesis, brackets and braces.
  3. Write a C program to implement the insert, delete, and traverse functions of doubly linked list.
  4. Write a program to determine whether two lists are identical

Friday, 16 August 2013

I am a student who is pursuing MSC tech in embedded systems in manipal university . This blog is about my studies of different subjects in embedded systems.