Lab Programme

 

FLOYD’S TRIANGLE

Ex No :1                                                                                  Date :

AIM :

         Write a c program to find out the Floyd’s triangle.

ALGORITHM :

·        Start the program.

·        Declaring the variables j, n and assign the value i=1.

·        Read the values for n.

·        By using for loop we can check the condition.

·        Print the result for Floyd’s triangle.

·        Stop the program.

 

CODING :

#include

#include

void main()

{

int i, j, n, l=1;

clrscr();

printf("\n\t\t\tFLOYD'S TRIANGLE");

printf("\n\t\t\t********************\n");

printf("\nEnter the value for n:");

scanf("%d",&n);

printf("\n\n");

for(i=1;i<=n;i++)

{

for(j=1;j<=i;j++)

printf("%d\t",l);

printf("\n\n");

l++;

}

getch();

}

 

OUTPUT :

FLOYD'S TRIANGLE

********************

Enter the value for n : 5

 

1

2        2

3        3        3

4        4        4        4       

5        5        5        5        5

 

PASCAL TRIANGLE

Ex No : 2                                                                                        Date :

AIM :

          Wirte a c program to find out the Pascal triangle.

ALGORITHM :

·        Start the program.

·        Declaring the variables i, j, k, val, m.

·        Read the values for n.

·        By using for loop we can check the condition.

·        Assign val=fact(i)/(fact(j)*fatc(i-j));

·        Print the result for Floyd’s triangle.

·        Stop the program.

CODING :

#include

#include

void main()

{

int i, n, j, val, k, m;

clrscr();

printf("\n\t\t\tPASCAL TRIANGLE");

printf("\n\t\t\t*******************\n");

printf("\nEnter the value for n:");

scanf("%d",&n);

m=n;

for(i=0;i<=n;i++)

{

for(k=m;k>0;k--)

printf(" ");

for(j=0;j<=i;j++)

{

val=fact(i)/(fact(j)*fact(i-j));

printf("%4d",val);

}

printf("\n\n"); m--;

} getch();

}

int fact(int l)

{

int f=1,i;

for(i=1;i<=l;i++)

f=f*i;

return f;

}

 

OUTPUT :

PASCAL TRIANGLE

********************

Enter the value for n : 5

 

                                                1

                                       1                1

                            1                2                  1

                   1                 3                 3                 1

      1                    4                 6                 4                 1

1                 5                 10               10               5                 1

 

ARMSTRONG NUMBER  GENERATION

Ex No :3                                                                                          Date :

AIM :

           Wirte a c program to find out the Armstrong number generation.

ALGORITHM :

·        Start the program.

·        Read the values for n.

·        By using for loop we can check the condition.

·        By using while loop we can check the condition a>0,if the condition is true means it can enter the loop.  

·        Print the result for Armstrong number generation.

·        Stop the program.

CODING :

#include

#include

void main()

{

int a, n, i, b, s;

clrscr();

printf(“\nARMSTRONG NUMBER GENERATION”);

printf(“\n*************************************”);

printf(“\nEnter the value for n:”);

scanf(“%d”,&n);

for(i=0;i<=n;i++)

{

a=i;

s=0;

while(a>0)

{

b=a%10;

b=b*b*b;

s=s+b;

a=a/10;

}

if(i==s)

{

printf(“\n%d”,i);

}

}

getch();

}

OUTPUT :

ARMSTRONG NUMBER GENERATION

*************************************

Enter the value for n :500

 

0

1

153

370

371

407

 

PRIME NUMBER GENERATION

Ex No : 4                                                                                         Date :

AIM :

           Wirte a c program to find out the Prime number generation.

ALGORITHM :

·        Start the program.

·        Declaring the variables i, j, m, n and assign count=0.

·        Read the values for n.

·        By using for loop we can check the condition.

·        Print the result for Prime number generation.

·        Stop the program.

CODING :

#include

#include

void main()

{

int i, j, n, m, count;

clrscr();

printf("\n\t\t\tPRIME NUMBER GENERATION");

printf("\n\t\t\t******************************\n");

Printf ("\n Enter the value for n :");

scanf("%d",&n);

printf("\n");

for (i=1; i<=n;i++)

{

count=0;

for(j=2;j

 

FIBONACCI SERIES

Ex No :5                                                                                          Date :

AIM :

      Wirte a c program to find out the Fibonacci series.

ALGORITHM :

·        Start the program.

·        Declaring the variables i, f1, f2, f3, n.

·        Read the values for n.

·        By using for loop we can check the condition.

·        Swap the value by using

                    f1=f2;

                    f2=f3;

·        Print the result for Fibonacci series.

·         Stop the program.

CODING :

#include

#include

void main()

{

int f1, f2, f3, n, i;

clrscr();

printf("\n\t\t\tFIBONACCI SERIES");

printf("\n\t\t\t*******************\n");

Printf ("\nEnter the value for n :");

scanf("%d",&n);

printf("\n");

f1=-1;

f2=1;

for(i=0;i

{

f3=f1+f2;

f1=f2;

f2=f3;

printf("\n\t\t%d",f3);

}

getch ();

}

OUTPUT :

FIBONACCI SERIES

*******************

Enter the value for n : 10

0

1

1

2

3

5

8

13

21

34

 

STRING CONCATENATION

Ex No : 6                                                                                        Date :

AIM :

           Wirte a c program to find out the string concatenation.

ALGORITHM :

·        Start the program.

·        Declaring the variables name1[50],name2[50].

·        Read the strings.

·        By using strcat(), joining the two strings.

·        Print the result for string concatenation.

·         Stop the program.

CODING :

#include

#include

#include

Void main ()

{

Char name1[50], name2[50];

Clrscr();

Printf ("\n\t\t\t PROGRAM FOR STRING CONCATENATION");

printf("\n\t\t\t******************************************\n");

Printf ("\nEnter the two strings :");

Scanf ("%s%s", name1, name2);

Strcat (name1, name2);

Printf ("\n the concatenated string is: %s", name1);

getch ();

}

OUTPUT :

PROGRAM FOR STRING CONCATENATION

******************************************

Enter the two strings :Anu

                                       Sri

The concatenated string is : AnuSri

 

STRING REVERSE

Ex No :7                                                                                          Date :

AIM :

          Wirte a c program to find out the reverse of the given string.

ALGORITHM :

·        Start the program.

·        Declaring the variables name1[50],name2[50].

·        Read the strings.

·        By using strrev(), reversing the given strings.

·        Print the result for string reverse.

·         Stop the program.

CODING :

#include

#include

#include

void main()

{

 char name1[50], name2[50];

 clrscr();

 printf("\n\t\t\t STRING REVERSE");

 printf("\n\t\t\t*****************\n");

 printf("\nEnter the string :");

 scanf("%s",name1);

 strcpy(name2,strrev(name1));

 printf("\nThe reversed string is : %s",name2);

 getch();

}

OUTPUT :

STRING REVERSE

******************

Enter the string :Anu

The reversed string is : unA

 

FINDING THE SUBSTRING

Ex No : 8                                                                                         Date :

AIM :

           Wirte a c program to find out the substring in the given string.

ALGORITHM :

·        Start the program.

·        Declaring the variables name1[50],name2[50].

·        Read the strings.

·        By using strstr(), find the substring.

·        Print the result for the substring.

·         Stop the program.

CODING :

#include

#include

#include

void main()

{

char name1[50], name2[50];

clrscr();

printf("\n\t\t\t FINDING THE SUBSTRING");

printf("\n\t\t\t*************************\n");

printf("\nEnter the two strings :");

scanf("%s%s",name1,name2);

if(strstr(name1,name2)==0)

printf("\n%s is not a substring of %s",name2,name1);

else

printf("\n%s is substring of %s",name2,name1);

getch();

}

OUTPUT :

FINDING THE SUBSTRING

**************************

Enter the two strings :AnuSri

                                       Sri

Sri is substring of AnuSri

 

REPLACING THE STRING

Ex No : 9                                                                                        Date :

AIM :

           Wirte a c program for replacing the string.

ALGORITHM :

·        Start the program.

·        Declaring the variables name1[50],name2[50].

·        Read the strings.

·        By using strcopy(), replace the string.

·        Print the result for replacing the string.

·         Stop the program.

CODING :

#include

#include

#include

void main()

{

char name1[50], name2[50];

clrscr();

printf("\n\t\t\t REPLACING THE STRING");

printf("\n\t\t\t*************************\n");

printf("\nEnter the two strings :");

scanf("%s%s",name1,name2);

strcpy(name1,name2);

printf("\nThe replaced string is : %s",name1);

getch();

}

OUTPUT :

REPLACING THE STRING

*************************

Enter the two strings :Anu

                                       Sri

The replaced string is : Sri

 

STRING  LENGTH

Ex No : 10                                                                                         Date :

AIM :

          Wirte a c program to find out the string length.

ALGORITHM :

·        Start the program.

·        Declaring the variables name1[50], x.

·        Read the strings.

·        By using strlen(), find the length of the string.

·        Print the result for string length.

·         Stop the program.

CODING :

#include

#include

#include

void main()

{

int n;

char name[50];

clrscr();

printf("\n\t\t\tSTRING LENGTH");

printf("\n\t\t\t*****************\n");

printf("\nEnter the string :");

scanf("%s",name);

n=strlen(name);

printf("\nLength of the string  %s is : %d",name,n);

getch();

 

COSINE SERIES

Ex No : 12                                                                                        Date :

AIM :

           Wirte a c program to find out the cosine series.

ALGORITHM :

·        Start the program.

·        Declaring the variables

EXPONENTIAL SERIES

Ex No :   13                                                                                       Date :

AIM :

           Wirte a c program to find out the exponential series.

ALGORITHM :

·        Start the program.

·        Declaring the variables i, j, n, fact=1, sum=1, x.

·        Read the values for n.

·        By using for loop we can check the condition.

·        Print the result for exponential series.

·         Stop the program.

CODING :

#include

#include

#include

void main()

{

int i, n, x, fact=1;

float sum=1;

clrscr();

printf("\n\t\t\tEXPONENTIAL SERIES");

printf("\n\t\t\t**********************\n");

printf("\nEnter the value for n and x:");

scanf("%d%d",&n,&x);

printf("\n");

for(i=1;i<=n;i++)

{

fact=fact*i;

sum=sum+pow(x,i)/fact;

}

printf("\nExponential Series:%f",sum);

getch();

}

OUTPUT :

EXPONENTIAL SERIES

**********************

Enter the value for n and x :2

3

Exponential Series : 8.500000

SALESMAN REPORT

Ex No : 14                                                                                         Date :

AIM :

           Wirte a c program to find the salesman report using two dimensional array.

ALGORITHM :

·        Start the program.

·        Declaring the variables i, j,

BANKING OPERATIONS USING FUNCTIONS

Ex No : 15                                                                                         Date :

AIM :

           Wirte a c program for banking operations using functions.

ALGORITHM :

·        Start the program.

·        Declaring the variables i, j,

TOWERS OF HANOI USING RECURSION

Ex No : 16                                                                                         Date :

AIM :

           Wirte a c program for Towers of Hanoi problem using recursion.

ALGORITHM :

·        Start the program.

·        Declaring the variables n.

·        Read the values for n.

·        Assign ‘L’, ‘R’, ‘C’ for disk movement.

·        Print the result for Towers of hanoi using recursion.

·         Stop the program.

CODING :

#include

#include

void main()

{

int n;

void hanoi(char, char, char, int);

clrscr();

 printf("\n\t\t\t TOWERS OF HANOI");

printf("\n\t\t\t********************\n");

printf("\nEnter the number of disc :");

scanf("%d",&n);

hanoi('L','R','C',n);

}

void hanoi(char ch1,char ch2,char ch3,int n)

{

if(n>0)

{

hanoi(ch1,ch3,ch2,n-1);

printf("\nMove disc %d from %c to %c",n,ch1,ch2);

hanoi(ch3,ch2,ch1,n-1);

getch();

}

}

OUTPUT :

TOWERS OF HANOI

*******************

Enter the number of disc : 3

Move disc 1 from L to R

Move disc 2 from L to C

Move disc 1 from R to C

Move disc 3 from L to R

Move disc 1 from C to L

Move disc 2 from C to R

Move disc 1 from L to R

FIBONACCI USING RECURSION

Ex No :17                                                                                         Date :

AIM :

           Wirte a c program for Fibonacci number generation using recursion.

ALGORITHM :

·        Start the program.

·        Declaring the variables a, i.

·        Read the values for a.

·        Assign result with (fib(a-1)+fib(a-2)).

·        Print the result for Fibonacci number generation using recursion.

·        Stop the program.

CODING :

#include

#include

int fib(int a);

void main()

{

int a, i;

clrscr();

printf(“\nFIBONACCI NUMBER GENERATION USING RECURSION”);

printf(“\n*******************************************************”);

printf("\nEnter the value for a:");

scanf("%d",&a);

printf("\nThe fibonacci series upto %d values are:",a);

for(i=0;i

printf("%d\n",fib(i));

getch();

}

int fib(int a)

{

if(a==0)

return 0;

if(a==1)

return 1;

else

return (fib(a-1)+fib(a-2));

}

OUTPUT :

FIBONACCI NUMBER GENERATION USING RECURSION

*******************************************************

Enter the value for a : 5

0

1

1

2

3

FACTORIAL USING RECURSION

Ex No : 18                                                                                         Date :

AIM :

           Wirte a program to find out the factorial using recursion.

ALGORITHM :

·        Start the program.

·        Declaring the variables n, f, x.

·        Read the values for n.

·        Assign fact=f(n).

·        Print the result for factorial using recursion.

·         Stop the program.

CODING :

#include

#include

#include

long int fact(long int x);

void main()

{

long int n, f, x;

clrscr();

printf("\n\t\t\tFACTORIAL USING RECURSION");

printf("\n\t\t\t*******************************\n");

printf("\nEnter the value for n:");

scanf("%ld",&n);

f=fact(n);

printf("\nFactorial of %ld is %ld",n,f);

getch();

}

long int fact(long int x)

{

if(x==1)

return(1);

else

return(x*fact(x-1));

}

OUTPUT :

FACTORIAL USING RECURSION

********************************

Enter the value for n :5

 

Factorial of 5 is 120

 


STUDENT MARKSHEET USING STRUCTURES

Ex No :19                                                                                          Date :

AIM :

           Wirte a c program for student marksheet using structures.

ALGORITHM :

·        Start the program.

·        Declare the keyword struct.

·        Initialize the variables.

·        Given the list of variables.

·        Print the result.

·        Stop the program.

CODING :

#include

#include

struct student

{

int rollno, m1, m2, m3, total;

char name[30];

float avg;

char grade, result[6];

}s[20];

void main()

{

int i, n, count=0,c=0;

clrscr();

printf("\n\t\t\tSTUDENT MARKSHEET USING STRUCTURES");

printf("\n\t\t\t*******************************************\n");

printf("\nEnter the number of students:");

scanf("%d",&n);

for(i=1;i<=n;i++)

{

printf("\nEnter %d students details :",n);

printf("\nRollno:");

scanf("%d",&s[i].rollno);

printf("\nName:");

scanf("%s",&s[i].name);

printf("\nEnter the three marks:");

scanf("%d%d%d",&s[i].m1,&s[i].m2,&s[i].m3);

s[i].total=s[i].m1+s[i].m2+s[i].m3;

s[i].avg=s[i].total/3;

if(s[i].avg>=90)

s[i].grade='A';

else if(s[i].avg>=80 && s[i].avg<90)

s[i].grade='B';

else if(s[i].avg>=70 && s[i].avg<80)

s[i].grade='C';

else if(s[i].avg<70)

s[i].grade='D';

if(s[i].m1>=50 && s[i].m2>=50 && s[i].m3>=50)

{

strcpy(s[i].result,"pass");

count=count+1;

}else

strcpy(s[i].result,"fail");

c=n-count;

}

printf("\nSTUDENT MARKSHEET USING STRUCTURES");

printf("\n__________________________________________________________________n");

printf("\nROLLNO\tNAME\tM1\tM2\tM3\tTOTAL\tAVERAGE\tGRADE\tRESULT");

printf("\n_________________________________________________________________\n");

for(i=1;i<=n;i++)

{

printf("\n%d\t%s\t%d\t%d\t%d",s[i].rollno,s[i].name,s[i].m1,s[i].m2,s[i].m3);

printf("\t%dt\t%2.2f\t%c\t%s",s[i].total,s[i].avg,s[i].grade,s[i].result);

}

printf("\n_________________________________________________________________\n");

printf("\nNumber of students passed : %d",count);

printf("\nNumber of students failed : %d",c);

printf("\nTotal number of students : %d",n);

printf("\n_________________________________________________________________\n");

getch();

}

OUTPUT :

STUDENT MARKSHEET USING STRUCTURES

********************************************

Enter the number of students : 3

Enter 3 student details :

Rollno : 09mca101

Name : Anu

Enter the three marks : 90

80

100

Rollno : 09mca102

Name : Banu

Enter the three marks : 90

70

60

Rollno : 09mca103

Name : Kalai

Enter the three marks : 40

60

70

        STUDENT MARKSHEET USING STRUCTURES

_____________________________________________________________________________

      ROLLNO    NAME    M1    M2    M3    TOTAL    AVERAGE    GRADE    RESULT

_____________________________________________________________________________

       09mca01       Anu       90       80     100       270              90                  A                Pass

       09mca02      Banu      90       70        60      230              76.66             C               Pass

       09mca03      Kalai      40       60        70      170              63.33             D               Fail

       Number of students passed  : 2

       Number of students failed    : 1

       Total number of students     : 3

______________________________________________________________________________

BOOK USING ARRAY OF STRUCTURES

Ex No :20                                                                                          Date :

AIM :

      Wirte a c program for book details using array of structures.

ALGORITHM :

·        Start the program.

·        Declare the keyword struct.

·        Initialize the variables int i, j, ch, f=0.

·        By using strcmp() function easily compare the statements.

·        By using for condition we can check the condition

·        Print the result.

·        Stop the program.

CODING :

#include

#include

struct book

{

char author[40], title[50];

int price;

};

struct book b[50], temp;

int n;

void main()

{

int i, j, ch, f=0;

char name[30],a[30];

void display();

clrscr();

printf("\n\t\tBOOK DETAILS USING ARRAY OF STRUCTURES");

printf("\n\t\t*********************************************\n");

printf("\nEnter the number of books:");

scanf("%d",&n);

for(i=0;i

{

printf("\nEnter the title of book:");

scanf("%s",&b[i].title);

printf("\nEnter the author name:");

scanf("%s",&b[i].author);

printf("\nEnter the price:");

scanf("%d",&b[i].price);

}

do

{

clrscr();

printf("\nMENU");

printf("\n1.Search\n2.Sort\n3.Exit");

printf("\nEnter your choice:");

scanf("%d",&ch);

switch(ch)

{

case 1:

printf("\nEnter the book name:");

scanf("%s",name);

printf("\nEnter the author name:");

scanf("%s",&a);

printf("\searching...");

for(i=0;i

{

if((strcmp(b[i].title, name==0))&&(strcmp(b[i].author, a)==0))

{

f=1;

printf("\n___________________________________________________________\n");

printf("\n\tBOOK NAME\t\tAUTHOR\t\tPRICE");

printf("\n___________________________________________________________\n");

printf("\n\t%s",b[i].title);

printf("\t\t%12s",b[i].author);

printf("\t\t%d",b[i].price);

printf("\nThe book is available");

}}

if(f==0)

printf("\nThe book is not available");

getch();

break;

case 2:

for(i=0;i

{

for(j=i+1;j

{

if(strcmp(b[i].title,b[j].title)>0)

{

temp=b[i];

b[i]=b[j];

b[j]=temp;

}

}}

display();

getch();

break;

}}

while(ch<3);

}

void display()

{

int i;

printf("\n\t\t\tSORTING BOOKS ON TITLE");

printf("\n_____________________________________________________________");

printf("\n\tBOOK NAME\t\tAUTHOR NAME\t\tPRICE"); printf("\n_____________________________________________________________");

for(i=0;i

{

printf("\n\t%s",b[i].title);

printf("\t\t\t%10s",b[i].author);

printf("\t%11d",b[i].price);

}

}

OUTPUT :

BOOK DETAILS USING ARRAY OF STRUCTURES

****************************************

Enter the number of books : 2

Enter the title of book : Java

Enter the author name :Patrick

Enter the price : 450

Enter the title of book : C++

Enter the author name :Dromey

Enter the price : 250

MENU

1.Search

2.Sort

3.Exit

Enter your choice : 1

Enter the book name : Java

Enter the author name : Patrick

Searching…

 

BOOKNAME                        AUTHORNAME                              PRICE

______________________________________________________________________________

                Java                                         Patrick                                           450    

 

The book is available

Enter your choice : 3

STRING OPERATIONS USING POINTERS

Ex No :21                                                                                          Date :

AIM :

           Wirte a c program for string operations using pointers.

ALGORITHM :

·        Start the program.

·        Declare the variables int I, n.

CODING :

#include

#include

void str()

{

int i;

}

void Accept(char *a)

{

printf("\nEnter The String : ");

scanf("%s",a);

}

int len(char *a)

{

char *p;

int count=0;

for(p=a;*p!='\0';p++)

count++;

return(count);

}

void copy(char *a,char *r)

{

while(*a!='\0')

{

*r=*a;

r++;

a++;

}

*r='\0';

}

void reverse(char *a)

{

char *p,*q;

int count=0;

for(p=a;*p!='\0';p++)

count++;

while(*p!='\0')

p++;

while(count>0)

{

p--;

count--;

printf("%c",*p);

}

}

int compare(char *a,char *b)

{

while(*a!='\0')

{

if(*a==*b)

return(1);

a++;

b++;

}

return(0);

}

int Substr(char *a ,char *b)

{

int N1,N2,count=0;

char *p,*q,*k;

for(N1=0;*(a+N1)!='\0';N1++);

for(N2=0;*(b+N2)!='\0';N2++);

for(p=a;p<=a+N1-N2+1;p++)

{

k=p;

for(q=b;*k==*q&& *q!='\0';q++,k++);

if(*q=='\0')

{

count++;

printf("\nLOCATION = %d",p-a+1);

}

}

return(count);

}

void StrCon(char *a,char *b)

{

char *p,*q;

while(*a!='\0')

a++;

while(*b!='\0')

{

*a=*b;

a++;

b++;

}

*a='\0';

}

void main()

{

char a[25],b[25],c[25],s;

int k,l;

clrscr();

do

{

str();

printf("\n\t\tSTRING MANIPULATION WITH POINTER.");

str();

printf(" \n1.Accept\n2.StringLength\n3.StringCopy\n4.StringReverse\n5.StringComparison\n6.Substring(String Searching)\n7.StrConcatinate\n8.Exit");

printf("\nEnter The Choice..... . . . . " );

scanf("%d",&k);

switch(k)

{

case 1:

Accept(a);

break;

case 2:

l=len(a);

printf("Length of string %s = %d",a,l);

break;

case 3:

copy(a,c);

printf("Copied String = %s",c);

break;

case 4:

reverse(a);

break;

case 5:

Accept(b);

l=compare(a,b);

if(l==1)

printf("\nStrings (%s & %s )are SAME",a,b);

else

printf("\nStrings (%s & %s )are Different",a,b);

break;

case 6:

Accept(b);

if(strstr(a,b)==0)

printf("\n%s is not a SubString of %s .",b,a);

else

printf("\n%s is SubString of %s .",b,a);

break;

case 7:

Accept(b);

StrCon(a,b);

printf("Concatinated string = %s ",a);

break;

case 8:

exit();

default:printf("\nPlease enter Proper Value. ");

}

printf("\nDo U want to Continue(y/n)? ");

scanf("%s",&s);

}

while(s=='y'||s=='Y');

if(s=='n')

exit();

getch();

}

OUTPUT :

 

STRING MANIPULATION WITH POINTER

****************************************

1.Accept

2.String Length

3.String Copy

4.String Reverse

5.String Comparison

6.Substring(String Searching)

7.StrConcatinate

8.Exit

Enter the Choice : 1

Enter the string : Anu

Enter your choice : 3

Length of string Anu is 3

Do you want to continue ? n

DYNAMIC MEMORY ALLOCATION

Ex No :22                                                                                          Date :

AIM :

           Wirte a c program for dynamic memory allocation.

ALGORITHM :

·        Start the program.

·        Declare the variables int I, n.

·        By using malloc() function, we can allocate the memory.

·        By using for condition, we can check the condition.

·        Print the result.

·        Stop the program.

CODING :

#include

#include

#include

void main()

{

int i, n;

char *buffer;

clrscr();

printf("\n\t\t\tDYNAMIC MEMORY ALLOCATION");

printf("\n\t\t\t**********************************\n");

printf("\nHow long do you want the string?:");

scanf("%d",&i);

buffer=(char*)malloc(i+1);

if(buffer==NULL)

exit(1);

for(n=0;n

buffer[n]=rand()%26+'a';

buffer[i]='\0';

printf("\nRandom String is : %s",buffer);

getch();

}

OUTPUT :

DYNAMIC MEMORY ALLOCATION

*********************************

How long do you want the string ? 5

iikay

SEQUENTIAL ACCESS FILE

Ex No :23                                                                                          Date :

AIM :

           Wirte a c program for sequential access file.

ALGORITHM :

·        Start the program.

·        Declare the keyword struct.

·        Initialize the variables.

·        By using while condition, we can check the condition.

·        Print the result.

·        Stop the program.

RANDOM ACCESS FILE

Ex No :24                                                                                          Date :

AIM :

           Wirte a c program for random access file.

ALGORITHM :

·        Start the program.

·        Declare the keyword struct.

·        Initialize the variables long int x=0,m;

·        By using if condition, we can check the condition.

·        By using for fopen(),we can open the file.

·        Print the result.

·        Stop the program.

{

m=i%j;

if(m==0)

count++;

}

if (count==0)

printf("\n\t\t%d",i);

}

getch();

}

OUTPUT :

PRIME NUMBER GENERATION

******************************

Enter the value for n: 50

1

2

3

5

7

11

13

17

19

23

29

31

37

41

43

47

 

Search site

© 2010 All rights reserved.