Lab Programs
Lab Programs
Program
Write a C program to converting character from lower case to upper case vice versa.
Creating a document (Bio data) and manipulating the text using Microsoft (MS) Word.
ALGORITHM:
Step-8 Stop
PROGRAM:
#include<stdio.h>
main()
float a,b,c;
scanf(“%f %f %f “,&a,&b,&c);
if(a>b);
if(a>c)
printf(“\t%f”,a);
else
printf(“\n\t%f”,c);
else
{
if (c>b)
printf(“\n\t%f”,c);
else
printf(“\n\t %f”,b);
SAMPLE OUTPUT:
ALGORITHM:
Step-3 Check the number whether the number is zero or not. If zero print Zero
value. If not zero go further.
Step-5 fib=fib+a;
a=b;
b=c;
PROGRAM:
main()
int num,fib=0,a=0,b=1,i;
scanf(“%d”,&num);
if(num==0)
printf(“0”);
else
for(i=0;i<num;i++)
fib=fib+a;
a=b;
b=fib;
printf(“%d\t”,fib);
FIBONACCI SERIES
01123
ALGORITHM:
Fact=Fact*I
Step-5 Stop
PROGRAM:
#include<stdio.h>
main()
int fact=1,i,num;
scanf(“%d”,&num);
for(i=1;i<=num;i++)
fact=fact*i;
ALGORITHM:
Step-7 Stop
PROGRAM:
#include<stdio.h>
#include<string.h>
main()
int len;
scanf(“%s”,str1);
printf(“\nThe string length of %s is %d”,str1,strlen(str1));
%s”,strlen(str1),strcat(str1,str2));
SAMPLE OUTPUT:
ALGORITHM:
Step-11 Stop
PROGRAM:
// FIND THE ADDITION OF TWO MATRIXES
#include<stdio.h>
main()
int a[25][25],b[25][25],c[25][25],i,j,m,n;
scanf(“%d %d”,&m,&n);
for(i=0;i<m;i++)
for(j=0;j<n;j++)
scanf(“%d”,&a[i][j]);
for(i=0;i<m;i++)
for(j=0;j<n;j++)
scanf(“%d”,&b[i][j]);
for(i=0;i<m;i++)
printf(“\n”);
for(j=0;j<n;j++)
printf(“\t%d”,a[i][j]);
for(i=0;i<m;i++)
printf(“\n”);
for(j=0;j<n;j++)
printf(“\t%d”,b[i][j]);
for(i=0;i<m;i++)
printf(“\n”);
for(j=0;j<n;j++)
c[i][j]=a[i][j]+b[i][j];
printf(“\t%d”,c[i][j]);
SAMPLE OUTPUT:
1 2 3
4 5 6
7 8 9
1 2 3
4 5 6
7 8 9
2 4 6
8 10 12
14 16 18
ALGORITHM:
PROGRAM:
#include<stdio.h>
main()
struct student
char name[25];
char regno[25];
int avg;
char grade;
} stud[50],*pt;
int i,no;
scanf(“%d”,&no);
for(i=0;i<no;i++)
scanf(“%s”,stud[i].name);
scanf(“%s”,stud[i].regno);
printf(“\nEnter the average value of the student”);
scanf(“%d”,&stud[i].avg);
pt=stud;
for(pt=stud;pt<stud+no;pt++)
if(pt->avg<30)
pt->grade=’D’;
else if(pt->avg<50)
pt->grade=’C’;
else if(pt->avg<70)
pt->grade=’B’;
else
pt->grade=’A’;
printf(“\n”);
for(pt=stud;pt<stud+no;pt++)
printf(“%-20s%-10s”,pt->name,pt->regno);
printf(“%10d \t %c\n”,pt->avg,pt->grade);
}
SAMPLE OUTPUT:
student[1] information:
student[2] information:
student[3] information:
MUNI 100 95 A
LKA 200 55 B
RAJA 300 25 D