CP Lab
CP Lab
C LAB MANUAL
EXERCISE– 1A
AIM : To learn OS Commands, To be Familiar of Editors - vi, Emacs
C LAB MANUAL
$ date
Fri Jul 6 01:07:09 IS T 2012
tty command: Displays current terminal.
$ tty
/dev/pts/0
whoami command:This command reveals the user who is currently logged in.
$ whoami
raghu
Vi editor : vi editor is a visual editor used to create a file (or) to open a file (or0 to modify a file.
The command to work with visual editor is
$ vi filename.c
It can function in different modes.
Insert mode : In this mode we can enter the data or modify content of a file . By pressing
(I/I or A/a) from escape mode we can come to insert mode.
Execute command mode : This is the mode from where we can apply the command mode
commands such as : wq save and quit
: q! quit without saving
In addition to these commands it can be applied on selected test such as copying, deleting lines
etc. From escape mode by pressing Shift + : we can enter into execute command mode.
Escape mode : By default immediately after opening a file through vi editor the file will be in
escape mode. We can switch from one mode to another mode.
Emacs editor: emacs is a screen editor. Unlike vi, emacs is not an insertion mode editor,
meaning that any character typed in emacs is automatically inserted into the file, unless it
includes a command prefix.
C LAB MANUAL
Commands in emacs are either control characters (hold down the <Ctrl> key while typing
another character) or are prefixed by one of a set of reserved characters: <Esc> or <Ctrl>-X. The
<Esc> key can be typed by itself (because it really is a character) and then followed by another
character; the <Ctrl> key must be held down while the next character is being typed. The
conventions for describing these characters (since it takes too long to type out the whole thing)
are ESC means <Esc> and C- means <Ctrl>. One other distinction between emacs and vi is that
emacs allows you to edit several files at once. The window for emacs can be divided into several
windows, each of which contains a view into a buffer. Each buffer typically corresponds to a
different file. Many of the commands listed below are for reading files into new buffers and
moving between buffers.
To use emacs on a file, type
$emacs filename
VIVA-VOCE QUESTIONS:
1. What is vi editor?
C LAB MANUAL
EXERCISE- 1B
PWD : The pwd command used to know the current working directory. pwd stands for "present
working directory" .
Syntax : pwd
ubuntu@ubuntu:-$ ~/home/Desktop
MAN : This is a command used to get documentation or help on commands or man is used for
displaying Linux manual pages.
LS: The ls command can show ('list') the files in your current directory. Used with certain
options, you can see sizes of files, when files were made, and permissions of files. Example: "ls
~" will show you the files that are in your home directory.
Syntax:ls
Example : $ls
CD: The cd command allows us to change directories. When you open a terminal you will be in
your home directory. To move around the file system we can use cd.
C LAB MANUAL
CP: The cp command is used to copy files and directories. The copies become independent of
the originals (i.e., a subsequent change in one will not affect the other).
MV: The mv command can move a file to a different location or can rename a file.
Syntax: rm filename
example: rm prime.c
C LAB MANUAL
CAT: cat command displays the content of a file and allows us to create single or multiple files,
view contents of file, concatenate files and redirect output into terminal or files.
Ctrl + D or ctrl + Z
$ cat hello.txt
Hello world !
Welcome to the c programming lab in lendi engineering college.
VIVA-VOCE QUESTIONS:
1. What is ls command?
2. What is cd command?
4. What is cp command?
C LAB MANUAL
EXERCISE 1(C)
AIM: C Program to Perform Adding, Subtraction, Multiplication and Division of two numbers
From Command line.
DESCRIPTION: A c program that uses command line arguments to take parameters to perform
addition, Subtraction, Multiplication and Division. As the command line arguments are strings
,here we are using atoi( ) function which converts string to integer.
Command Line arguments are the arguments that are passed to the program when the
program is invoked to for execution. The prototype of main( ) when it supports command line
arguments is as follows:
ALGORITHM:
INPUT: 2 Numbers
STEP-1: Start
STEP-2: a=atoi(argv[1])
STEP-3: b=atoi(argv[2])
STEP-9: Stop
C LAB MANUAL
SAMPLE OUTPUT:
$ ./a.out 8 4
Sum=12
Sub=4
Mul=32
Div=2
VIVA-VOCE QUESTIONS:
2. What is the prototype of main( ) when command line arguments are supported.?
C LAB MANUAL
EXERCISE 2(A)
DESCRIPTION:
Newton’s First law An object at rest will remain at rest unless acted on by an unbalanced force.
An object in motion continues in motion with the same speed and in the same direction unless
acted upon by an unbalanced force. i.e if the force applied on the object is non-zero the object
can move in certain direction.
Newton’s Second law Acceleration is produced when a force acts on a mass. The greater the
mass (of the object being accelerated) the greater the amount of force needed (to accelerate the
object).
Force=Mass * Acceleration
Newton’s Third law For every action there is an equal and opposite re-action.
If force applied is F then its reaction will be -F in the opposite direction.
FIRST LAW
ALGORITHM:
INPUT: Force(one)
OUTPUT: A Message
STEP-1: Start
STEP-2:Read f
STEP-3:If f!=0 then display ―The object is moving‖
C LAB MANUAL
SAMPLE OUTPUT:
Enter force
SECOND LAW
ALGORITHM:
INPUT: 2 Numbers(m,a)
OUTPUT: Force(one)
STEP-1: Start
STEP-3:Compute f=m*a
STEP-4: Display f
STEP-5:Stop
SAMPLE OUTPUT:
3 4
Force = 12
THIRD LAW
ALGORITHM:
INPUT: One(Force)
C LAB MANUAL
STEP-1: Start
STEP-2:Read f
STEP-3: Compute f=-f
STEP-4: Display f
STEP-5:Stop
SAMPLE OUTPUT:
Enter force
F=-3
VIVA-VOCE QUESTIONS:
C LAB MANUAL
EXERCISE 2(B)
AIM: Write a C Program to convert Celsius to Fahrenheit and vice versa
From To Formula
ALGORITHM:
STEP-1: Start
STEP-2: Read f
STEP-4: Display c
STEP-5: Stop
SAMPLE OUTPUT:
Temperature in Celsius=4.4
C LAB MANUAL
ALGORITHM:
STEP-1: Start
STEP-2: Read c
STEP-4: Display f
STEP-5: Stop
SAMPLE OUTPUT:
Temperature in Fahrenheit: 40
VIVA-VOCE QUESTIONS:
5. When an expression consisting of operators with same priority how they can be evaluated.
C LAB MANUAL
EXERCISE 3(A)
AIM: Write a C Program to Find Whether the Given Year is a Leap Year or not.
DESCRIPTION: Divide the year with 4 if resultant remainder is zero then the year is leap year
otherwise it is a non-leap year. We can use if –else or conditional statement to write the program.
ALGORITHM:
OUTPUT: A message
STEP-1: Start
STEP-2: Read a
SAMPLE OUTPUT:
VIVA-VOCE QUESTIONS:
C LAB MANUAL
EXERCISE 3(B)
DESCRIPTION: From the given number extract the digits then add them and multiply them.
We can extract a digit using % operator. Here while loop is preferable because this is the case of
event control loop.
ALGORITHM:
INPUT: A number
STEP 1: Start
STEP 2: Read n
Step 7: Stop
C LAB MANUAL
SAMPLE OUTPUT:
Sum of digits: 6
Multiplication of digits: 6
VIVA-VOCE QUESTIONS:
1. What is loop?
C LAB MANUAL
EXERCISE 4(A.I)
AIM: Write a C Program to Find Whether the Given Number is Prime Number.
DESCRIPTION: The number which is not having any factor from 2 to n/2 is called a prime
number. Computing the factors from 2 to n/2 and if there is no factor the number is prime
otherwise the number non-prime. Here for loop is preferred because it is the case of counter
control loop.
ALGORITHM:
OUTPUT: A message
STEP-1:Start
STEP-2:Read n
Otherwise go to STEP-7
STEP-8: Stop
C LAB MANUAL
SAMPLE OUTPUT:
Enter a number:7
Enter a number:9
C LAB MANUAL
EXERCISE 4 (A.II)
AIM: Write a C Program to Find Whether the Given Number is Armstrong Number.
DESCRIPTION: The number for which the sum of the nth powers of digits of given number is
equal to the number itself then it an Armstrong number .Where n is the number of digits of the
given number. Example : 153.
ALGORITHM:
OUTPUT: A message
STEP-1:Start
STEP-2:Read n
STEP-3:Initialize temp=n,sum=0
Otherwise go to STEP-7
STEP-7:Compute temp=n
Otherwise go to STEP-10
C LAB MANUAL
STEP-7: Stop
SAMPLE OUTPUT:
VIVA-VOCE QUESTIONS:
C LAB MANUAL
EXERCISE 4(B)
DESCRIPTION: Display the numbers in the following format is the Floyd Triangle. Where
user can enter number of rows.
2 3
4 5 6
7 8 9 10
ALGORITHM:
STEP-1:Start
STEP-2: Read n
Otherwise go to STEP-9
STEP-5:If j<=i then go to STEP-6
Otherwise go to STEP-8
STEP-6: Display a
C LAB MANUAL
SAMPLE OUTPUT:
2 3
4 5 6
7 8 9 10
C LAB MANUAL
EXERCISE 4(C)
DESCRIPTION: A Pascal triangle represents the binomial coefficients of the binomials. Example Pascal
triangle is as follows.
1 1
1 2 1
1 3 3 1
Here user can take the number of rows. Here also we can use nest loops.
ALGORITHM:
STEP-1:Start
STEP-2: Read n
Otherwise go to STEP-11
Otherwise go to STEP-7
STEP-6:Compute j=j+1 and go to STEP-5
C LAB MANUAL
Otherwise go to STEP-4
STEP-8: Compute n=fact(i)/fact(j)*fact(i-j)
STEP-9:Compute j=j+1
STEP-10:Display ―\n‖ and go to STEP-7
STEP-11:Stop
SAMPLE OUTPUT:
1 1
1 2 1
1 3 3 1
VIVA-VOCE QUESTIONS:
3. What is nested-loop?
5. What is ‗\t‘?
C LAB MANUAL
EXERCISE 5 (A)
AIM: Write a C Program demonstrating of parameter passing in Functions and returning values.
DESCRIPTION: There are categories of functions depends on return value and parameters.
They are
2. int sum( );
4. void sum(void);
ALGORITHM:
STEP-1:Start
STEP-3:Return res
C LAB MANUAL
STEP-1:Start
STEP-3:c=sum(a,b)
STEP-4: Display c
STEP-5: Stop
SAMPLE OUTPUT:
Sum=9
VIVA-VOCE QUESTIONS:
1. What is function?
2. What are the types of functions based on parameters and return values?
C LAB MANUAL
EXERCISE 5(B)
AIM: Write a C Program illustrating Fibonacci, Factorial with Recursion without Recursion
DESCRIPTION:
1. Fibonacci series is defined as fn=f(n-1)+f(n-2) where n>2 and f0=0 and f1=1.The example series
is 0,1,1,2,3,5,8…………..etc.
ALGORITHM:
STEP-1:Start
STEP-2:Read n
STEP-3:result= fact(n)
STEP-5:Stop
STEP-1: Start
C LAB MANUAL
SAMPLE OUTPUT:
ALGORITHM:
STEP-1:Start
STEP-2:Read n
STEP-3:result= fact(n)
STEP-5:Stop
STEP-1: Start
STEP-3:loop(i<=n)
res=res*i
i++
repeat loop
C LAB MANUAL
SAMPLE OUTPUT:
ALGORITHM:
INPUT: A Number
STEP-1:Start
STEP-2:Read n
STEP-3:initialize i=0
STEP-4: loop(i<=n)
res= fib(i)
display res
i++
repeat loop
STEP-4: Stop
fib(int n):
STEP-1:Start
return 0
return 1
C LAB MANUAL
SAMPLE OUTPUT:
ALGORITHM:
INPUT: A Number
STEP-1:Start
STEP-2:Read n
STEP-3:call fibseries(n)
STEP-4:Stop
fibseries(int n):
STEP-1:Start
STEP-3:Display f0,f1
STEP-4: loop(i>=n)
term=f0+f1
display term
f0=f1
f1=term
i++
repeat loop
STEP-5:Stop
C LAB MANUAL
SAMPLE OUTPUT:
VIVA-VOCE QUESTIONS:
C LAB MANUAL
EXERCISE -6A
AIM: Write a C Program to make a simple Calculator to Add, Subtract, Multiply or Divide
Using switch…case
Syntax:
statement(s);
break;
default:
statement(s);
}
Here for the problem we can take operator and operands from the user and based on the operator
the operation can be done. This was asked to do using switch-case
ALGORITHM:
STEP-1. Start
C LAB MANUAL
STEP-3: read n
r=n%2
a[i]=r
i++
n=n/2
Repeat loop
STEP-6: stop
SAMPLE OUTPUT:
1.add
2.sub
3.mul
4.div
enter your choice1
2+3=5
enter a,b values2 3
1.add
2.sub
3.mul
4.div
enter your choice2
2-3=-1
enter a,b values2 3
C LAB MANUAL
1.add
2.sub
3.mul
4.div
enter your choice3
2*3=6
enter a,b values2 3
1.add
2.sub
3.mul
4.div
enter your choice4
2/3=0.666667
C LAB MANUAL
EXERCISE -6B
AIM: Write a C Program to convert decimal to binary and hex (using switch call function the
function)
DESCRIPTION: Base of binary number is 2 and digits are 0 and 1. Base of hexa decimal
number is 16 and digits are 0-9 and ‗A‘-‗F‘. Here we can use function to do conversion from
decimal to binary and hexadecimal using conversion techniques.
STEP-1. Start
STEP-1. Start
C LAB MANUAL
4.1 rem=dec%2;
4.2 bin[i++]=rem;
4.5 dec=dec/2;
STEP-5. printf("\nDecimal; to binary");
STEP-6. for(j=i;j>0;j--) then
STEP-7. print bin[j]
SAMPLE OUTPUT:
1.Decimal to Hexa
2.Decimal to Binary
1.Decimal to Hexa
2.Decimal to Binary
Enter your choice2
Enter the Decimal number42
Decimal to binary0101010
VIVA-VOCE QUESTIONS:
1. What is Armstrong number?
2. How convert decimal number in to binary?
3. The operator to get remainder in division process?
4. What is array?
5. What is the functionality of power( )?
C LAB MANUAL
EXERCISE -7
AIM: Write a C Program to compute the values of sin x and cos x and ex values using Series
expansion. (Use factorial function)
DESCRIPTION:
The expansions of the series
1. sin(x): x - (1/3!)x3 + (1/5!)x5 - (1/7!)x7+…
2. cos(x): 1 - (1/2!)x2 + (1/4!)x4 - (1/6!)x6+…
3. ex= 1 + x + x2/2! + x3/3! + x4/4! + ...
Here we can use factorial function and for loop to compute the series.
4.1.1 fact*=i;
STEP-5. return fact;
STEP-6. Stop
ALGORITHM: SIN(X)
STEP-1. Declare x,sum=0,fraction=0,n,i,j; /*the declarations*/
STEP-2. Declare factorial(int);
STEP-3. Read degree to calculate
STEP-4. Read number of terms
STEP-5. for(i=1,j=0;i<=n,j<n;i=i+2,j++) then
5.1 fraction=pow(-1,j)*(float)(pow(x,i)/factorial(i));/*each term*/
C LAB MANUAL
SAMPLEOUTPUT:
Enter the number of the terms in series
5
Enter the value of x(in degrees)
C LAB MANUAL
60
Sum of the cosine series = 0.50
The value of cos(60) using library function = 0.499882
SAMPLE OUTPUT:
enter the x value 4
enter the no of terms 6
the exp(4) value is : 48.555553
the actual exp(4) value is : 54.598150
VIVA-VOCE QUESTIONS:
1. What is the function?
2. What are the different types of functions?
3. What is the return statement?
4. Classification of functions
C LAB MANUAL
EXERCISE- 8A
AIM: Write a c program to implement linear search.
DESCRIPTION: linear search (Searching algorithm) which is used to find whether a given
number is present in an array and if it is present then at what location it occurs. It is also known
as sequential search. It is very simple and works as follows: We keep on comparing each element
with the element to search until the desired element is found or list ends. Linear search in c
language for multiple occurrences and using function
ALGORITHM:
STEP-1. Start
STEP-2. Declare n,i,a[10],key
STEP-3. Read n
STEP-4. for (i=0;i<n;i++) then
4.1 Read a[i]
STEP-5. Read key
STEP-6. for(i=0;i<n;i++)
6.1 if(a[i]==key)
6.1.1 print element found at position
6.1.2 exit(0);
6.2 end if
STEP-7. end for
STEP-8. print key not found
SAMPLE OUTPUT:
1) enter the no of elements4
enter the elements1 2 3 4
enter the key to search3
the key element 3 found at 3 position
C LAB MANUAL
VIVA-VOCE QUESTIONS:
1. What is searching?
2. What is the difference between linear search and binary search?
3. What are the boundaries of an array index?
4. What can be the data type of an array index?
5. What is one dimensional array?
C LAB MANUAL
EXERCISE -8B
AIM: Write a c program to sort array of elements using bubble sort and selection sort.
DESCRIPTION: The process of arranging the elements either in ascending order or descending
order is called sorting.
Bubble sort: In this process in each iteration the greatest or least element can get it position
Selection sort: In this process in each iteration the position of the element is fixed
ALGORITHM: BUBBLE SORT
STEP-1. Start
STEP-2. Declare n,i,a[10],j,t;
STEP-3. Read n
STEP-4. Print enter the elements
STEP-5. for(i=0;i<n;i++) then
STEP-6. Read a[i]
STEP-7. End for
STEP-8. for(i=0;i<n;i++) then
8.1 for(j=i+1;j<n;j++) then
8.1.1 if(a[i]>a[j])
8.1.1.1 t=a[i];
8.1.1.2 a[i]=a[j];
8.1.1.2 a[j]=t;
End if
STEP-9. End for
STEP-10. End for
STEP-11. Print the sorted list is
STEP-12. for(i=0;i<n;i++) then
STEP-13. Print a[i]
STEP-14. End for
STEP-15. Stop
C LAB MANUAL
8.1 pos=i;
8.2 for(j=i+1;j<n;j++)
8.2.1 if(a[pos]>a[j])
8.2.1.1 pos=j;
8.2.2 end if
8.3 end for
8.4 if(pos!=i)
8.4.1 t=a[i];
8.4.2 a[i]=a[pos];
8.4.3 a[pos]=t;
9. End for
10. Print the sorted list is
11. for(i=0;i<n;i++) then
12. Print a[i]
13. End for
14. Stop
C LAB MANUAL
C LAB MANUAL
EXERCISE- 8C
AIM: Write a c program to perform operations on matrices
DESCRIPTION: We can perform addition of two matrices provided their orders are same. And
we can perform multiplication of two matrices if the no of columns of first matrix are equal to
number of rows of second matrix.
ALGORITHM:
Matrix addition Algorithm) Suppose A and B are two matrix arrays of order m x n, and C is
another matrix array to store the addition result. i, j are counters.
Step1: Start
Step2: Read: m and n
Step3: Read: Take inputs for Matrix A[1:m, 1:n] and Matrix B[1:m, 1:n]
Step4: Repeat for i := 1 to m by 1:
Repeat for j := 1 to n by 1:
C[i, j] := A[i, j] + B[i, j]
[End of inner for loop]
[End of outer for loop]
Step5: Print: Matrix C
Step6: Exit.
ALGORITHM
(Matrix Multiplication Algorithm) Suppose A and B are two matrices and their order are
respectively m x n and p x q. i, j and k are counters. And C to store result.
Step1: Start.
Step2: Read: m, n, p and q
Step3: Read: Inputs for Matrices A[1:m, 1:n] and B[1:p, 1:q].
Step4: If n ≠ p then:
Print: Multiplication is not possible.
Else:
Repeat for i := 1 to m by 1:
Repeat for j := 1 to q by 1:
C[i, j] := 0 [Initializing]
C LAB MANUAL
Repeat k: = 1 to n by 1
C[i, j] := C[i, j] + A[i, k] x B[k, j]
[End of for loop]
[End of for loop]
[End of for loop]
[End of If structure]
Step5: Print: C[1:m, 1:q]
Step6: Exit.
SAMPLE OUTPUT:
SAMPLE OUTPUT:
Enter matrix a :
Enter 1 row : 1 2
Enter 2 row : 1 2
Enter matrix b:
Enter 1 row : 1 2
Enter 2 row : 1 2
Addition of a and b:
2 4
2 4
C LAB MANUAL
Multiplication of a and b:
3 6
3 6
C LAB MANUAL
EXERCISE -9A
AIM: Write a C Program to Store Information of a Movie Using Structure
DESCRIPTION: A structure is an user defined data type used to represent an object or entity.
The information of the movie consists of Movie Name, Hero Name, Heroin Name, Director
Name and Certification etc. We can use a structure to represent the information of the movie.
ALGORITHM:
1. Start
2. Declare structure with movie data
3. Read movie title
4. Read name of the movie's Director
5. Read the year the movie was released
6. Read running time of the movie in minutes
7. Read the Production Cost
8. Read First Year Revenue
9. Print movie title, movie's Director, movie was released, running time of the movie in
minutes, Production Cost, First Year Revenue
SAMPLE OUTPUT:
C LAB MANUAL
movie details
***************
Bahubali
RajaMouli
2015
180
2500000000
2500000000
C LAB MANUAL
EXERCISE- 9B
AIM: Write a C Program to Store Information Using Structures with Dynamically Memory
Allocation
DESCRIPTION: Structure is a user-defined data type in C which allows you to combine
different data types to store a particular type of record. Structure helps to construct a complex
data type in more meaningful way. It is somewhat similar to an Array. The only difference is that
array is used to store collection of similar data types while structure can store collection of any
type of data.
Structure is used to represent a record. Suppose you want to store record of Student which
consists of student name, address, roll number and age. You can define a structure to hold this
information.
DEFINING A STRUCTURE
struct keyword is used to define a structure. struct define a new data type which is a collection of
different type of data.
ALGORITHM:
STEP-1. Start
STEP-2. Declare the structure course
STEP-3. Declare *ptr, i, noOfRecords
STEP-4. Read number of records
STEP-5. ptr = (struct course*) malloc (noOfRecords * sizeof(struct course));
STEP-6. for(i = 0; i < noOfRecords; ++i)
6.1 read Enter name of the subject and marks respectively
STEP-7. Print Displaying Information
STEP-8. for(i = 0; i < noOfRecords ; ++i) then
STEP-9. Print (ptr+i)->subject, (ptr+i)->marks
STEP-10. Stop
SAMPLE OUTPUT:
Enter number of records: 2
Enter name of the subject and marks respectively:
C LAB MANUAL
Programming
22
Enter name of the subject and marks respectively:
Structure
33
Displaying Information:
Programming 22
Structure 33
C LAB MANUAL
EXERCISE- 9C
AIM: Write a C Program to Add Two Complex Numbers by Passing Structure to a Function
DESCRIPTION: C program to add two complex numbers: this program calculate the sum of
two complex numbers which will be entered by the user and then prints it. User will have to
enter the real and imaginary parts of two complex numbers. In our program we will add real
parts and imaginary parts of complex numbers and prints the complex number, i is the symbol
used for iota. For example if user entered two complex numbers as (1 + 2i) and (4 + 6 i) then
output of program will be (5+8i). A structure is used to store complex number.
ALGORITHM:
STEP-1. Start
STEP-2. Create structure with complex
STEP-3. Declare real, imag
STEP-4. Read comple and imaginary pares
STEP-5. Print temp.real = n1.real + n2.real;
STEP-6. Print temp.imag = n1.imag + n2.imag;
STEP-7. Stop
SAMPLE OUTPUT:
For 1st complex number
Enter real and imaginary part respectively: 2.3
4.5
For 2nd complex number
Enter real and imaginary part respectively: 3.4
5
Sum = 5.7 + 9.5i
VIVA-VOCE QUESTIONS:
1. What is the Structure?
2. What is the Union?
3. What is the difference between structure and union?
4. What is the Dynamic memory Allocation?
C LAB MANUAL
C LAB MANUAL
EXERCISE 10(A)
DESCRIPTION: A pointer is a variable which stores the address. One can access the value at
the address by using value at the address operator(*).First read the array and then assign the
address of the array to a pointer and access its value using value at the address. As per C
language
a[i]=*(a+i)
ALGORITHM:
STEP-1: Start
Read a[i]
i++
Repeat loop1
i++
Repeat loop2
STEP-6: Stop
C LAB MANUAL
SAMPLE OUTPUT:
$ ./a.out
VIVA-VOCE QUESTIONS:
C LAB MANUAL
EXERCISE 10(B)
AIM: Write a C Program to find the sum of numbers with Arrays and Pointers.
DESCRIPTION: First assign the address of array to a pointer. Then access the elements of the
array using pointers and add them. Here we can use arrays, pointers, for loop to make the
program.
ALGORITHM:
STEP-1: Start
Read a[i]
i++
Repeat loop1
Sum=sum+ *p
p++
i++
Repeat loop2
STEP-8: Stop
C LAB MANUAL
SAMPLE OUTPUT:
$ ./a.out
VIVA-VOCE QUESTIONS:
C LAB MANUAL
EXERCISE 11(A)
AIM: Write a C program to find sum of n elements entered by user. To perform this program,
allocate memory dynamically using malloc() function.
DESCRIPTION: First read the number elements then allocate memory for those many
elements using dynamic memory using memory allocation function malloc( ) and pointers. Now
we can access the elements and do summation of them.
malloc( ): this is the dynamic memory allocation function used to allocate block of memory.
Header: #include<stdli.h>
ALGORITHM:
STEP-1: Start
Read p+i
i++
Repeat loop1
Sum=sum+ *p
p++
i++
C LAB MANUAL
Repeat loop2
STEP-8: Stop
SAMPLE OUTPUT:
$ ./a.out
VIVA-VOCE QUESTIONS:
C LAB MANUAL
EXERCISE 11(B)
AIM: Write a C program to find sum of n elements entered by user. To perform this program,
allocate memory dynamically using calloc() function. Understand the difference between the
above two programs.
DESCRIPTION: First read the number elements then allocate memory for those many
elements using dynamic memory using memory allocation function calloc( ) and pointers. Now
we can access the elements and do summation of them.
calloc( ): this is the dynamic memory allocation function used to allocate memory to array of
elements. And makes them initialized to zeros.
Header: #include<stdli.h>
ALGORITHM:
STEP-1: Start
Read p+i
i++
Repeat loop1
Sum=sum+ *p
p++
C LAB MANUAL
i++
Repeat loop2
STEP-8: Stop
SAMPLE OUTPUT:
$ ./a.out
VIVA-VOCE QUESTIONS:
C LAB MANUAL
EXERCISE 12(A)
DESCRIPTION: : The string library consists of strcpy( ), strcat( ), strlen( ), strcmp( ) functions
Copy: It is used copy one string to the other.
Header: #include<string.h>
Concatenate: The string library consists of strcat( ) function which is used to concatenate or
combine one string with the other.
Header: #include<string.h>
Length: Length of the string is the number of characters in the string.The string library consists
of strlen( ) function which is used to get length of the string.
Header: #include<string.h>
String Comparission: The string library consists of strcmp( ) function which is used to compare
two strings and results their relation.
Header: #include<string.h>
C LAB MANUAL
ALGORITHM:
INPUT: 3 Strings
OUTPUT: Copied String, String length, Concatenated String and Compared Strings
STEP-1: Start
STEP-4: Print l1
STEP-6: Print s
STEP-12: Stop
SAMPLE OUTPUT:
$ ./a.out
C LAB MANUAL
Lendi
Engineering
College
Length of s1 is 5
After copying 1st string into 3rd string is Lendi
The two Strings s1 and s2 are not equal
After adding first two string LendiEngineering
VIVA-VOCE QUESTIONS:
1. Define a String?
C LAB MANUAL
EXERCISE 12(B)
DESCRIPTION: :
Copy: As the string terminates with the null character(‗\0‘) take each character from the first
string until you get null character and make it copied to corresponding position of the second
string. So that the strings are copied.
ALGORITHM:
INPUT: 1 String
STEP-1: Start
s2[i]=s1[i]
Increment i
STEP-6: Print s2
STEP-7: Stop
C LAB MANUAL
SAMPLE OUTPUT:
$ ./a.out
Concatenate: String concatenation is appending second string at the end of first string. First
reach end of the first string from where copy second string into first string.
ALGORITHM:
INPUT: 2 Strings
STEP-1: Start
i++
Repeat loop1
s1[i]=s2[j]
i++
j++
Repeat loop2
STEP-6: s1[i]=‘\0‘
STEP-7: Display s1
STEP-8: Stop
C LAB MANUAL
SAMPLE OUTPUT:
$ ./a.out
Length: Length of the string is the number of characters in the string. Scanning the string
character by character and make the count until you get null character.
ALGORITHM:
INPUT: 1 String
STEP-1: Start
STEP-8: Stop
SAMPLE OUTPUT:
$ ./a.out
C LAB MANUAL
String Comparission: If the lengths of the strings are same then we can go for comparison of
them. Such that the strings are compared character by character until end or there is no match.
ALGORITHM:
INPUT: 2 Strings
STEP-1: Start
If(s1[i]!= = s2[i])
temp=i
i++
Repeat loop1
STEP-5: If (temp= = i)
STEP-6: Otherwise
STEP-7: Stop
SAMPLE OUTPUT:
$ ./a.out
C LAB MANUAL
VIVA-VOCE QUESTIONS:
2. What is \0 in a string?
C LAB MANUAL
EXERCISE 13(A)
AIM: Write a C programming code to open a file and to print its contents on screen.
DESCRIPTION: It is the program to display the content of the file. First open the file using
fopen( ) and read the file character by character using fgetc( ) until end of the file is reached and
after reading charters display them using printf( ).
Header: #include<stdio.h>
Header: #include<stdio.h>
Return:On success returns next character and EOF on error or end of the file.
ALGORITHM:
STEP-1:Start
Else
C LAB MANUAL
Display char
repeat Loop
STEP-7:Stop
SAMPLE OUTPUT:
$ ./a.out
VIVA-VOCE QUESTIONS:
5What is EOF?
C LAB MANUAL
EXERCISE 13(B)
DESCRIPTION: This is the program to copy file content in to another file. Open the first file in
read mode and second file in write mode. Read first file character by character using fgetc( )
until end of the file and write the read character into second file using fputc( ).
fputc( ): This is the function used to write a character into an opened file.
Header: #include<stdio.h>
ALGORITHM:
STEP-1:Start
Else
fputc(char, fp2)
C LAB MANUAL
repeat Loop
STEP-9:Stop
SAMPLE OUTPUT:
$ ./a.out
VIVA-VOCE QUESTIONS:
C LAB MANUAL
EXERCISE 14(A)
AIM: Write a C program merges two files and stores their contents in another file.
DESCRIPTION: The process of combining two files into third file is said as merging the files.
First open first two files in read mode and third file in write mode. Then Copy first file content
into to third file followed by second file.
ALGORITHM:
STEP-1:Start
STEP-8:
Else
fputc(char, fp3)
Repeat Loop1
C LAB MANUAL
fputc(char, fp3)
Repeat loop2
STEP-12: Stop
SAMPLE OUTPUT:
$ ./a.out
VIVA-VOCE QUESTIONS:
C LAB MANUAL
EXERCISE 14(B)
DESCRIPTION: Deleting a file means removing the file. This can be done using
remove ( ).
Header: #include<stdio.h>
ALGORITHM:
STEP-1:Start
STEP-5: If (x==0)
Otherwise
STEP-6:Stop
SAMPLE OUTPUT:
$ ./a.out
C LAB MANUAL
VIVA-VOCE QUESTIONS:
C LAB MANUAL
EXERCISE 15(A)
INTRODUCTION TO COMPUTER:
Computer is an electronic device which takes the input information from the input device
and generates the output information and it will be displayed on the output. It enables arithmetic
computations, data processing, information management (storage) and knowledge reasoning in
an efficient manner. The word computer is derived from the word compute which means „to
calculate. So a computer generally considered to be calculating device that perform operations at
very faster rates.
Basically the computer system has three major components. These are
System Unit
Central Processing Unit (Processor)
C LAB MANUAL
INPUT UNIT
This unit contains devices with the help of which we enter data into computer. This unit
makes link between user and computer. The input devices translate the information into the
form understandable by computer.
Arithmetic Section
Logic Section
C LAB MANUAL
It stores all the data and the instructions required for processing.
It stores intermediate results of processing.
It stores final results of processing before these results are released to an output device.
All inputs and outputs are transmitted through main memory (RAM).
CONTROL UNIT
It is responsible for controlling the transfer of data and instructions among other units of
a computer.
It manages and coordinates all the units of the computer.
It obtains the instructions from the memory, interprets them, and directs the operation of
the computer.
It communicates with Input / Output devices for transfer of data or results from storage.
It does not process or store data.
OUTPUT UNIT:
Output unit consists of devices with the help of which we get the information from
computer. This unit is a link between computer and users. Output devices translate the
computer's output into the form understandable by users.
ROM AND RAM
A ROM chip is non-volatile storage and does not require a constant source of power to
retain information stored on it. When power is lost or turned off, a ROM chip will keep the
information stored on it. A RAM chip is volatile and requires a constant source of power to
retain information. When power is lost or turned off, a RAM chip will lose the information
stored on it. Other differences between a ROM and a RAM chip include:
A ROM chip is used primarily in the start up process of a computer, whereas a RAM chip
is used in the normal operations of a computer after starting up and loading the operating
system.
Writing data to a ROM chip is a slow process, whereas writing data to a RAM chip is a
faster process. A RAM chip can store multiple gigabytes (GB) of data, up to 16 GB or
C LAB MANUAL
more per chip. A ROM chip typically stores only several megabytes (MB) of data, up to 4
MB or more per chip.
Hardware is the physical appearance of the devices or tools. It is what which we can
touch and feel. Computer Hardware consists of the Monitor, CPU, Keyboard, Mouse and all
other devices connected to the computer either externally or internally.A typical computer
(personal computer, PC) consists of a desktop or tower case (chassis) and the following parts:
1. Cabinet:
a. It is used to install all hardware devices like(mother board, SMPS, HDD,CD
ROM, FDD)
b. It has Start, Restart Button, Led‟s, Audio and USB Connecters are available at
front side.
2. Monitor:
a. Monitor of a computer is like a television screen.
b. It displays text characters and graphics in colors or in shades of grey.
c. The monitor is also called as screen or display or CRT (cathode ray tube).
In the monitor the screen will be displayed in pixels format.
i. 800 by 600 pixels
ii. 1024 by 768 pixels
3. Key Board:
a. Key board is like a type writer, which contains keys to feed the data or information into the
computer
b. Keyboards are available in two modules. These are
i. standard key board with 83-88 keys
ii. Enhanced key board with 104 keys or above
4. Mouse:
a. Every mouse has one primary button (left button) and one secondary button (right
button).
C LAB MANUAL
b. The primary button is used to carry out most tasks, where as secondary button is used in
special cases you can select commands and options.
5. Printer:
a. A device that prints images (numbers, alphabets, graphs, etc…) on paper is known as Printer.
b. We have different types of printers to take printouts. These are as follows:
i. Dot matrix printer
ii. Inkjet printer
iii.Laser printer
6. Speakers:
a. Speakers make your system much more delightful to use entertain you while you are
working on computer
7. Scanner :
a. Scanner used to scan images and text
8. System board/Motherboard
9. Socket 478:
C LAB MANUAL
10. CPU
a. The central processing unit contains the heart of any computer, the
processor. The processor is fitted on to a Mother Board. The Mother
Board contains various components, which support the functioning of a
PC.
b. It is brain of the computer
c. It is square shape
C LAB MANUAL
C LAB MANUAL
C LAB MANUAL
26. SMPS:
a. SMPS is used to supply the power to Mother Board HDD,CD ROM,
FDD
C LAB MANUAL
27. CPU heat Sink and fan 28. Different Screws Used
C LAB MANUAL
C LAB MANUAL
8. First, we have to unplug the fan from the motherboard. The system fan should be
labeled "SYS_FAN1".
9. Next, we will have to unscrew the fan from the outside. We should now be able to lift
the fan out of the PC
10. The CPU fan is located right on top of the CPU heat sink, which is a large piece of
metal with fins on the top.
11. The power supply supplies power to every component in a computer. The list below
is everything that to disconnect: Motherboard (very large connector/plug), CD/DVD
drive[s] power, Internal hard drive power, Portable hard drive slot power
12. The CD/DVD drive is one of the easiest components to remove. First, unplug the
ribbon from the back of the drive. Once that is completed then push it out from the
inside.
13. Just like every other component, unplug the wire first. Then unscrew them all! After
that, the card reader should be removable.
14. First off, de-attach the connector at the back of the slot, and unplug the other end
from the motherboard. To remove the hard drive from the side of the slot, unscrew
the four screws securing it in place. You must be very careful to not drop the hard
drive, as it is very delicate!
15. Expansion cards give computer new capabilities, once installed. Different examples
are: Bluetooth, Wireless Internet, Ethernet, TV
16. Remove the screws on the occupied card slots. Once the screws are removed, you
should be able to remove the cards by pulling them carefully upward.
17. The connectivity center is the area on the front of the computer where there is many
input sections, like usb, fire wire, microphone, headphones, video, etc.
18. To remove the RAM, push down on both tabs holding the RAM in place, which are
located at both ends of the RAM. Please see the pictures.
19. The power button, power LED, and hard drive LED are all within a plastic "chasis".
20. To remove the LEDs from the "chasis", push them from the front with a screw driver.
21. First thing, unscrew the single screw holding it in place.
C LAB MANUAL
22. Once the screw[s] is removed, the whole component should slide into the inside of
the computer, which can then be removed.
23. The motherboard links every component in the computer together. The motherboard
has seven screws holding it to the frame. Remove those seven, then lift the
motherboard out of the frame.
Steps for Assembling.
1. Check how to open the cabinet and determine where to fix the components.
2. Determine if the case has the appropriate risers installed.
Preparing to fit the Components:
C LAB MANUAL
9. Mother board.
10. Screws.
Fitting the Mother board.
1. Line up the patch on the motherboard ( ps/l, USB, etc ) with the appropriate holes in
the block panel I/O shield of the case.
2. Check the points where you and to install
3. Install them and make the mother board sit on them and fix screws if required.
Mother board parts:
1. ACR slot.
2. PCI Slot.
3. AGP Slot.
4. ATX Connectors.
5. CPU Fan.
6. Chipset North Bridge.
7. CPU socket.
8. Floppy.
9. System memory.
10. Chipset south bridge.
11. Panel connector.
12. Power supply.
13. IDE connectors.
ATX Connectors:
1. PS, Mouse.
2. Key board.
3. USB.
4. Parallel ( Prints )
5. Serial COM1.
6. Serial COM 2.
7. Joystick.
C LAB MANUAL
8. Sound.
Fitting the processor:
2. Notice that there is a pin missing at one corner, determine the direction to fit in the
processor.
3. You should not force the CPU. When inserting it. All pins should slide smoothly into
the socket.
4. Lock the lever back down.
5. Install the heat sink over it (Different type for each processor). Heat sink / CPU fan.
Fitting the RAM:
C LAB MANUAL
1. Attach the long end of the cable to the IDEU connector on the motherboard first.
2. The red stripe on the IDE cable should be facing the CD Power.
Powering the driver and motherboard:
2. RS, RE, RS or RESET: Connect the two pin Reset cable here.
3. PWR, PW, PWSW, PS or power SW: Power switch, the pc‘s on (switch, the plug is
two pin).
4. PWLED, PWRLED or Power LED: The light emitting diode on the front panel of the
case illuminates when the computer is switched on. It‘s a 2-pin cable.
5. HD, HDD, and LED: These two pins connect to the cable for the hard disk activity
LED.
Final Check:-
1. Mother board jumper configurations are the settings for the processor operator.
2. Drive jumper settings, master/ slave correct?
3. Are the processor, RAM modules and plug in cards finally seated in there sockets?
4. Did you plug all the cables in? Do they all fit really?
5. Have you frightened all the screws in plug- in cards or fitted the clips?
6. Are the drive secure?
7. Have u connected the power cables to all driver?
C LAB MANUAL
1. Ensure that no wires are touching the CPU heat sink fan.
2. Plug your monitor, mouse and keyboard.
3. Plug in power card and switch the power supply.
4. If everything is connected as it should be
All system, fans should start spinning.
U should hear a single beep and after about 5-10 sec.
Amber light on monitor should go green.
You will see computer start to boot with a memory check.
Now check front LED‘S to see if u plugged them in correctly.
Check all other buttons.
Power afford change any wrong settings.
C LAB MANUAL
EXERCISE 15(B)
AIM: Operating System Installation-Install Operating Systems like Windows, Linux along with
necessary Device Drivers.
PROCEDURE:
1. Keep on press the delete button and go to advanced BIOS feature. [ BIOS-
Basic Input Output System ]
2. And go to boot sequence. Select first boot drivers. CD ROM and press F10 to save the bios
feature. Yes and then enter. Press any key to boot from CD. Press enter to setup windows
XP.
F8 = To agree the license.
Collecting information.
Dynamic update.
Preparing installation
Installing windows.
Tracking installation. Then
1. Select the language as English (united status), then ok.
C LAB MANUAL
PROCEDURE:
1. Language Selection
Using your mouse select the language you would prefer to use for the installation
Click next to continue.
2. Key Board Configuration:
Using your mouse select the correct layout type for the keyboard you would prefer to use
for the installation and as the system default.
C LAB MANUAL
If you have a PS/2 ,USB or Bus mouse you do not need to pick a port and device. If you
have a serial mouse, you should choose the correct port and device that your serial mouse
is on.
The Emulate 3 buttons checkbox allows you to use a two-button mouse as if it had three
buttons. If you select this check box you can emulate a third ―middle‖ button by pressing
both mouse buttons simultaneously.
4. Installation Type:
You can chose automatic partitioning or manual partitioning using Disk Druid of fdisk.
Automatic partitioning allows you to perform an installation without having to partition
your drives yourself.
Automatic partitioning allows you to have some control concerning what data is
removed from your system.
Your options are:
Remove all Linux partitions on this system.
Remove all partitions on this system
Keep all partitions and use existing free space.
To partition manually choose either Disk druid or fdisk partitioning tool.
Lick next once you have made your selections.
5. Partitioning your system:
If you chose automatic partitioning and did not select Review skip ahead
If you choose automatic partitioning and selected review you can either
accept the current partition settings (click next) or modify the setup using
Disk Druid, the manual partition tool.
C LAB MANUAL
Boot loader is the first software program that runs when a computer starts.
The installation program provides two boot loaders GRUB ( GR and Unified Boot
Loader) which is the default and LILO
If you do not want GRUB as your boot loader click Change Boot Loader.
You can then choose to install LILO or choose not to install boot loader at all by clicking
Do not install boot loader on the change boot loader button.
Network devices are automatically detected and displayed in Network Devices list,
Select a network device and click Edit
Here you can configure IP address and net mask of the device.
8. Firewall configuration:
You can set your time zone by selecting your computers physical location or by specifying your
time zones offset from Universal Time.
C LAB MANUAL
You can select package groups which groups components together or individual packages or a
combination of the two.
Device drivers:
Sample screens for installation of device drivers such as sound, internet, chipset and video
C LAB MANUAL
Step 3: then it shows different system drivers such as audio, vedio etc.
C LAB MANUAL
Step 9: installing…..
C LAB MANUAL
VIVA-VOCE QUESTIONS:
1. What is CPU?
2. What is assembling?
C LAB MANUAL
EXERCISE 16(A)
iii) PowerPoint - features of power point, guidelines for preparing an effective presentation.
Microsoft Office Word 2007 allows you to create and edit personal and business documents,
such as letters, reports, invoices, emails and books. By default, documents saved in Word 2007
are saved with the .docx extension. Microsoft Word can be used for the following purposes:
To create business documents having various graphics including pictures, charts, and
diagrams.
To store and reuse ready-made content and formatted elements such as cover pages and
sidebars.
To create letters and letterheads for personal and business purpose.
To design different documents such as resumes or invitation cards etc.
To create a range of correspondence from a simple office memo to legal copies and
reference documents.
Accessing (Word 2007 Basics)
The Microsoft Office Button is locaed in the upper left-hand corner of the program window. It
replaced the old File menu found in previous versions of Microsoft Word. The Office Button
menu contains basic file management commands, including New, Open, Save, Print, and Close.
To Create a New Document - Click the Office Button, select New, and click Create, or press
<CTRL> + <N>.
C LAB MANUAL
To Open a Document - Click the Office Button and select Open, or press <CTRL> + <O>.
To Save a Document - Click the Save button on the Quick Access Toolbar, or press <CTRL> +
<S>.
To Save a Document As - Click the Office Button, select Save As, and enter a new name for the
document.
To Preview a Document - Click the Office Button, point to the Print list arrow, and select
PrintPreview.
To Print a Document - Click the Office Button and select Print, or press <CTRL> + <P>.
To Undo - Click the Undo button on the Quick Access Toolbar or press <CTRL> + <Z>.
To Close a Document - Click the Close button or press <CTRL> + <W>.
To Get Help = Press <F1> to open the Help window. Type your question and press <ENTER>.
To Exit Word - Click the Office Button and click Exit Word.
C LAB MANUAL
1. From the menu tab at the top of Word, select Page Layout.
2. In the Page Layout menu, the margins button will allow you to change the margins to
the correct format.
3. Select Normal to set all margins to one inch.
Formatting Font
The screenshot below displays the menu path to change the font. Use a traditional font
such as Times New Roman or Courier in 12-point size.
C LAB MANUAL
Formatting Spacing
The standard spacing format for a paper is double-spacing. Double-space the entire
document, including the reference page. The screenshot below displays the menu path to change
the spacing format to double.
Centering Text
The screenshot below is an example of text that is centered and that is not centered. In
order to center text highlight the text that requires centering and select the icon in the formatting
toolbar as shown.
C LAB MANUAL
1. To create a header, enter text or graphics in the header area or click button on the header and
footer tool bar.
4. Click the Insert tab on the Ribbon and click the Page Break button on the Page Setup group.
Select the paragraphs you want to bullet or number and click the Bullets or Numbering
button in the Paragraph group on the Home tab.
We can change the text orientation in drawing objects, such as text boxes, shapes, and
callouts, or in table cells so that the text is displayed vertically or horizontally.
C LAB MANUAL
1. Click the drawing object or table cell that contains the text you want to change.
2. On the Format menu, click Text Direction.
3. Click the orientation you want.
Table:
C LAB MANUAL
1. In print layout view, click where you want to insert the note reference mark.
2. On the Insert menu, point to Reference, and then click Footnote.
3. Click Footnotes or End notes.
By default, Word places footnotes at the end of each page and endnotes at the end of the
document. You can change the placement of footnotes and endnotes by making a selection in the
Footnotes or Endnotes box.
4. In the Number format box, click the format you want.
5. Click Insert.
Word inserts the note number and places the insertion point next to the note number.
6. Type the note text.
7. Scroll to your place in the document and continue typing.
As you insert additional footnotes or endnotes in the document, Word automatically
applies the correct number format.
Page Boarders
C LAB MANUAL
Reviewing
Step 3: if it is correct then it shows green color otherwise it shows red in color
Equations
1. Click on insert option
2. Click on equation symbol (right side corner)
3. Then it opens equation tools
4. Select equation
5. And close
Open tool bar and click on equation then it shows different equations
C LAB MANUAL
Symbols
C LAB MANUAL
EXERCISE 16(A-II)
Microsoft Excel is a spreadsheet program included in the Microsoft Office suite of applications.
Spreadsheets present tables of values arranged in rows and columns that can be manipulated
mathematically using both basic and complex arithmetic operations and functions.
Starting Excel
You start Excel from the Start menu in Windows. Click the Start button, click All
Programs, click Microsoft Office, and then click Microsoft Excel 2007.
The Excel program window has the same basic parts as all Office programs: the title bar,
the Quick Access Toolbar, the Ribbon, Backstage view, and the status bar.
Exploring the Parts of the Workbook
Each workbook contains three worksheets by default. The worksheet displayed in the
work area is the active worksheet.
Columns appear vertically and are identified by letters. Rows appear horizontally and are
identified by numbers.
A cell is the intersection of a row and a column. Each cell is identified by a unique cell
reference.
Excel program window
C LAB MANUAL
Organize data
In MS Excel, there are 1048576*16384 cells. MS Excel cell can have Text, Numeric
value or formulas. An MS Excel cell can have maximum of 32000 characters.
Inserting Data for inserting data in MS Excel, just activate the cell type text or number
and press enter or Navigation keys.
For modifying the cell content just activate the cell, enter a new value and then press
enter or navigation key to see the changes. See the screen-shot below to understand it.
C LAB MANUAL
MS Excel provides various ways of deleting data in the sheet. Let us see those ways.
Select the data you want to delete. Right Click on the sheet. Select the delete option, to
delete the data.
Select the data you want to delete. Press on the Delete Button from the keyboard to
deletes the data.
Select the rows, which you want to delete with Mouse click + Control Key. Then right
click to show the various options. Select the Delete option to delete the selected rows.
Copy Paste
To copy and paste, just select the cells you want to copy. Choose copy option after right
click or press Control + C.
Select the cell where you need to paste this copied content. Right click and select paste
option or press Control + V.
Formulae in Excel:
First click on start button at the bottom of the screen on status bar. Click on programs and
then on Microsoft excel. Then open a new document. Give the main heading and subheading by
changing the size so that they look in block letters. Enter the data. To calculate go to Insert menu
in the menu bar and then click on function and then ok. Then select the data to which you want
to calculate mean. Then you get the required answer. In same way, sample means standard
C LAB MANUAL
deviation lower count limit and upper count limit. Go to insert menu and click on function and
select the required operation to be done and select the data and calculate. Formulas for all the
above are given below.
3. Here first select which cells you want. Then click on auto sum
C LAB MANUAL
C LAB MANUAL
3. Go to tool bar
4. Click on insert option
5. Now it shown different types of graph and charts such as column, line, pie, bar, area,
scatter.
6. In that select any one
7. Now I select XY scatter in insert chart which comes under other charts
8. Click on any one scatter then click on OK. Now it shows the following figure
MS POWERPOINT
Features of PowerPoint
1) Adding Smart Art
Don‘t confuse SmartArt with the similarly named WordArt. Where WordArt just allows
you to display text using a wide variety of different formats and effects, SmartArt is a
comprehensive and flexible business diagram tool that greatly improves upon the ‗Diagram
Gallery‘ feature found in previous versions of Office. Click the insert Smart Chart Graphic to
choose from a selection of options. SmartArt can be used to create professional diagrams that
include pictures and text or combinations of the two. An obvious use of Smart Art would be to
create an organization chart but it can be used for many different kinds of diagrams and even to
provide some variety to slides using text bullet points.
C LAB MANUAL
2) Inserting Shapes
If you need to include some sort of diagram in your presentation, then the quickest and
easiest way is probably to use SmartArt. However, it is important to be able to include shapes
independently of SmartArt and worth being familiar with the various Drawing Tool format
options. Not only will they be useful if you do need to manually draw a diagram (and SmartArt
doesn‘t suit all diagrams), but they can also be applied to objects on a slide that you might not
immediately think of as shapes. For example the box that contains your slide title or your
content. This can be anything from text to a video, or even the individual shapes in a SmartArt
diagram. As you can see, the gallery of available shapes is very extensive. Once you have
selected your chosen shape, you can just click in your slide to insert a default version of the
shape or, to set a particular size and position, click and drag with the mouse to create the shape
and size you want.
3) Inserting an Image
Here are two content type icons which appear in new content Placeholders for inserting
pictures. You can Insert Picture from File or Insert Clip Art. Alternatively, the Illustrations group
of the Insert ribbon tab includes the same two tools. In addition, PowerPoint 2010 has a new
‗Screenshot‘ option that allows you to capture an entire window or part of a window for
inclusion on a slide. You can also copy any image and just paste it directly to a slide. Insert
Picture from File allows you to browse to an image file saved somewhere on your system
whereas Clip Art is held in an indexed gallery of different media types. Clip Art is not limited to
pictures: ‗The Results should be:‘ box lets you choose between: ‗All media file types‘ and one or
more of the following different types:
Illustrations
Photographs
Video
Audio
C LAB MANUAL
Once you have found the image you want to use, click on it to insert it into the current slide. You
can now re-size and move the image accordingly with further editing options available when you
right click the desired image
4) Slide Transitions
Properly used, slide transitions can be make your presentations clearer and more
interesting and, where appropriate, more fun. Badly used, the effect of slide transitions can be
closer to irritating or even nauseating. Simple animation effects are often used to add interest to
bullet point text. Much more extreme animation effects are available but, in most cases, should
be used sparingly if at all. Two main kinds of animation are available in a PowerPoint
presentation: the transition from one slide to the next and the animation of images/text on a
specific slide. In PowerPoint 2010 & 2013 there is also a separate Transitions ribbon tab that
includes a gallery of different transition effects. These can be applied to selected slides or all
slides. If you want to apply different transition effects to different groups of slides, then you
might want to choose ‗Slide Sorter‘ view from the Presentation Views group of the View ribbon.
5) Adding Animations
Whereas the transition effects are limited to a single event per slide, animations can be
applied to every object on a slide – including titles and other text boxes. Many objects can even
have animation applied to different components, for example each shape in a SmartArt graphic,
each paragraph in a text box and each column in a chart. Animations can be applied to three
separate ‗events‘ for each object:
To apply an animation effect, choose the object or objects to be animated, then choose
Animation Styles or Add Animation from the Animations toolbar. Where an animation is applied
to an object with different components (for instance a SmartArt graphic made up of several
boxes), the Effect Options tool becomes available to control how each component will be
C LAB MANUAL
animated. So for example, your animation can be used to introduce elements of an organisation
chart to your slide one by one.
SLIDE LAYOUT:
C LAB MANUAL
C LAB MANUAL
1. Select the lines of text that you want to add bullets or numbering to.
2. Click bullets or numbering.
AUTOSHAPES:
1. Select the auto shape that has the text you want to position.
2. Double-click the selection rectangle of the auto shape or text box and then click the text box
tab in the format dialog box.
3. In the text anchor point box, click the position you want the text to start in.
LINES AND ARROWS:
C LAB MANUAL
1. Select the text or object that you want to represent the hyperlink.
2. Click insert hyperlink.
3. Under link to, click place in this document.
INSERT IMAGES:
Locate the folder that contains the picture that you want to insert, and then click the picture file.
CLIP ART:
C LAB MANUAL
PROCEDURE:
First click on start button at the button of the screen on status bar. Click on programs and
then Microsoft PowerPoint. Go to file and new. Then you find different pattern of slides on right
side of your screen. Then select which is completely empty. Then enter the contents in the first
slide as per given information, name in the second slide, Address in the third slide, Hobbies in
the fourth slide and friends in the fifth slide. Except first slide, all the second, third, fourth, fifth
slides should be inserted. When you select pattern of slide from a new slide, on slide which you
selected you will find an arrow towards its right side, click that arrow and then again click insert
slide. Then save it. Then adjust the layout. Then format the text then give bullets or numbering to
the text if required. Go to auto shapes. Select more auto shapes and insert wherever required.
Then again go to insert option and select new slides. And select chart and a chart with datasheet
appear. Give the name, roll no, marks in three subjects and calculate the total. Then save the file.
C LAB MANUAL
EXERCISE 16(B)
AIM: Network Configuration & Software Installation-Configuring TCP/IP, Proxy, and firewall
settings. Installing application software, system software & tools.
A local area connection is created automatically if a computer has a network adapter and
is connected to a network. If a computer has multiple network adapters and is connected to a
network, you'll have one local area connection for each adapter. If no network connection is
available, you should connect the computer to the network or create a different type of
connection.
IP addresses that are assigned manually are called static IP addresses. Static IP addresses are
fixed and don't change unless you change them.
Dynamically A DHCP server (if one is installed on the network) assigns dynamic IP
addresses at startup, and the addresses might change over time. Dynamic IP addressing is the
default configuration.
When you assign a static IP address, you need to tell the computer the IP address you
want to use, the subnet mask for this IP address, and, if necessary, the default gateway to use for
internetwork communications. An IP address is a numeric identifier for a computer. IP
addressing schemes vary according to how your network is configured, but they're normally
assigned based on a particular network segment.
IPv6 addresses and IPv4 addresses are very different. With IPv6, the first 64 bits
represent the network id and the remaining 64 bits represent the network interface. With IPv4, a
variable number of the initial bits represent the network id and the rest of the bits represent the
host id. For example, if you're working with IPv4 and a computer on the network segment
192.168.10.0 with a subnet mask of 255.255.255.0, the first 24 bits represent the network id and
C LAB MANUAL
the address range you have available for computer hosts is from 192.168.10.1 to 192.168.10.254.
In this range, the address 192.168.10.255 is reserved for network broadcasts.
One local area network (LAN) connection is available for each network adapter
installed. These connections are created automatically. To configure static IP addresses for a
particular connection, follow these steps:
1. Click Start and then click Network. In Network Explorer, click Network and Sharing Center
on the toolbar.
2. In Network and Sharing Center, click Manage Network Connections. In Network
Connections, right-click the connection you want to work with and then select Properties.
3. Double-click Internet Protocol Version 6 (TCP/IPv6) or internet protocol version 4
(TCP/IPv4) as appropriate for the type of IP address you are configuring.
4. For an IPv6 address, do the following:
o Select Use The Following IPv6 Address and then type the IPv6 address in the IPv6
Address text box. The IPv6 address you assign to the computer must not be used
anywhere else on the network.
o Press the Tab key. The Subnet Prefix Length field ensures that the computer
communicates over the network properly. Windows Server 2008 should insert a
default value for the subnet prefix into the Subnet Prefix Length text box. If the
network doesn't use variable-length subnetting, the default value should suffice. If
your network does use variable-length subnets, you'll need to change this value as
appropriate for your network.
5. For an IPv4 address, do the following:
o Select Use The Following IP Address and then type the IPv4 address in the IP
Address text box. The IPv4 address you assign to the computer must not be used
anywhere else on the network.
o Press the Tab key. The Subnet Mask field ensures that the computer communicates
over the network properly.
C LAB MANUAL
6. If the computer needs to access other TCP/IP networks, the internet, or other subnets, you
must specify a default gateway. Type the IP address of the network's default router in the
Default Gateway text box.
7. DNS is needed for domain name resolution. Select Use The Following DNS Server
Addresses and then type a preferred address and an alternate DNS server address in the text
boxes provided.
8. When you're finished, click OK three times to save your changes. Repeat this process for
other network adapters and IP protocols you want to configure.
Many organizations use DHCP servers to dynamically assign IPv4 and IPv6 addresses. To
receive an IPv4 or IPv6 address, client computers use a limited broadcast to advertise that they
need to obtain an IP address. Dhcp servers on the network acknowledge the request by offering
the client an IP address. The client acknowledges the first offer it receives, and the DHCP server
in turn tells the client that it has succeeded in leasing the IP address for a specified amount of
time.The message from the DHCP server can, and typically does, include the IP addresses of the
default gateway, the preferred and alternate DNS servers, and the preferred and alternate WINS
servers. This means these settings wouldn't need to be manually configured on the client
computer.
Using advanced TCP/IP settings, you can configure a single network interface on a
computer to use multiple IP addresses and multiple gateways. This allows a computer to appear
to be several computers and to access multiple logical subnets to route information or to provide
internetworking services.The best way to configure multiple gateways depends on the
configuration of your network. If your organization's computers use DHCP, you'll probably want
to configure the additional gateways through settings on the DHCP server. If computers use
static IP addresses or you want to set gateways specifically, assign them by following these
steps:
C LAB MANUAL
1. Click Start and then click Network. In Network Explorer, click Network and Sharing Center
on the toolbar.
2. In Network and Sharing Center, click Manage Network Connections. In Network
Connections, right-click the connection you want to work with and then select Properties.
3. Double-click Internet Protocol Version 6 (TCP/IPv6) or internet protocol version 4
(TCP/IPv4) as appropriate for the type of IP address you are configuring.
Click Advanced to open the Advanced TCP/IP Settings dialog box. Figure shows advanced
settings for IPv4. The dialog box for IPv6 is similar
Step 3:
assign a IP address in TCP/IPv4
C LAB MANUAL
Step 4: click ok
To configure the Web Proxy client browser to automatically detect its settings:
C LAB MANUAL
If the Master Database is downloaded through a firewall or proxy server that requires
authentication, ensure that a browser on the Filtering Service machine can load Web pages
properly. If pages open normally, but the Master Database does not download, check the proxy
server settings in the Web browser.
3.Click LAN Settings. Proxy server configuration information appears under Proxy server.
Mozilla Firefox:
Click Settings. The Connection Settings dialog box shows whether the browser is configured to
3.connect to a proxy server.
Next, make sure that Websense software is configured to use the same proxy server to perform
the download.
Verify that Use proxy server or firewall is selected, and that the correct server and port are
2.listed.
3.
Make sure that the Authentication settings are correct. Verify the user name and password,
C LAB MANUAL
If a firewall restricts Internet access at the time Websense software normally downloads
the database, or restricts the size of a file that can be transferred via HTTP, Websense software
cannot download the database. To determine if the firewall is causing the download failure,
search for a rule on the firewall that might be blocking the download, and change the download
times in TRITON - Web Security (Configuring database downloads), if necessary.
A software generally refers to any type of executable code that can be launched in a
computer system. It is designed to implement and complete specific functions that are required
by the user in his activities. Software can be developed and distributed freely (freeware) by
programmers in various communities and forums, or they can be sold commercially either online
or in computer stores by software companies like Microsoft, Adobe, and Sony among others.
Some computer experts believe that software can be categorized as general application (can be
installed and used by any organization) or customized (developed to cater to the specific needs of
a particular group or enterprise). General application software like the Microsoft Office
Productivity Suite for example can also be customized and tailor fitted to the needs of a specific
organization. This is done by using macro commands and a bit of programming.
Materials Needed:
-Computer
-CD or DVD drive
- Installation disc
- Internet connection
- Web browser
C LAB MANUAL
Step 1
The first most important step in software installation is to verify that the target system
meets the general hardware requirements of the application. Beginning the installation in a
computer machine which does not possess the minimum requirements can lead to either an
unsuccessful installation or failure of the program to run after installing it.
Step 2
Since programs in general are written to be Operating System dependent, make sure that
the version of the application you are installing corresponds to the Operating System platform
running on your machine.
Step 3
Aside from the general hardware requirements, some computer programs also have
software requirements prior to installation. Double check if you need to update or upgrade your
Operating System or if there is a need to download other tools or utilities.
Step 4
Once all the initial requirements have been met, make sure that there are no unnecessary
programs running before beginning the installation procedure. In some instances, applications
may require that the antivirus programs be disabled. Make sure that you are installing a
legitimate application before disabling your protection software.
Step 5
Software installation can be done either from the Internet (skip to step 8) or from an
installation disc provided by the software manufacturer. To install from the disc, simply open the
CD or DVD drive and insert the installer.
Step 6
A setup wizard window should be launched. In case there is none, open the Explorer and
navigate to the optical drive. Double click on either the Autorun or Setup file.
C LAB MANUAL
Step 7
Once the wizard is running, simply follow the prompts until the installation process is
completed. For novice users, accept the default values to minimize potential problems during the
procedure. Jump to step 10.
Step 8
For installation from the Web, launch your browser application and download the setup
file to your hard drive.
Step 9
After completion of the downloading process, run the setup program to execute the setup
wizard that will handle the automatic installation of the software. Do step 7.
Step 10
After the installation procedure has been completed and the setup wizard has terminated,
reboot your machine before launching the newly installed software.
System software
C LAB MANUAL
one hallmark of a skilled software engineer. The most basic tools are a source code editor and a
compiler or interpreter, which are used ubiquitously and continuously. Other tools are used more
or less depending on the language, development methodology, and individual engineer, and are
often used for a discrete task, like a debugger or profiler. Tools may be discrete programs,
executed separately – often from the command line – or may be parts of a single large program,
called an integrated development environment (IDE). In many cases, particularly for simpler use,
simple ad hoc techniques are used instead of a tool, such as print debugging instead of using a
debugger, manual timing (of overall program or section of code) instead of a profiler, or tracking
bugs in a text file or spreadsheet instead of a bug tracking system.
VIVA-VOCE QUESTIONS:
3. What is IP address?
C LAB MANUAL
ADVANCED EXPERMENT-1
AIM: Write C programs that implement stack (its operations) using arrays
DESCRIPTION: Stack is a linear data structure where it restricts operations to only one end.
That end is called as ―TOP‖. Stack works on the principle of “last in first out” (LIFO).
Operations to insert an element are stack is called “PUSH”. And deleting an element from stack
is called “POP”.
ALGORITHM:
C LAB MANUAL
Procedure
Display() if top =
-1 then
print ‗ Stack is empty‗
else
{
i=0;
while(top>0)
do
print ‗stack[i];
i++;
end while.
}
end Display.
SAMPLE OUTPUT:
Menu
1.push
2.pop
Enter your choice 1
Enter the element to insert 50
Do you wish to continue press y for yes and n for no: y
Menu
1.push
2.pop
Enter your choice 1
Enter the element to insert 20
Do you wish to continue press y for yes and for no:n
Stack elements are: 20 50
C LAB MANUAL
ADVANCED EXPERMENT-2
AIM: Write C programs that implement stack (its operations) using linked list.
DESCRIPTION: The major problem with the stack using array is, it works only for fixed
amount of numbers of data values. That means the amount of data must be specified at the
beginning of the implementation itself. Stack implemented using array is not suitable, when we
don‘t know the size of the data which we are going to use. A stack data structure can be
implemented by using linked list data structure. The stack implemented using linked list can
work for unlimited number of values. That means the stack implemented using linked list can
work for variable size of data. So there is no need to fix the size at the beginning of
implementation.
ALGORITHM:
Algorithm: Push item ITEM into a linked stack S with top pointer TOP
procedure PUSH_LINKSTACK (TOP, ITEM)
/* Insert ITEM into
stack */ Call
GETNODE(X)
DATA(X) = ITEM /*frame node for ITEM */
LINK(X) = TOP /* insert node X into stack */
TOP = X /* reset TOP pointer */
end PUSH_LINKSTACK.
Algorithm: Pop from a linked stack S and output the element through ITEM
procedure POP_LINKSTACK(TOP, ITEM)
/* pop element from stack and set ITEM to the element
*/ if (TOP = 0) then call LINKSTACK_EMPTY
/* check if linked stack is
empty */ else {
TEMP = TOP
C LAB MANUAL
ITEM =
DATA(TOP) TOP =
LINK(TOP)
}
call RETURN(TEMP)
; end
POP_LINKSTACK.
SAMPLE OUTPUT:
Linked stack
1. Push
2. Pop
3. Display
Enter your choice 1
Enter the number 18
Linked stack
C LAB MANUAL
1. Push
2. Pop
3. Display
Enter your choice 3
Stack elements: 18
VIVA-VOCE QUESTIONS:
1. What is stack?
C LAB MANUAL
DESIGN EXPERMENT-1
AIM: Write a C program to find the largest of three numbers using ternary operator.
DESCRIPTION: First get the greatest among two then get the greatest among that and
remaining number. We can use ternary operator to do this.
ALGORITHM:
STEP-1: Start
If a>c then
d=a
Otherwise
d=c
Otherwise
If b>c then
d=b
Otherwise
d=c
STEP-4: Display d
STEP-5: Stop
C LAB MANUAL
SAMPLE OUTPUT:
Enter 3 numbers:
1 2 3
VIVA-VOCE QUESTIONS:
C LAB MANUAL
DESIGN EXPERMENT-2
AIM: Write a c program to interchange largest and smallest number in array.
DESCRIPTION: Find the position of smallest element in the array and find the position of
largest element in the array. Now swap the elements at those positions.
ALGORITHM:
STEP-1:Start
STEP-6: Loop(i<n)
If (l<a([i]))
l=a[i]
li=i
If (s>a[i])
s=a[i]
si=i
i++
repeat loop
C LAB MANUAL
STEP-9:Stop
SAMPLE OUTPUT:
2 5 8 4 4 1
Before interchanging
2 5 8 4 4 1
After interchanging
2 5 1 4 4 8
VIVA-VOCE QUESTIONS:
2. What is swapping?
C LAB MANUAL
ALGORITHM:
Define the macro at the global declaration section of the program as given below
#define PI 3.14
STEP-1:Start
STEP-5: Stop
SAMPLE OUTPUT:
Enter radius:
2.5
Area of circle:
19.63
VIVA-VOCE QUESTIONS:
1. What is macro?
C LAB MANUAL
C LAB MANUAL
There are 2 programs named as main.c and support.c such that the global variable of
mani.c is referred as extern-variable of support.c.
ALGORITHM:
Make the declaration of global variable count. And refer global function of support as extern
function.
STEP-1: Start
STEP-2:Assign count=5
STEP-4:Stop
STEP-1: Start
STEP-3: Stop
count is 5
C LAB MANUAL
VIVA-VOCE QUESTIONS: