lab programs

15
LAB Program Write a C program to find a factorial of the given number. Write a C program to perform arithmetic operation using switch. Write a C program to find the maximum value of given three numbers. Write a C program to find the given number is odd or even. Write a C program to converting character from lower case to upper case vice versa. Write a C program to find Fibonacci series of a given number. Write a C program to find the string length and concatenation of string. Write a C program to arrange the names in alphabetical order. Write a C program to perform matrix addition. Write a C program to process the student records using structure. Write a C program to print the employee details using union. Creating a document (Bio data) and manipulating the text using Microsoft (MS) Word. Creating a document in MS Word with Scientific Notation using Math Editor. Creating a Flow Chart using Drawing tools in MS Word. (a) Creating and formatting a student information table using MS-Word

Upload: idealmanju

Post on 08-Apr-2015

248 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: Lab Programs

LAB   Program

Write a C program to find a factorial of the given number.

Write a C program to perform arithmetic operation using switch.

Write a C program to find the maximum value of given three numbers.

Write a C program to find the given number is odd or even.

Write a C program to converting character from lower case to upper case vice versa.

Write a C program to find Fibonacci series of a given number.

Write a C program to find the string length and concatenation of string.

Write a C program to arrange the names in alphabetical order.

Write a C program to perform matrix addition.

Write a C program to process the student records using structure.

Write a C program to print the employee details using union.

Creating a document (Bio data) and manipulating the text using Microsoft (MS) Word.

Creating a document in MS Word with Scientific Notation using Math Editor.

Creating a Flow Chart using Drawing tools in MS Word.

(a) Creating and formatting a student information table using MS-Word

(b) Converting table to text and text to table.

Implementation of Mail Merge and Letter Preparation.

Creating an Employee Database using MS-Excel and preparing different charts.

To write a program to find the largest of the three numbers.

ALGORITHM:

Step-1 Start the program

Step-2 Enter the three numbers

Page 2: Lab Programs

Step-3 Assign large to first number

step-4 Check the next number is greater then the large. If greater then assign large to next number

Step-5 Compare the next number with large

Step-6 Do the step-4

Step-7 Print the larger value of the three number

Step-8 Stop

PROGRAM:

//TO FIND THE LARGEST OF THE THREE NUMBERS

#include<stdio.h>

main()

{

float a,b,c;

printf(“\n enter the three numbers”);

scanf(“%f %f %f “,&a,&b,&c);

printf(“\n largest value is”);

if(a>b);

{

if(a>c)

printf(“\t%f”,a);

else

printf(“\n\t%f”,c);

}

else

Page 3: Lab Programs

{

if (c>b)

printf(“\n\t%f”,c);

else

printf(“\n\t %f”,b);

}

}

SAMPLE OUTPUT:

Enter the three numbers 93 43 23

The biggest of three number is 93

To write a program to generate the fibbonaci series

ALGORITHM:

Step-1 Start the program

Step-2 Enter the number

Step-3 Check the number whether the number is zero or not. If zero print Zero value. If not zero go further.

Step-4 Set a loop up to the given number.

Step-5 fib=fib+a;

a=b;

b=c;

Step-6 Every increment in the loop prints the value of fib.

Step-7 After the execution of the loop stops the program

PROGRAM:

//TO PRINT THE FIBBONACI SERIES UPTO GIVEN NUMBERS

Page 4: Lab Programs

#include<stdio.h>

main()

{

int num,fib=0,a=0,b=1,i;

printf(“Enter the number”);

scanf(“%d”,&num);

printf(“\n FIBBONACI SERIES\n”);

if(num==0)

printf(“0”);

else

{

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

{

fib=fib+a;

a=b;

b=fib;

printf(“%d\t”,fib);

}

}

}

SAMPLE INPUT AND OUTPUT

Enter the number 5

FIBONACCI SERIES

Page 5: Lab Programs

0 1 1 2 3

To write a program to find the factorial of the given number

ALGORITHM:

Step-1 Start the program

Step-2 Enter a number

Step-3 Set a loop to find the factorial of the given number

using the formula

Fact=Fact*I

Step-4 Print the factorial of the given number

Step-5 Stop

PROGRAM:

//TO FIND THE FACTORIAL OF THE GIVEN NUMBER

#include<stdio.h>

main()

{

int fact=1,i,num;

printf(“Enter the number”);

scanf(“%d”,&num);

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

{

fact=fact*i;

}

printf(“The factorial of %d is %d”,num,fact);

Page 6: Lab Programs

}

SAMPLE INPUT AND OUTPUT:

Enter the number 5

The factorial of 5 is 120

To write a program to find the string length and concatenation of string.

ALGORITHM:

Step-1 Start the program

Step-2 Enter the string

Step-3 Find the string length using the function strlen()

Step-4 Print the string length of the entered string

Step-5 concatenation the two string using the function strcat()

Step-6 Print the concatenated string

Step-7 Stop

PROGRAM:

// TO FIND THE STRING LENGTH OF THE STRING

#include<stdio.h>

#include<string.h>

main()

{

char str1[50],str2[]=” WELCOME”;

int len;

printf(“Enter the string…”);

scanf(“%s”,str1);

Page 7: Lab Programs

printf(“\nThe string length of %s is %d”,str1,strlen(str1));

printf(“\nTheconcatenation string length is %d and its string is

%s”,strlen(str1),strcat(str1,str2));

}

SAMPLE OUTPUT:

Enter the string… mech

The string length of mech is 4

The concatenation string length is 17 and its string is mech WELCOME

To write a program to give the addition of two matrixes.

ALGORITHM:

Step-1 Start the program

Step-2 Enter the row and column of the matrix

Step-3 Enter the elements of the A matrix

Step-4 Enter the elements of the B matrix

Step-5 Print the A matrix in the matrix form

Step-6 Print the B matrix in the matrix form

Step-7 Set a loop up to the row

Step-8 Set a inner loop up to the column

Step-9 Add the elements of A and B in column wise and store the result in C matrix

Step-10 After the execution of the two loops. Print the value of C matrix

Step-11 Stop

PROGRAM:

Page 8: Lab Programs

// FIND THE ADDITION OF TWO MATRIXES

#include<stdio.h>

main()

{

int a[25][25],b[25][25],c[25][25],i,j,m,n;

printf(“Enter the rows and column of two matrixes…\n”);

scanf(“%d %d”,&m,&n);

printf(“\nEnter the elements of A matrix…”);

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

{

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

scanf(“%d”,&a[i][j]);

}

printf(“\nEnter the elements of B matrix…”);

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

{

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

scanf(“%d”,&b[i][j]);

}

printf(“\nThe elements of A matrix”);

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

{

printf(“\n”);

Page 9: Lab Programs

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

printf(“\t%d”,a[i][j]);

}

printf(“\nThe elements of B matrix”);

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

{

printf(“\n”);

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

printf(“\t%d”,b[i][j]);

}

printf(“\nThe addition of two matrixes”);

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:

Enter the rows and column of two matrixes… 3 3

Page 10: Lab Programs

Enter the elements of A matrix… 1 2 3 4 5 6 7 8 9

Enter the elements of B matrix… 1 2 3 4 5 6 7 8 9

The elements of A matrix

1 2 3

4 5 6

7 8 9

The elements of B matrix

1 2 3

4 5 6

7 8 9

The addition of two matrixes

2 4 6

8 10 12

14 16 18

To write a program to process the student records using structures.

ALGORITHM:

Step-1 Start the program

Step-2 Initialize the structure variable

Step-3 Enter the number of student

Step-4 Set a loop up to the number of student

Step-5 Enter the student name, roll no, average marks

Step-6 Find their grades

Step-7 Print the student name, roll no, average and their grade

Page 11: Lab Programs

Step-9 Stop

PROGRAM:

//STUDENT RECORD USING POINTER AND STRUCT

#include<stdio.h>

main()

{

struct student

{

char name[25];

char regno[25];

int avg;

char grade;

} stud[50],*pt;

int i,no;

printf(“Enter the number of the students…”);

scanf(“%d”,&no);

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

{

printf(“\n student[%d] information:\n”,i+1);

printf(“Enter the name”);

scanf(“%s”,stud[i].name);

printf(“\nEnter the roll no of the student”);

scanf(“%s”,stud[i].regno);

Page 12: Lab Programs

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”);

printf(“NAME REGISTER-NO AVERAGE GRADE\n”);

for(pt=stud;pt<stud+no;pt++)

{

printf(“%-20s%-10s”,pt->name,pt->regno);

printf(“%10d \t %c\n”,pt->avg,pt->grade);

}

}

Page 13: Lab Programs

SAMPLE OUTPUT:

Enter the number of the students

3

student[1] information:

Enter the name MUNI

Enter the roll no of the student 100

Enter the average value of the student 95

student[2] information:

Enter the name LAK

Enter the roll no of the student 200

Enter the average value of the student 55

student[3] information:

Enter the name RAJA

Enter the roll no of the student 300

Enter the average value of the student 25

NAME REGISTER-NO AVERAGE GRADE

MUNI 100 95 A

LKA 200 55 B

RAJA 300 25 D