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

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

{

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

#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

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

}

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

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:

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

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

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

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

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

}

}

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


v\:* {behavior:url(#default#VML);}

If you have any question visit this link

http://www.edrawsoft.com/examples.php

http://www.tenouk.com/clabworksheet/labworksheet8a.html

http://www.exforsys.com/tutorials/c-language/c-structures-and-unions.html

http://www.java2s.com/Code/C/CatalogC.htm
8b)to find if the given no.is odd or even

#include<stdio.h>
#include<conio.h>

void main()
{
int n;
clrscr();
printf(“enter any no: “);
scanf(“%d”,&n);
if(n%2==0)
printf(“no is even”);
else
printf(“no is odd”);
getch();
}

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

#include<stdio.h>
#include<conio.h>
void main()
{
int n,f;
f=1;
printf(“Enter the number:\n”);
scanf(“%d”,&n);

while(n>0)
{
printf(“%d”,n);
f=f*n;
n–;
}
printf(“The factorial of the integer is:%d”,f);
getch();
}

Write a C program to perform arithmetic operation using switch.

#include<stdio.h>
#include<conio.h>

void main()
{
int a,b,n,s,m,su,d;
clrscr();
printf(“enter two no’s : “);
scanf(“%d%d”,&a,&b);
printf(“enter 1 for sum\n2 for multiply\n3for subtraction\n4 for division: “);
scanf(“%d”,&n);
switch(n)
{
case 1:
s=a+b;
printf(“sum=%d”,s);
break;
case 2:
m=a*b;
printf(“multiply=%d”,m);
break;
case 3:
su=a-b;
printf(“subtraction=%d”,su);
break;
case 4:
d=a/b;
printf(“divission=%d”,d);
break;
default:
printf(“wrong input”);
break;
}
getch();
}

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

#include<stdio.h>
#include<conio.h>

void main()
{
int a,b,c;
clrscr();
printf(“enter value of a, b & c: “);
scanf(“%d%d%d”,&a,&b,&c);
if((a>b)&&(a>c))
printf(“a is greatest”);
if((b>c)&&(b>a))
printf(“b is greatest”);
if((c>a)&&(c>b))
printf(“c is greatest”);
getch();
}

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

#include<stdio.h>

#include<ctype.h>

Void main()

{

Char ch;

Printf(“\n \t enter the char “);

Scanf(“%c”,&ch);

if(isalpha(ch))

{

If(islower(ch))

Printf(“\n\t the given char is lower:: upper is%c”,toupper(ch));

Else

Printf(“\n\t the given char is upper:: lower is:%c”,tolower(ch));

}

Else

Printf(“\n\t this is not an alpha”);

}

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

void main()
{
int a=1,b=1,c=0,i;
clrscr();
printf(”%d\t%d\t”,a,b);
for(i=0;i<=10;i++)
{
c=a+b;
if(c<100)
{
printf(”%d\t”,c);
}
a=b;
b=c;
}
getch();
}

OR

//TO PRINT THE FIBBONACI SERIES UPTO GIVEN NUMBERS

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

}

}

}

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

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

Program

// Alphabetical order

#include<stdio.h>

#include<conio.h>

#define items 5

#define maxchar 20

void main()

{

char string[items][maxchar],dummy[maxchar];

int i=0,j=0;

printf(“\n Enter names of %d items “,items);

while(i<items)

scanf(“%s”,&string[i++]);

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

{

for(j=1;j<items-1;j++)

{

if(strcmp(string[j-1],string[j])>0)

{

strcpy(dummy,string[j-1]);

strcpy(string[j-1],string[j]);

strcpy(string[j],dummy);

}

}

}

printf(“\n Alphabetical list”);

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

printf(“\n%s”,string[i]);

}

OUTPUT:

Enter names of 5 items

suji lak muthu arun deepa

Alphabetical list

arun deepa lak muthu suji

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

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

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

}

}

OUTPUT:

Enter the number of the students

3

student[1] information:

Enter the name Arun

Enter the roll no of the student 100

Enter the average value of the student 95

student[2] information:

Enter the name Kumar

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

Arun 100 95 A

Kumar 200 55 B

RAJA 300 25 D

8b)to find if the given no.is odd or even

#include<stdio.h>
#include<conio.h>

void main()
{
int n;
clrscr();
printf(“enter any no: “);
scanf(“%d”,&n);
if(n%2==0)
printf(“no is even”);
else
printf(“no is odd”);
getch();
}

Write a C program to perform arithmetic operation using switch.

#include<stdio.h>
#include<conio.h>

void main()
{
int a,b,n,s,m,su,d;
clrscr();
printf(“enter two no’s : “);
scanf(“%d%d”,&a,&b);
printf(“enter 1 for sum\n2 for multiply\n3for subtraction\n4 for division: “);
scanf(“%d”,&n);
switch(n)
{
case 1:
s=a+b;
printf(“sum=%d”,s);
break;
case 2:
m=a*b;
printf(“multiply=%d”,m);
break;
case 3:
su=a-b;
printf(“subtraction=%d”,su);
break;
case 4:
d=a/b;
printf(“divission=%d”,d);
break;
default:
printf(“wrong input”);
break;
}
getch();
}

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

#include<stdio.h>

#include<ctype.h>

Void main()

{

Char ch;

Printf(“\n \t enter the char “);

Scanf(“%c”,&ch);

if(isalpha(ch))

{

If(islower(ch))

Printf(“\n\t the given char is lower:: upper is%c”,toupper(ch));

Else

Printf(“\n\t the given char is upper:: lower is:%c”,tolower(ch));

}

Else

Printf(“\n\t this is not an alpha”);

}

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

Program

// Alphabetical order

#include<stdio.h>

#include<conio.h>

#define items 5

#define maxchar 20

void main()

{

char string[items][maxchar],dummy[maxchar];

int i=0,j=0;

printf(“\n Enter names of %d items “,items);

while(i<items)

scanf(“%s”,&string[i++]);

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

{

for(j=1;j<items-1;j++)

{

if(strcmp(string[j-1],string[j])>0)

{

strcpy(dummy,string[j-1]);

strcpy(string[j-1],string[j]);

strcpy(string[j],dummy);

}

}

}

printf(“\n Alphabetical list”);

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

printf(“\n%s”,string[i]);

}

OUTPUT:

Enter names of 5 items

suji lak muthu arun deepa

Alphabetical list

arun deepa lak muthu suji

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

  1. praveen
    December 24, 2008 at 5:18 PM

    sir,pl send the flowcharts to our id as soon as possible.thanks in advance.

  2. praveen
    December 24, 2008 at 5:31 PM

    and sir the following programs havent been updated in this page yet.
    7a)perofrming arithmetic operations
    7b)changing the case of alphabets

    8b)to find if the given no.is odd or even

    10b)alphabetical order

  3. praveen
    December 24, 2008 at 5:35 PM

    and also the “employee details using union”

  4. praveen
    December 27, 2008 at 2:23 PM

    sir,union program?
    and the algorithms for
    7a)perofrming arithmetic operations
    7b)changing the case of alphabets

    8b)to find if the given no.is odd or even

    10b)alphabetical order????

  5. SANJAY(1 yr mech)
    December 30, 2008 at 11:44 PM

    sir i need flow charts for above programs
    pls send it to sanjayxb@yahoo.co.in
    by the way sir u gave printouts for only 6 programs sir
    wat abt the rest

  6. January 1, 2009 at 3:48 AM

    sir please upload
    7b) lower case to upper case
    12) employee details using union…..

  7. raghul
    September 23, 2011 at 10:18 PM

    please send me the flowcharts for the above programs as soon as possible sir…

  8. balaji
    October 10, 2011 at 4:55 AM

    extraordinary website sir
    very useful (from my heart)

    mind blowing marvellous is hidden here !!!!!
    congrats for ur bright future!!!!sir

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: