FULL STACK CODING PROGRAM

JOIN OUR PROGRAM AND BUILD YOUR CAREER IN TECH WITH EDULADDER.


NEW JOINEES WILL RECIVE CRYPTO WORTH OF RS 5000/-.


WHITE PAPER APPLY NOW HERE

Real Problems! Real Experts!

An unparalleled, New approach On creative thinking and problem solving.


The Eduladder is a community of students, teachers, and programmers just interested to make you pass any exams. So we help you to solve your academic and programming questions fast.
In eduladder you can Ask,Answer,Listen,Earn and Download Questions and Question papers.
Watch related videos of your favorite subject.
Connect with students from different parts of the world.
Apply or Post Jobs, Courses ,Internships and Volunteering opportunity. For FREE
See Our team
Wondering how we keep quality?
Got unsolved questions? Ask Questions


You are here:Open notes-->Anna-University-->GE2115-Computer-practice-Laboratory-Part-10

GE2115-Computer practice Laboratory Part-10

How to study this subject

91. Program to accept elements into single dimensional array and print the array in ascending order by
using three different arrays.
#include
#include
void read_array(int x[]);
void sort_array(int y[]);
void print_array(int z[]);
main()
{
int a[10];
clrscr( );
read_array(a);
sort_array(a); 44
print_array(a);
getch( );
}
void read_array(int x[])
{
int i;
for(i=0;i<10;i++)
{
printf(“enter value for a[%d]”,i);
scanf(“%d”,&x[i]);
}
}
void sort_array(int y[])
{
int i,j,k;
for(i=0;i<9;i++)
for(j=i+1;j<=9;j++)
if(y[i]>y[j])
{
k=y[i];
y[i]=y[j];
y[j]=k;
}
}
void print_array(int z[])
{
int i;
for(i=0;i<10;i++)
printf(“%d\n”,z[i]);
}
92.Program to accept data and store the given data into file print the data.
#include
#include
main( )
{
FILE *fp;
char c;
fp=fopen(“data.dat”,”w”);
clrscr();
printf(“enter text”);
while(1)
{
c=getchar( );
if(c==eof( ))
break;
putc(c);
}
fclose(fp);
fp=fopen(“data.dat”,”r”);
while(1)
{
c=getc(fp);
if(c==eof( )) 45
break;
putchar(c);
}
getch( );
fclose(fp);
}
93. Program to accept data in lower case and store the given data into file into upper case and print the
data.
#include
#include
main( )
{
FILE *fp;
Char c;
fp=fopen(“data2.dat”,”w”);
clrscr( );
printf(“enter text”);
while((c=getchar( ))!=eof( ))
{
putc(toupper(c),fp)
}
fclose(fp);
fp=fopen(“data2.dat”,”r”);
while(1)
{
c=getc(fp);
if(c==eof( ))
break;
putchar(c);
}
getch( );
fclose(fp);
}
94.Program to copy contents of one file into another.
#include
#include
main( )
{
FILE * fp1,*fp2;
char ch;
fp1=fopen(“text1”,”w”);
printf(“enter the text”);
while((ch=getchar()!=EOF);
putc(ch,fp1);
fclose(fp1);
fp1=fopen(“text1”,”r”);
fp2=fopen(“text2”,”w”);
while((ch=getc(fp1))!=EOF)
putc(ch,fp2); 46
fcolse(fp1);
fcolse(fp2);
getch( );
}
95. Program to create a file of numbers and copy odd number into second file and even number into
third file
#include
#include
main( )
{
FILE *fp1,*fp2,*fp3;
int i;
fp1=open(“data1”,w”);
printf(“enter the number”);
scanf(“%d”,&i);
while(i!=eof)
{
putw(i,fp1);
scanf(“%d”,&i);
}
fcolse(fp1);
fp1=fopen(“data1”,”r”);
fp2=fopen(“data2”,”w”);
fp3=fopen(“data3”,”w”);
while((i=getc(fp1))!=eof)
if(i%2==0)
putc(i,fp3);
else
putw(i,fp2);
fcolse(fp1);
fcolse(fp2);
fcolse(fp3);
getch( );
}
96.Program to accept a string in lower case and print first character of each word in upper case.
 #include
 #include
 main( )
 {
 char str1[80];
 int length,i;
 clrscr( );
 printf(“enter a string; “);
 length=getline(str1,80);

 for(i=0;i

 {
 str1[0]-=32;
 if(str1[i]= =’ ‘)
 str1[i+1]-=32;
 printf(“%c”.str1[i]);
 } 47
 getch();
 }
 int getline(char line [], int lim)
 {
 int i;

 for(i=0;i

 if(line[i]= =’\n’)
 line[i]=’\0’;
 return i;
 }
97.Program to accept two numbers and interchange two values using functions.
#include
#include
void swap (int a, int b);
main( )
{
int a,b;
clrscr( );
printf(“enter value for a;”);
scanf(“%d”,&a);
printf(“enter value for b;”);
scanf(“%d”,&b);
swap(a,b);
getch( );
}
void swap(int a,int b)
}
int c;
c=a;
a=b;
b=c;
printf(“\na=%d”,a);
printf(“\nb=%d”,b);
}
98.Program for example of static variable.
#include
#include
static int i=1;
main( )
{
int j;
clrscr( );
for (j=1;j<=5;j++);
fun( );
getch( );
}
fun( )
{
printf(“\n%d”,i);
i=i+1;
} 48
99.Program to accept a string and print by trailing spaces.
#include
#include
main( )
{
char n,n1;
clrscr ( );
printf(“enter a string;”);
while((n=getchar( )!=’\n’)
if(n>=’a’ && n<=’z’)
putchar(n);
else
if(n>=’a’ && n<=’z’)
putchar(n);
getch( );
}
100. Program to print anti diagonal.
#include
#include
main( )
{
int a[4][4],i,j,c;
clrscr( );
printf(“enter which number you want;”);
scanf(“%d”,&c);
for(i=0;i<4;i++)
for(j=0;j<4;j++)
if(i+j= =3)
a[i]]j]=c;
else
a[i][j]=0
for(i=0;i<4;i++)
{
for(j=0;j<4;j++)
printf(“%d”,a[i][j]);
printf(“\n”);
}
getch( );

Add contents here


Official Notes


Add contents here


Notes from other sources


Add contents here


Model question papers


Add contents here


Previous year question papers


Add contents here


Useful links


Add contents here



Editors




You might like this video:Watch more here

Watch more videos from this user Here

Learn how to upload a video over here