C Program
C Program
C Programming Language
Name : _____________________________
Year : _____________________________
Batch : _____________________________
Roll No : _____________________________
Department: _____________________________
Teacher : _____________________________
1
INTRODUCTION
Each lab session begins with a brief theory of the topic. Many details have
not been incorporated as the same is to be covered in Theory classes. The
Exercise section follows this section.
Next lab session deals with single stepping; an efficient debugging and error
detection technique.
Next three lab sessions cover the basic building blocks of programming.
These practicals introduce the concepts of decision making; loops;
function declaration and definition etc.
The next three experiments deal with the advance concepts like arrays,
pointers, structures and unions. These features enable the users to
handle not only large amount of data, but also data of different types
(integers, characters etc.) and to do so efficiently.
Separate practical’s have been included for different graphics and text
modes, passing variable number of arguments to functions, and command
line arguments.
Further two lab sessions covers the filing feature, which allows the user to
store/retrieve the data on/from permanent storage like floppy or hard disk
and various file and directory manipulation functions.
Finally, there are labs on hardware interfacing using ROM BIOS routines,
which explain accessing the system color palettes, interfacing mouse etc.
in programs using C.
2
Few changes have been made in the examples and exercises of this
workbook since its last edition which was printed in 2004. Now these are
more comprehensive than those of the previous issue. One lab session of
the previous workbook is replaced by an appendix that discusses various
date and time functions.
3
CONTENTS
4
Lab Session 01
OBJECT
THEORY
Using Menus
If the menu bar is inactive, it may be invoked by pressing the [F10]
function key. To select different menu, move the highlight left or right
with cursor (arrow) keys. You can also revoke the selection by pressing
the key combination for the specific menu.
5
To type a program, you need to open an Edit Window. For this, open file
menu and click “new”. A window will appear on the screen where the
program may be typed.
Writing a Program
When the Edit window is active, the program may be typed. Use the
certain key combinations to perform specific edit functions.
Saving a Program
To save the program, select save command from the file menu. This
function can also be performed by pressing the [F2] button. A dialog box
will appear asking for the path and name of the file. Provide an
appropriate and unique file name. You can save the program after
compiling too but saving it before compilation is more appropriate.
6
Making an Executable File
The source file is required to be turned into an executable file. This is called
“Making” of the
.exe file. The steps required to create an executable file are:
1. Create a source file, with a .c extension.
2. Compile the source code into a file with the .obj extension.
3. Link your .obj file with any needed libraries to produce an executable
program.
Project/Make
Before compiling and linking a file, a part of the IDE called
Project/Make checks the time and date on the file you are going to
compile.
Executing a Program
If the program is compiled and linked without errors, the program is
executed by selecting Run from the Run Menu or by pressing the
[Ctrl+F9] key combination.
7
If every program worked the first time you tried it, that would be the
complete development cycle: Write the program, compile the source
code, link the program, and run it. Unfortunately, almost every
program, no matter how trivial, can and will have errors, or bugs, in the
program. Some bugs will cause the compile to fail, some will cause the
link to fail, and some will only show up when you run the program.
Whatever type of bug you find, you must fix it, and that involves editing
your source code, recompiling and relinking, and then rerunning the
program.
Correcting Errors
If the compiler recognizes some error, it will let you know through the
Compiler window. You’ll see that the number of errors is not listed as 0,
and the word “Error” appears instead of the word “Success” at the
bottom of the window. The errors are to be removed by returning to the
edit window. Usually these errors are a result of a typing mistake. The
compiler will not only tell you what you did wrong; they’ll point you to
the exact place in your code where you made the mistake.
Exiting IDE
An Edit window may be closed in a number of different ways. You can
click on the small square in the upper left corner, you can select close
from the window menu, or you can press the [Alt][F3] combination. To
exit from the IDE select Exit from the File menu or press [Alt][X]
combination.
8
C Program Structure – First C Program
A C program source code can be written in any text editor; however the
file should be saved with .c extension. Lets write the First C program.
1. Create
2. Compile
3. Execute or Run
4. Get the Output
CREATION, COMPILATION AND EXECUTION OF A C PROGRAM:
Prerequisite:
If you want to create, compile and execute C programs by your own, you
have to install C compiler in your machine. Then, you can start to execute
your own C programs in your machine.
You can refer below link for how to install C compiler and compile and
execute C programs in your machine.
Once C compiler is installed in your machine, you can create, compile
and execute C programs as shown in below link.
If you don’t want to install C/C++ compilers in your machine, you can
refer online compilers which will compile and execute C/C++ and many
other programming languages online and display outputs on the screen.
Please search for online C/C++ compilers in Google for more details.
ASIC STRUCTURE OF A C PROGRAM:
Structure of C program is defined by set of rules called protocol, to be followed
by programmer while writing C program. All C programs are having
sections/parts which are mentioned below.
1. Documentation section
2. Link Section
3. Definition Section
4. Global declaration section
5. Function prototype declaration section
6. Main function
7. User defined function definition section
9
/*
1
Documentation section
2
C programming basics & structure of C programs
3
Author: New Author
4
Date :01/01/2018
5
*/
6
7
#include <stdio.h> /* Link section */
8
int total = 0; /* Global declaration, definition section */
9
int sum (int, int); /* Function declaration section */
10
int main () /* Main function */
11
{
12
printf ("This is a C basic program \n");
13
total = sum (1, 1);
14
printf ("Sum of two numbers : %d \n", total);
15
return 0;
16
}
17
18
int sum (int a, int b) /* User defined function */
19
{
20
return a + b; /* definition section */
21
}
22
OUTPUT:
This is a C basic program
Sum of two numbers : 2
10
during compilation.
Example : /* comment line1
comment line2 comment 3
*/
A SIMPLE C PROGRAM:
Below C program is a very simple and basic program in C programming
language. This C program displays “Hello World!” in the output window. And,
11
all syntax and commands in C programming are case sensitive. Also, each
statement should be ended with semicolon (;) which is a statement terminator.
1 #include <stdio.h>
2 int main()
3{
4 /* Our first simple C basic program */
5 printf("Hello World! ");
6 getch();
7 return 0;
8}
OUTPUT:
Hello World!
12
Lab Session 02
if, else, switch, case, default – Used for decision control programming
structure.
int, float, char, double, long – These are the data types and used during
variable declaration.
13
for, while, do – types of loop structures in C.
continue – It is generally used with for, while and dowhile loops, when
compiler encounters this statement it performs the next iteration of the loop,
skipping rest of the statements of current iteration.
Operators
I. Arithmetic Operators
I. Arithmetic Operators
* Multiplication
/ division
15
Below table will explain the difference between pre/post increment and
decrement operators in C programming language
value of i is decremented
Post decrement operator (i- - after assigning it to variable
) i
#include <stdio.h>
int main()
{
int i=0;
16
while(i++ < 5 )
{
printf("%d ",i);
}
return 0;
}
Output:
12345
Step 1 : In this program, value of i “0” is compared with 5 in while
expression.
Step 2 : Then, value of “i” is incremented from 0 to 1 using post-
increment operator.
Step 3 : Then, this incremented value “1” is assigned to the variable “i”.
Above 3 steps are continued until while expression becomes false and
output is displayed as “1 2 3 4 5”.
Output:
9876
Step 1 : In above program, value of “i” is decremented from 10 to 9
using pre-decrement operator.
Step 2 : This decremented value “9” is compared with 5 in while
expression.
Step 3 : Then, this decremented value “9” is assigned to the variable “i”.
Above 3 steps are continued until while expression becomes false and
output is displayed as “9 8 7 6”.
17
Output:
98765
Step 1 : In this program, value of i “10” is compared with 5 in while
expression.
Step 2 : Then, value of “i” is decremented from 10 to 9 using post-
decrement operator.
Step 3 : Then, this decremented value “9” is assigned to the variable “i”.
Above 3 steps are continued until while expression becomes false and
output is displayed as “9 8 7 6 5”.
Operators
Example/Description
= sum = 10;
10 is assigned to variable
sum
+= sum += 10;
This is same as sum = sum +
10
-= sum -= 10;
This is same as sum = sum –
10
*= sum *= 10;
This is same as sum = sum *
10
sum /= 10;
/= This is same as sum = sum /
10
%= sum %= 10;
This is same as sum = sum %
10
18
&= sum&=10;
This is same as sum = sum &
10
sum ^= 10;
^= This is same as sum = sum ^
10
Operators
Example/Description
>
x > y (x is greater than y)
<=
x <= y (x is less than or equal
to y)
== x == y (x is equal to y)
!= x != y (x is not equal to y)
#include <stdio.h>
int main()
{
19
int m=40,n=20;
if (m == n)
{
printf("m and n are equal");
}
else
{
printf("m and n are not equal");
}
}
Output:
m and n are not equal
V. Logical Operators
Operators Example/Description
&& (logical AND) (x>5)&&(y<5)
It returns true when both
conditions are true
|| (logical OR) (x>=10)||(y>=10)
It returns true when at-least one of
the condition is true
! (logical NOT) !((x>5)&&(y<5))
It reverses the state of the operand
“((x>5) && (y<5))”
If “((x>5) && (y<5))” is true, logical
NOT operator makes it false
#include <stdio.h>
20
int main()
{
int x=1, y ;
y = ( x ==1 ? 2 : 0 ) ;
printf("x value is %d\n", x);
printf("y value is %d", y);
}
Output:
x value is 1
y value is 2
TRUTH TABLE FOR BIT WISE OPERATION & BIT WISE OPERATORS:
Note:
21
Bit wise NOT : Value of 40 in binary is 00000000000000000000000000000000
00000000000000000010100000000000. So, all 0’s are converted into 1’s in bit
wise NOT operation.
Bit wise left shift and right shift : In left shift operation “x << 1 “, 1 means that
the bits will be left shifted by one place. If we use it as “x << 2 “, then, it means
that the bits will be left shifted by 2 places.
#include <stdio.h>
int main()
{
int m = 40,n = 80,AND_opr,OR_opr,XOR_opr,NOT_opr ;
AND_opr = (m&n);
OR_opr = (m|n);
NOT_opr = (~m);
XOR_opr = (m^n);
printf("AND_opr value = %d\n",AND_opr );
printf("OR_opr value = %d\n",OR_opr );
printf("NOT_opr value = %d\n",NOT_opr );
printf("XOR_opr value = %d\n",XOR_opr );
printf("left_shift value = %d\n", m << 1);
printf("right_shift value = %d\n", m >> 1);
}
Output:
AND_opr value = 0
OR_opr value = 120
NOT_opr value = -41
XOR_opr value = 120
left_shift value = 80
right_shift value = 20
22
VIII . Special Operators
Below are some of the special operators that the C programming language
offers.
Operators Description
These identifiers actually have upto 6 parts as shown in the table below. They
MUST be used in the order shown.
% Flags Minimum Period Precision.
field width Maximum Argument
field width type
Format Specifiers
Format Specifiers tell the printf statement where to put the text and how to
display the text.
The various format specifiers are:
char
%c Character
unsigned char
short
unsigned short
%d Signed Integer
int
long
23
float
%e or %E Scientific notation of float values
double
float
%g or %G Similar as %e or %E
double
short
unsigned short
%i Signed Integer
int
long
unsigned int
%lu Unsigned integer
unsigned long
short
unsigned short
%o Octal representation of Integer. int
unsigned int
long
%s String char *
unsigned int
%u Unsigned Integer
unsigned long
24
int
unsigned int
long
%n Prints nothing
%% Prints % character
Flags
The format identifers can be altered from their default function by applying the
following flags:
- Left justify.
0 Field is padded with 0's instead of blanks.
+ Sign of number always O/P.
blank Positive values begin with a blank.
# Various uses:
%#o (Octal) 0 prefix inserted.
%#x (Hex) 0x prefix added to non-zero values.
%#X (Hex) 0X prefix added to non-zero values.
%#e Always show the decimal point.
%#E Always show the decimal point.
%#f Always show the decimal point.
%#g Always show the decimal point trailing
zeros not removed.
%#G Always show the decimal point trailing
zeros not removed.
They are used with % to limit precision in floating point number. The
number showing limit follows the radix point.
25
printf("%d\n", c);
output will print
9876
-3
501
Escape Sequences
Escape Sequence causes the program to escape from the normal
interpretation of a string, so that the next character is recognized as
having a special meaning. The back slash “\” character is called the
Escape Character”. The escape sequence includes the following:
\n => new line
\b => back space
carriage
\r => return
double
\” => quotations
back slash
\\ => etc.
Getting Input From the User
The input from the user can be taken by the following techniques:
scanf( ), getch( ), getche( ), getchar( ) etc.
Examples
1. Implementing a Simple C Program
#include<conio.h>
#include<stdio.h>
void main(void)
{
clrscr();
printf(“\n Hello World”);
getch();
}
26
2. Demonstrating the fundamentals of C Language
#include<conio.h>
#include<stdio.h>
void main(void)
{
clrscr();
int num1,num2,sum,product;
printf(“\tThe program takes two numbers as input and
prints their sum and product”);
printf(“\n Enter first number:”);
scanf(“%d”,&num1);
printf(“\n Enter second number:”);
scanf(“%d”,&num2);
sum=num1+num2;
product=num1*num2;
printf(“\n%d+%d=%d”,num1,num2,sum);
printf(“\n%d*%d=%d”,num1,num2,product);
getch();
}
27
EXERCISES
1. Type the following program in C Editor and execute it. Mention the
Error (if any).
void main(void)
{
printf(“This is my first program in C”);
}
__________________________________________________________________________
_
__________________________________________________________________________
_
__________________________________________________________________________
_
__________________________________________________________________________
_
__________________________________________________________________________
_
__________________________________________________________________________
_
__________________________________________________________________________
_
__________________________________________________________________________
_
__________________________________________________________________________
_
28
__________________________________________________________________________
_
__________________________________________________________________________
_
__________________________________________________________________________
_
__________________________________________________________________________
_
__________________________________________________________________________
_
__________________________________________________________________________
_
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
29
SET A
SET B
1. WAP to swap two integers –
i) Using temporary variable
ii) Without Using temporary variable
a) Using + and – operator
b) Using / and *
30
Lab Session 03
OBJECT
THEORY
One of the most innovative and useful features of Turbo C++ is the
integration of debugging facilities into the IDE.
Even if your program compiles perfectly, it still may not work. Such
errors that cause the program to give incorrect results are called
Logical Errors. The first thing that should be done is to review the
listing carefully. Often, the mistake will be obvious. But, if it is not,
you’ll need the assistance of the Turbo C Debugger.
31
line of the program in turn by pressing [F7]. Eventually you’ll reach the
first if statement:
This statement is true (since number is –50); so, as we would expect the
run bar moves to the second if statement:
This is false. Because there’s no else matched with the second if, we
would expect the run bar to the printf( ) statement. But it doesn’t! It
goes to the line
answer = 0;
Now that we see where the program actually goes, the source of the bug
should become clear. The else goes with the last if, not the first if as the
indenting would lead us to believe. So, the else is executed when the
second if statement is false, which leads to erroneous results. We need
to put braces around the second if, or rewrite the program in some
other way.
Watches
Single stepping is usually used with other features of the debugger. The
most useful of these is the watch (or watch expression). This lets you
see how the value of variable changes as the program runs. To add a
watch expression, press [Ctrl+F7] and type the expression.
Breakpoints
It often happens that you’ve debugged part of your program, but must
deal with a bug in another section, and you don’t want to single-step
through all the statements in the first part to get to the section with the
bug. Or you may have a loop with many iterations that would be tedious
to step through. The way to do this is with a breakpoint. A breakpoint
marks a statement where the program will stop. If you start the program
with [Ctrl][F9], it will execute all the statements up to the breakpoint,
then stop. You can now examine the state of the variables at that point
using the watch window.
Installing breakpoints
To set a breakpoint, first position the cursor on the appropriate line.
Then select Toggle Breakpoint from the Debug menu (or press
[Ctrl][F8]). The line with the breakpoint will be highlighted. You can
install as many breakpoints as you want. This is useful if the program
32
can take several different paths, depending on the result of if
statements or other branching constructs.
Removing Breakpoints
You can remove a single breakpoint by positioning the cursor on the
line with the breakpoint and selecting Toggle breakpoint from the Debug
menu or pressing the [Ctrl][F8] combination (just as you did to install
the breakpoint). The breakpoint highlight will vanish.
You can all set Conditional Breakpoints that would break at the specified
value only.
EXERCISES
++;
Before
Executio After Execution
n
x y avg x y avg
iii. int x=your_roll_no,y=your_roll_no+50;
float avg;
avg=(x+y)/2;
33
Lab Session 04
OBJECT
THEORY
Normally, your program flows along line by line in the order in which it
appears in your source code. But, it is sometimes required to execute a
particular portion of code only if certain condition is true; or false i.e.
you have to make decision in your program. There are three major
decision making structures. Four decision making structures:
1. If statement
2. If-else statement
3. Switch case
4. Conditional Operator (Rarely used)
The if statement
The if statement enables you to test for a condition (such as whether
two variables are equal) and branch to different parts of your code,
depending on the result. The simplest form of an if statement is:
if (expression)
statement;
The expression may consist of logical or relational operators like (> >= < <=
&& || )
void main(void)
{
int var;
printf(“Enter any number;”);
scanf(“%d”,&var);
if(var==10)
printf(“The user entered number is Ten”);
}
if (expression)
statement;
else
statement;
34
Note: To execute multiple statements when a condition is true or false,
parentheses are used.
Consider the following example that checks whether the input character
is an upper case or lower case:
void main(void)
{
char ch;
printf(“Enter any character”);
ch=getche();
if(ch>=’A’&&ch<=’Z’)
printf(“%c is an upper case character”,ch);
else
printf(“%c is a lower case character”,ch);
getch();
}
An Example:
void main(void)
{
clrscr();
float per;
printf(“\n Enter your percentage;”);
scanf(“%f”,&per);
printf(“\n you are”);
printf(“%s”, per >= 60 ?“Passed”: ”Failed”);
getch();
}
35
Typecasting
Typecasting allow a variable of one type to act like another for a single
operation. In C typecasting is performed by placing, in front of the
value, the type name in parentheses.
36
EXERCISES
__________________________________________________________________________
_
__________________________________________________________________________
_
__________________________________________________________________________
_
__________________________________________________________________________
_
__________________________________________________________________________
_
__________________________________________________________________________
_
37
__________________________________________________________________________
_
__________________________________________________________________________
_
__________________________________________________________________________
_
__________________________________________________________________________
_
__________________________________________________________________________
_
__________________________________________________________________________
_
Assignments :-
Set A
#include<stdio.h>
void main()
{
int a=100;
if(a>10)
printf("Good");
else if(a>20)
printf("Better");
else if(a>30)
printf("Best");
}
2. WAP that takes a number as input from user and checks whether the
number is even or odd.
a) Using if-else
b) Using conditional operator:
5. WAP that takes a number as input from user and checks whether the
number is even or odd
a) Using if-else
b) Using conditional operator:
38
6. WAP that takes three numbers as input from user and finds maximum
a) Using if-else
b) Using conditional operator:
7. WAP that takes three numbers as input from user and finds minimum
a) Using if-else
b) Using conditional operator:
Set B
1. WAP to take input student age and check whether given student can vote
or not
2. WAP to check whether a given year is leap year or not.
3. WAP to print grade of a student using If Else Ladder Statement
4. WAP to find the roots of quadratic equation.
39
Lab Assignment 05
OBJECT
THEORY
}
getch();
}
40
Important Points about Switch Statement
SET A
1. Give the output of following code with explaination
a. #include<stdio.h>
#define L 10
void main()
{
auto a = 10;
switch (a, a*2)
{
case L:
printf("ABC");
break;
case L*2:
printf("XYZ");
break;
case L*3:
printf("PQR");
break;
default:
printf("MNO");
case L*4:
printf("www");
break;
}
41
}
b.
#include <stdio.h>
int main()
{
int num = 2;
switch (num + 2)
{
case 1:
printf("Case 1: ");
case 2:
printf("Case 2: ");
case 3:
printf("Case 3: ");
default:
printf("Default: ");
}
return 0;
}
42
Lab Assignment 06
OBJECT
Study of Loops(While)
THEORY
A loop is used for executing a block of statements repeatedly until a given
condition returns false.
Types of Loops
There are three types of Loops:
for Loop
while Loop
do - while Loop
Flowchart:
43
Example of while loop
#include <stdio.h>
int main()
{
int count=1;
while (count <= 4)
{
printf("%d ", count);
count++;
}
return 0;
}
Output:
1234
step1: The variable count is initialized with value 1 and then it has been tested
for the condition.
step2: If the condition returns true then the statements inside the body of
while loop are executed else control comes out of the loop.
step3: The value of count is incremented using ++ operator then it has been
tested again for the loop condition.
44
The do-while Loop
do
{
this;
}
while(condition is true);
This loop runs as long as the condition in the parenthesis is true. Note
that there is a semicolon after the “while” statement. The difference
between the “while” and the “do-while” statements is that in the
“while” loop the test condition is evaluated before the loop is executed,
while in the “do” loop the test condition is evaluated after the loop is
executed. This implies that statements in a “do” loop are executed at
least once. However, the statements in the “while” loop are not
necessarily executed.
Flowchart:
45
printf("Value of variable j is: %d\n", j);
j++;
}while (j<=3);
return 0;
}
Output:
SET A
SET B
1. WAP to print following pattern.
a) for example if n=5 then output should be
*
* *
* * *
* * * *
* * * * *
*
* *
* * *
* * * *
* * * * *
46
2. WAP to print the square of number(s) repeatedly till 1 is entered by
user. Using do-while loop.
3. WAP to print following series
a) Fibonacci series of n numbers
b) 1+3+5+7+--------+n
SET C
47
Lab Assignment 07
OBJECT
THEORY
For loop
This is one of the most frequently used loop in C programming.
Step 1: First initialization happens and the counter variable gets initialized.
Step 2: In the second step the condition is checked, where the counter variable
is tested for the given condition, if the condition returns true then the C
statements inside the body of for loop gets executed, if the condition returns
false then the for loop gets terminated and the control comes out of the loop.
Step 3: After successful execution of statements inside the body of loop, the
counter variable is incremented or decremented, depending on the operation
(++ or –).
Example of For loop
#include <stdio.h>
int main()
{
48
int i;
for (i=1; i<=3; i++)
{
printf("%d\n", i);
}
return 0;
}
Output:
1
2
3
Various forms of for loop in C
1) Here instead of num++, I’m using num=num+1 which is same as num++.
for (num=10; num<20; num=num+1)
2) Initialization part can be skipped from loop as shown below, the counter
variable is declared before the loop.
int num=10;
for (;num<20;num++)
Note: Even though we can skip initialization part but semicolon (;) before
condition is must, without which you will get compilation error.
3) Like initialization, you can also skip the increment part as we did below. In
this case semicolon (;) is must after condition logic. In this case the increment
or decrement part is done inside the loop.
for (num=10; num<20; )
{
//Statements
num++;
}
4) This is also possible. The counter variable is initialized before the loop and
incremented inside the loop.
int num=10;
for (;num<20;)
{
//Statements
num++;
}
5) As mentioned above, the counter variable can be decremented as well. In the
below example the variable gets decremented each time the loop runs until the
condition num>10 returns false.
for(num=20; num>10; num--)
Nested For Loop in C
Nesting of loop is also possible. Lets take an example to understand this:
#include <stdio.h>
int main()
{
for (int i=0; i<2; i++)
{
for (int j=0; j<4; j++)
{
printf("%d, %d\n",i ,j);
}
}
return 0;
}
Output:
0, 0
49
0, 1
0, 2
0, 3
1, 0
1, 1
1, 2
1, 3
Exercise as an assignment:-
Solve all programs given for while and do while loops using for loop
SET A
SET B
1. WAP a class of n students take an annual examination in 3 subjects. WAP
to read the marks obtained by each student in various subjects and to
compute and print the total marks obtained by each of them
2. WAP to calculate the series 1+x+x2+x3+-----+xn
3. WAP to l ask the user to input 5 numbers and print out the maximum and
minimum
numbers from the set.
4. WAP to find power of a number (xn)
5. WAP to program to count frequency of digits in a given number
6. WAP to program to find HCF(GCD) of two numbers
7. WAP to program to find LCM of two numbers
SET C
1. WAP to find 1s complement of a binary number
2. WAP to convert from Decimal to Binary number system
50
Lab Assignment 08
OBJECT
THEORY
C programming allows to use one loop inside another loop.
Syntax
The syntax for a nested for loop statement in C is as follows −
for ( init; condition; increment ) {
while(condition) {
statement(s);
}
statement(s);
}
The syntax for a nested do...while loop statement in C programming language
is as follows −
do {
statement(s);
do {
statement(s);
}while( condition );
}while( condition );
A final note on loop nesting is that you can put any type of loop inside any
other type of loop. For example, a 'for' loop can be inside a 'while' loop or vice
versa.
Example
The following program uses a nested for loop to find the prime numbers from 2
to 100 −
Live Demo
#include <stdio.h>
int main () {
return 0;
}
Output:
2 is prime
3 is prime
5 is prime
7 is prime
11 is prime
13 is prime
17 is prime
19 is prime
23 is prime
29 is prime
31 is prime
37 is prime
41 is prime
43 is prime
47 is prime
53 is prime
59 is prime
61 is prime
67 is prime
71 is prime
73 is prime
79 is prime
83 is prime
89 is prime
97 is prime
SET A
* ****
* ***
* **
* *
*
52
3. WAP to pattern program of stars and alphabets
*
*A*
*A*A*
*A*A*A*
SET B
1. WAP to print all the composite numbers from 2 to a certain number entered
by user.(A number is said to be composite if it has at least one factor other
than 1 and itself)
53
Lab Assignment 09
OBJECT
Jumping Statements :
C language provides us multiple statements through which we can transfer the
control anywhere in the program.
Syntax: break;
NOTE: This jumping statements always used with the control structure like
switch case, while, do while, for loop etc.
#include<stdio.h>
#include<conio.h>
void main()
{
int i=1;
for(i=1;i<=10;i++)
{
printf(“Enter ”,i,”no”);
printf(“ \t %d ”,i);
if(i>5)
break;
}
}
Syntax: continue;
NOTE: This jumping statements always used with the control structure like
switch case, while, do while, for loop etc.
#include<stdio.h>
#include<conio.h>
void main()
{
int i=1;
for(i=1;i<=10;i++)
{
printf(“Enter ”,i,”no”);
printf(“ \t %d ”,i);
if(i==5 || i==8)
continue;
}
}
NOTE:
· The control will transfer to those label that are part of particular
function, where goto is specified.
· All those labels will not include, that are not the part of a particular
function where the goto is specified.
NOTE:
· It is good programming style to use the break, continue and return
instead of goto.
· However, the break may execute from single loop and goto executes from
more deeper loops.
55
Example: Program based upon continue jumping statements:
WAP to display the square root of a no, if no. is not positive then re enter the
input.
#include<stdio.h>
#include<conio.h>
void main()
{
int i,n;
float s;
start:
printf(“Enter a no.”);
scanf(“%d”,&n);
s=sqrt(n);
if(n<=0)
goto start;
printf(“%f”,s);
}
Exit
#include<stdio.h>
#include<stdlib.h>
int main () {
printf("Start of the main()...\n");
printf("Exiting the main()...\n");
exit(0);
printf("End of the program\n");
return(0);
}
56
SET A
Give the output of following codes with proper explaination
1. #include <stdio.h>
int main()
{
int a = 0, i = 0, b;
for (i = 0;i < 5; i++)
{
a++;
continue;
}
}
2. #include <stdio.h>
int main()
{
int a = 0, i = 0, b;
for (i = 0;i < 5; i++)
{
a++;
if (i == 3)
break;
}
}
3. #include <stdio.h>
void main()
{
int i = 0, j = 0;
for (i = 0;i < 5; i++)
{
for (j = 0;j < 4; j++)
{
if (i > 1)
break;
}
printf("Hi \n");
}
}
4.
#include <stdio.h>
void main()
{
int i = 0;
int j = 0;
for (i = 0;i < 5; i++)
{
57
for (j = 0;j < 4; j++)
{
if (i > 1)
continue;
printf("Hi \n");
}
}
}
5.
#include <stdio.h>
int main()
{
int num;
printf("Enter value of num:");
scanf("%d",&num);
switch (num)
{
case 1:
printf("You have entered value 1\n");
break;
case 2:
printf("You have entered value 2\n");
case 3:
printf("You have entered value 3\n");
break;
default:
printf("Input value is other than 1,2 & 3 ");
}
return 0;
}
6. #include <stdio.h>
int main()
{
int var;
for (var =100; var>=10; var --)
{
printf("var: %d\n", var);
if (var==99)
{
break;
}
}
printf("Out of for-loop");
return 0;
}
58
7.
#include <stdio.h>
int main()
{
int i = 0;
for (i=0; i<20; i++)
{
switch(i)
{
case 0:
i += 5;
case 1:
i += 2;
case 5:
i += 5;
default:
i += 4;
break;
}
printf("%d ", i);
}
return 0;
}
8.
#include <stdio.h>
int main()
{
int i = 0;
do
{
i++;
if (i == 2)
continue;
printf("In while loop ");
} while (i < 2);
printf("%d\n", i);
}
9. #include <stdio.h>
int main()
{
int i = 0, j = 0;
for (i; i < 2; i++){
for (j = 0; j < 3; j++){
printf("1\n");
break;
}
printf("2\n");
59
}
printf("after loop\n");
}
10.
#include <stdio.h>
int main()
{
int i = 0;
char c = 'a';
while (i < 2){
i++;
switch (c) {
case 'a':
printf("%c ", c);
break;
break;
}
}
printf("after loop\n");
}
11.
#include <stdio.h>
int main()
{
printf("%d ", 1);
goto l1;
printf("%d ", 2);
l1:goto l2;
printf("%d ", 3);
l2:printf("%d ", 4);
}
13.
#include <stdio.h>
int main()
{
printf("%d ", 1);
goto l1;
60
printf("%d ", 2);
}
void foo()
{
l1 : printf("3 ", 3);
}
14.
#include <stdio.h>
int main()
{
int i = 0, j = 0;
while (i < 2)
{
l1 : i++;
while (j < 3)
{
printf("Loop\n");
goto l1;
}
}
}
15.
#include <stdio.h>
int main()
{
int i = 0, j = 0;
while (l1: i < 2)
{
i++;
while (j < 3)
{
printf("loop\n");
goto l1;
}
}
}
16.
#include <stdio.h>
int main()
{
int i = 0, j = 0;
l1: while (i < 2)
{
i++;
while (j < 3)
{
61
printf("loop\n");
goto l1;
}
}
}
17.
#include <stdio.h>
void main()
{
int i = 0;
if (i == 0)
{
goto label;
}
label: printf("Hello");
}
18.
#include <stdio.h>
void main()
{
int i = 0, k;
if (i == 0)
goto label;
for (k = 0;k < 3; k++)
{
printf("hi\n");
label: k = printf("%03d", i);
}
}
19.
#include <stdio.h>
#include <stdlib.h>
int main()
{
printf("statement-1\n");
printf("statement-2\n");
exit(0);
printf("statement-N\n");
return 0;
}
62
SET B
63
Lab Assignment 10
OBJECT
SET A
SET B
1. Write a C program for a menu driven program which has following options:
1. Factorial of a number.
2. Prime or not
3. Odd or even
4. Exit
2. Write a menu driven C program using switch-case to find:
(a) Sum of the digits of number
(b) product of the digits of number.
SET C
64
Lab Session 11
OBJECT
Study of Functions
(User defined)
THEORY
User-defined functions
There are four types of functions depending on the return type and arguments:
1. Functions that take nothing as argument and
return nothing.
2. Functions that take arguments but return nothing.
3. Functions that do not take arguments but return
something.
4.Functions that take arguments and return
something.
General syntax for function declaration is,
returntype functionName(type1 parameter1, type2 parameter2,...);
Like any variable or an array, a function must also be declared before its used.
Function declaration informs the compiler about the function name,
parameters is accept, and its return type. The actual body of the function can
be defined separately. It's also called as Function Prototyping. Function
declaration consists of 4 parts.
returntype
function name
parameter list
65
terminating semicolon
returntype
When a function is declared to perform some sort of calculation or any
operation and is expected to provide with some result at the end, in such
cases, a return statement is added at the end of function body. Return type
specifies the type of value(int, float, char, double) that function is expected to
return to the program which called the function.
Note: In case your function doesn't return any value, the return type would be
void.
functionName
Function name is an identifier and it specifies the name of the function. The
function name is any valid C identifier and therefore must follow the same
naming rules like other variables in C language.
parameter list
The parameter list declares the type and number of arguments that the
function expects when it is called. Also, the parameters in the parameter list
receives the argument values when the function is called. They are often
referred as formal parameters.
functionbody
The function body contains the declarations and the statements(algorithm)
necessary for performing the required task. The body is enclosed within curly
braces { ... } and consists of three parts.
local variable declaration(if required).
function statements to perform the task inside the function.
66
a return statement to return the result evaluated by the function(if return type
is void, then no return statement is required).
Calling a function
When a function is called, control of the program gets transferred to the
function.
functionName(argument1, argument2,...);
In the example above, the statement multiply(i, j); inside the main() function is
function call.
Consider another example that adds two numbers using a function sum() .
void sum(void);
void main(void)
{
printf(“\nProgram to print sum of two numbers\n”);
sum(void);
}
void sum(void)
{
int num1,num2,sum;
printf(“Enter 1st number:”);
scanf(“%d”,&num1);
printf(“Enter 2nd number:”);
scanf(“%d”,&num2);
sum=num1+num2;
printf(“Sum of %d+%d=%d”,num1,num2,sum);
}
SET A
a) func(int a,int b)
{
int a; a=20; return a;
}
68
int myfunc(int); int b; b=myfunc(20); printf(“%d”,b); return 0;
}
int myfunc(int a)
{
a > 20? return(10): return(20);
}
3. WAP to print your name 10 times. The function can take no arguments
and should not return any value.
SET B
1.WAP to print the GCD of 4 given numbers using function to calculate the
GCD of two numbers*/
2. WAP to find the factorial of an Integer
3. WAP to Calculate the value of nCr
5. main( ) is a function. Write a function which calls main( ). What is the
output of this program?
SET C
1 . WAP that takes a number as input and print its binary equivalent.
69
Lab Assignment 12 and Assignment 13
Study of Functions
call By value
call By Reference
Unlike call by value, in this method, address of actual arguments (or
parameters) is passed to the formal parameters, which means any operation
performed on formal parameters affects the value of actual parameters.
SET A
Trace the output .Give proper explaination
1. # include<stdio.h>
void fun(int*, int*);
int main()
{
int i=5, j=2;
fun(&i, &j);
printf("%d, %d", i, j);
return 0;
}
void fun(int *i, int *j)
{
*i = *i**i;
*j = *j**j;
}
1. Using a function, swap the values of two variables. The function takes
two values of Variables as arguments and returns the swapped
values.(call by value)
2. Write function definition that takes two complex numbers as argument
and prints their sum.
70
Write a C program to print all even or odd numbers in given range.
3. Check if an integer (entered by the user) can be expressed as the sum of
two prime numbers of all possible combinations with the use of functions.
71
Lab Session 14
OBJECT
Recursion
Recursion is an ability of a function to call itself.
int add(int);
void main(void)
{
int num,ans;
printf(“Enter any number:”);
scanf(“%d”,&num);
ans=add(num);
printf(“Answer=%d”,ans);
getch();
}
int add(int n)
{
int result;
if(n==1)
return 1;
result=add(n-1) + n;
return result;
}
SET A
1. Trace the output
#include<stdio.h>
int i;
int fun();
int main()
{
while(i)
{
fun();
main();
72
}
printf("Hello\n");
return 0;
}
int fun()
{
printf("Hi");
}
SET B
4. WAP to Find the power of a number using Recursion
73
Lab Session 15
OBJECT
Study of Arrays
THEORY
#include<stdio.h>
74
void main(void)
{
clrscr();
int arr[10];
for(int i=0;i<10;i++)
{
printf(“\n\tEnter element %d:”,i+1);
scanf(“%d”,&arr[i]);
}
clrscr();
for(int j=0;j<10;j++)
printf(“\n\n\t Element %d is %d”,j+1,arr[j]);
getch();
}
EXERCISES
SET A
SET C
75
Lab Session 16
OBJECT
Above code are three different ways to initialize a two dimensional arrays.
76
SET A
1. WAP to store temperature of two cities for a week and display it.
2. WAP to find the sum of two matrices of order 2*2 using multidimensional
arrays.
3. WAP to store values entered by the user in a three-dimensional array and
display it.
SET B
SET C
77
Lab Session 17
OBJECT
78
SET A
1. WAP to check whether given character is
a. Alphabet or not
b. Digit or not
c. symbol or not
2.WAP to check whether a given character is upper case. If it is upper case
convert it to lower case
SET B
SET C
1. Check Armstrong Number of n digits
79
80
Savitribai Phule Pune University,Pune
F. Y. B. C. A. (Science) Semester-I
Lab Course – II
Fundamentals of Computer
Workbook
Name: ___________________________________________________________
College Name:____________________________________________________
Academic Year:__________________
1
Editors:
2
Introduction
This workbook is intended to be used by FYBCA (Science) students for the Programming
in C& Fundamental of computers Assignments in Semester–I. This workbook is designed
by considering all the practical concepts / topics mentioned in syllabus.
You have to ensure appropriate hardware and software is made available to each
student.
The operating system and software requirements on server side and also client side
areas given below:
Server and Client Side-(Operating System) Fedora Core Linux/Windows
Turbo C
4
Table of Contents
DOS Commands
Assignment 2 ............................................................................... 16
Microsoft word I
Assignment 4 ............................................................................... 28
Microsoft word II
Assignment 5 ............................................................................... 29
Spreadsheet I
Assignment 6 ............................................................................... 33
Spreadsheet II
Assignment 7 ............................................................................... 35
Assignment 8 ............................................................................... 39
Shell Commands
5
Section IV : HTML
Assignment 10 ............................................................................. 47
Introduction to HTML
Assignment 11 ............................................................................. 54
Assignment 12 ............................................................................. 58
Assignment 13 ............................................................................. 62
Assignment 14 ............................................................................. 66
6
Assignment Completion Sheet
Lab Course II
Fundamentals of Computers
3 Microsoft Word I
4 Microsoft Word II
5 Spreadsheet I
6 Spreadsheet II
7 Microsoft PowerPoint I
8 Microsoft PowerPoint II
9 Shell Command
10 Introduction to HTML
8
Assignment No 1
DOS COMMANDS
Syntax Notes
To be functional, each DOS command must be entered in a particular way: this command entry
structure is known as the command's "syntax." The syntax "notation" is a way to reproduce the command
syntax in print.
For example, you can determine the items that are optional, by looking for information that is printed
inside square brackets. The notation [d:], for example, indicates an optional drive designation. The
command syntax, on the other hand, is how YOU enter the command to make it work.
7. Filename Extension
A filename extension can follow the filename to further identify it. The extension follows a period
and can be of three or fewer characters. A filename extension is not required.
8. Switches
Characters shown in a command syntax that are represented by a letter or number and preceded
by a forward slash (for example, "/P") are command options (sometimes known as "switches").
Use of these options activate special operations as part of a DOS command's functions.
9. Brackets
Items enclosed in square brackets are optional; in other words, the command will work in its
basic form without entering the information contained inside the brackets.
9
10. Ellipses
Ellipses (...) indicate that an item in a command syntax can be repeated as many times as
needed.
11. Vertical Bar
When items are separated by a vertical bar (|), it means that you enter one of the separated items.
For example: ON | OFF means that you can enter either ON or OFF, but not both.
1. Internal Commands
These are for performing basic operations on files and directories and they do not need any external
file support.
2. External Commands
These external commands are for performing advanced tasks and they do need some external
file support as they are not stored in COMMAND.COM
In MS-DOS, keyboard shortcuts involving handy ones like Functional keys, arrows, pipe character (” | “),
asterisk (*), ?, [] and ESC are of great help for recalling to searching to clearing command line etc., Here
are few of them:
UP ( ) and DOWN (Ļ) arrows recall previously entered commands.
ESC clears the present command line. It abandons the currently construct command and the
10
MS-DOS commands perform tasks like:
1. Date
This command is used to display the system current date setting and prompt you to enter a new date.
The syntax is: DATE [/T | date]
If you type DATE without parameters then it displays current date and prompts to enter new date. We
should give new date in mm-dd-yy format. If you want to keep the same date just Press ENTER. DATE
command with /T switch tells the command to just output the current system date, without
prompting for a new date.
2. TIME
Same as DATE command, typing TIME with no parameters displays the current time and a prompt for
a new one. Press ENTER to keep the same time. TIME command used with /T switch tells the
command to just output the current system time, without prompting for a new time.
3.COPY CON
It is used to create a file in the existing directory. Here CON is a DOS reserved word which stands for
console.
Syntax is: COPY CON filename after that press Enter and start typing your text and after you’re done
typing your text, to save and exit hit F6 key.
11
4.TYPE
This command is used to display the contents of a text file or files. The syntax is:TYPE
[drive:][path]filename
5. CLS
6. REN
This command is used to change/modify the name of a file or files.
Syntax is: REN [drive:] [path] filename1 filename2.
Here, filename1 is source file for which you wanted to change the name, and filename2 will obviously
becomes your new file name. Also note that you cannot specify a new drive or path for your destination
file.
7. DIR
This command displays a list of files and subdirectories in a directory. Syntax is:DIR
[drive:] [path] [filename] [/A[[:]attributes]] [/B] [/C] [/D] [/L]
12
Here,
13
8. PATH
This command displays the path that how we have come to the present position or sets a search path
for executable files.
Its Syntax is PATH [[drive:]path[;…][;%PATH%]]
Typing PATH without any parameters displays the current path under current directory. Typing PATH
; clears all search-path settings and direct cmd.exe to search only in the current directory. And
including %PATH% in the new path setting causes the old path to be appended to the new setting.
9. VER
This command displays the version of the Microsoft Windows running on your computer.
10. VOL
It displays the disk volume label and serial number, if they exist for the drive specified. If no drive is
specified it displays for the active drive.
Syntax is VOL [drive:]
11. DEL/ERASE
12. COPY
This command is useful in copying one or more files to another file or location. Syntax is COPY [/D]
[/V] [/N] [/Y | /-Y] [/Z] [/A | /B ] source [/A | /B] [+ source [/A | /B] [+ …]] [destination
[/A | /B]]
The different switches that can be used with this command as follow along with their use.
a. MD (or MKDIR) command stand for make directory and it is used to create a directory.
Syntax is MD [drive:]path
b. CD (or CHDIR) stands for create or change directory and it allows to display the name of
or change the current directory or rather we can say come out of a directory. Syntax is
CD [/D] [drive:][path]
Typing CD drive: displays the current directory in the specified drive. This CD (or CHDIR)
14
command does not treat spaces as delimiters due to which it allows to CD into a subdirectory
name that contains a space without surrounding the name with quotes.
For example:
CHDIR program filesmozilla firefox is
the same as:
CHDIR “program filesmozilla firefox”
If you type CD without any parameters it displays current drive and directory. CD.. specifies that
you want to change to the higher directory in the current path. Whereas, using CD you can directly
change to parent/root directory from any location in the current drive.
Using /D switch changes current drive in addition to current directory for a drive.
c. RD (or RMDIR) command removes or deletes a directory. There are two conditions to remove any
directory – (1) Directory to be removed should be empty. and (2) We should be outside the
directory we are commanding to delete.
Syntax is RD [/S] [/Q] [drive:]path
Here, using the switch /S removes a directory tree meaning it removes all directories and files in the
specified directory in addition to the directory itself. And using /Q is the quiet mode that doesn’t
asks for ok approval to remove a directory tree.
15
Assignment 2
16
Step#2 Now you will get the Windows Setup Window. This is the part to select Language for your
windows. Select ‘English’ and click Next. Also there will be a ‘INSTALL NOW’ button. Click on it and
proceed to next step.
Step #3
17
Step#4 In this step you will do partitioning of your drive. Be careful, this is the most important part
of the Installation. In this you will allocate spaces to your drive. If you want to create a new drive,
simply click on a drive and then click ‘NEW’. A new drive will be created.
Step #5
18
Step#6 Now you windows will start installing its files. Grab a cup of coffee and wait for a few
minutes while it install. During this process don’t plug in or off your device. It might cause
interruption and you might loose your data and have to begin the process all over again.
Step #7
19
Step#8 In this step you have to activate your windows. Simply look at the back of your Windows
CD/DVD cover there will be a PRODUCT KEY. Add this key into your PC and Click ‘NEXT’.
Step #9
20
Last Step – Congratulations:‐ You have installed you windows. Now you can see is your desktop. It
is simple to use, setup your desktop and enjoy!
21
Section II: Microsoft Office
22
Assignment No 3: INTRODUCTION TO MS-OFFICE
Microsoft office is a set of inter related desk top applications ,servers and services, collectively refers to
as an office suit for the micro soft windows and MAC OSX operating systems .
MS WORD:
Microsoft Word is a word processing software package. we can use it to type letters, reports, and
other documents. In Word 2007, how a window displays depends on the size of your window, the
size of Your monitor and the resolution to which your monitor is set. Resolution determines how
much information your computer monitor can
display.
23
STARTING MS WORD:-
Two ways of starting MSWORD:-
Double click on Microsoft word icon on the desk top. Click on start ->programs->ms office -
>msword.
24
The Ribbon
We use the Ribbon to issue commands. The Ribbon is located near the top of the screen,
below the Quick Access toolbar. At the top of the Ribbon are several tabs; clicking a
tab displays several related command groups. Within each group are related command
buttons. You click buttons to issue commands or to access menus and dialog boxes
The Ruler
We can use the ruler to change the format of your document quickly
25
26
Assignment
SET A
SET B
1. Create a document to show the use of Watermark.
2. Create a document with at least three paragraphs and perform editing operations.
SET C
Create a formal letter using a suitable word processing package, like MS Word, to place a
purchase order for procurement of books. Use tables for list of books.
Assignment Evaluation
Signature of Instructor
27
Assignment no. 04
SET A
1. Create a document with at least two pages to show use of header and footer.
2. Create a document to add various shapes with color and text options. Add border to this
pages.
SET B
1. Using word, create September month timetable. It should include the following
a. time slot
b. days of week
c. border
d. subject in each slot
e. proper heading
f. footer: ‘FY BCA TIME TABLE’
2. On Microsoft Word, write a leave application to your College Principal, asking for 3 days
holiday, as you have to attend your sister’s wedding at Nagpur. Create a table for 3 days function,
you will be attending. You will be marked on font, font size, letter format, tabbing, line spacing &
table.
SET C
1. Create a formal letter using MS Word, to place a purchase order for procurement of
books. Use tables for list of books.
2. Open a new document & save it as ‘3G_Hours_Firstname_Lastname’
a. Insert a table that is 3 columns wide by 4 rows high.
b. Enter the information in the table as shown below.
Assignment Evaluation
Signature of Instructor
28
Assignment No 5
29
View alt +v (related to page setting & Layout) Insert
Today (n1,n2) Displays today’s date in the cell =today () calculate the
no. Of days
Insert a worksheet?
To insert a worksheet, go to insert menu and choose worksheet
30
Delete a worksheet?
To delete a worksheet, click on the work sheet name tab, go to edit menu and
choose delete worksheet.
4. Now we have two ranges of cells, which are required for the pie chart- the
names and the net pay of the employees.
5. Click on the chart wizard on the formatting toolbar. The chart wizard appears.
6. In the chart wizard, under the standard types tab, choose pie as chart type.
7. In the sub-type section select the second figure-pie with a 3-d visual effect.
9. Click the finish button. The chart appears as an object in the salary worksheet.
10. Click the save button on the standard toolbar to save the worksheet and the chart.
31
Assignment
SET A
SET B
2. Create a list of your friends in class using the Custom List option. Enter the names of those
friends in an Excel worksheet using the fill handle.
SET C
Assignment Evaluation
Signature of Instructor
32
Assignment No: 06
SET A
1. Create a worksheet to compute mean/median/mode of student percentage.
2. Generate graph to show the production of goods in a company during the last five years.
3. Generation of Telephone Bill
SET B
1. The following are the salaries of five employees. Create a File in MS EXCEL
2. Create a MS-Excel worksheet Display a Pie Chart for following data, Also calculate total marks
and average marks using functions.
1 432
2 300
3 400
4 302
5 455
33
SET C
1. Generate the following worksheet
Roll No. Marks
2050 67
2051 49
2052 40
2053 74
2054 61
2055 57
2056 45
Assignment Evaluation
Signature of Instructor
34
Assignment No 7
Power point is a complete presentation graphics package. It has the powerful features like
power point wizards, toolbars and power point views to create good slides. It has all the tools
required to produce a professional looking presentation, such as text handling, outlining, and
drawing graphics, clipart and so on. Speaker supports and aids help you to create truly
effective presentations. It has wizard, auto layouts, and a complete set of easy to use tools
assuring you to have everything you need to share your knowledge with others.
What is presentation?
Power point is a good way to communicate ideas simply and effectively. For complex topics
that are rich with details, such as a scientific paper or an annual report. Each
presentation consists of one more pages or slides, which can contain text, bulleted lists,
graphics, charts and other data types.
To insert a new slide, you can perform any of the following tasks.
To delete a slide, make that slides current slide and choose duplicate slide from the edit
menu. Slide will be deleted immediately.
Duplicate a slide
To duplicate a slide make that slide current slide and choose duplicate slide from the edit
menu.
35
Creating master slide
If you want to have certain common items on all the pages without adding them individually to
the slides one by one, create a master slide. The items contained in master slide will
automatically become the items for all the slides.
1. Design characters.
2. Arrange the matter in readable form.
3. Add pictures in the charts.
4. Change the appearance of the alphabets on the charts.
5. Print these charts.
Ina new presentation, the slides by default have a width of 10inches, height of 7.5 inches
and landscape orientation. These settings can be changed using the page setup commands.
The procedure for changing the slide setup is follows:
6. Click on the ok button to change slide settings for every slide in your presentation. The
slides will now be 10inches in height, have a width of 7.5inches and the orientation will
be portrait.
Saving a presentation
To save a presentation on disk, click the save button on the standard or choose save
option or save as option from the file menu. Option save is to save the file with current name
and save as the command to save file with some other name.
36
To display a slide show
A presentation can be displayed on the screen by running a slide show. The slides can
be advanced manually or automatically. The procedure for running the slide show is:
1. Click on the slide button. At the bottom of the slide to begin the slide show.
2. Select slide show from the view menu to display a dialog box.
3. One slide is displayed at a time each slide fills the entire screen.
4. Click on the left mouse button or press enter or press page down to move one slide
forward.
5. When we reach the last slide in the presentation, power point brings us back to the
slide view, or any other view that we are in.
6. Click on file menu option
7. Click on close command to close the presentation.
8. Click on exit command to exit from the power point.
1. Choose insert<picture >clipart or double- click a clip art placeholder to open the insert
clip art dialog box.
2. Select the picture you want to insert and click insert menu
37
Assignment
SET A
1. Use Microsoft PowerPoint to create a slideshow entitled “Me!” Your presentation must contain
at least five slides, should be eye-catching and have a creative use of visual and audio effects.
Your slides should also be edited for correct use of spelling and grammar. You should discuss:
Your early life (where you were born, who’s in your family, where you grew up, which
elementary school(s) you attended, etc.)
The person that you are now (hobbies, your favorite music, favorite classes, sports you’re
interested in, what makes you different than other people, etc.)
What you’d like your future to be (which high school and college you would like to graduate
from, your ideal career after graduation, will you be married?, have children?, etc.)
2. Preapare a power point presentation on Indian Festivals.
SET B
1. Use Microsoft PowerPoint to create a slideshow for Input and Output Devices. Your presentation must
contain at least five slides, should be eye-catching and have a creative use of visual and audio effects.
2. Use Microsoft PowerPoint to create a slideshow entitled “My College!” Your presentation must
contain at least five slides, should be eye-catching and have a creative use of visual and audio effects.
Give all information of your college.
SET C
Assignment Evaluation
Signature of Instructor
38
Assignment No 8
SET A
1. Create a PowerPoint slide show on “Air Polution”
2. Create a PowerPoint slide show on BCA (Science) Course information.
SET B
1. Create a PowerPoint slide show on “Swatch Bharat Mission” with the contents given below.
Select a suitable design template and appropriate slide layouts.
Graphics that can enhance your presentation may also be inserted. You can replace
standard bullet symbols with other graphics.
Add animation effects to the bullet items.
Add transition and appropriate sound effects.
2. Use Microsoft PowerPoint to create a slideshow entitled “My Resume!”. Your presentation must
contain at least five slides, should be eye-catching and have a creative use of visual and audio effects.
SET C
Use Microsoft PowerPoint to create a slideshow entitled “ M.S.Office!”. Your presentation must contain at least
five slides, should be eye-catching and have a creative use of visual and audio effects
Assignment Evaluation
Signature of Instructor
39
Section III: Shell Commands
40
Assignment No 9 : Shell Commands
1.Date Command :
Options : -
P = Display AM or PM S = Seconds
2.Calender Command :
This command is used to display the calendar of the year or the particular month of calendar year.
Syntax :
a.$cal b.$cal
Here the first syntax gives the entire calendar for given year & the second Syntax gives the
calendar of reserved month of that year.
3.Echo Command :
This command is used to print the arguments on the screen .
Syntax :
$echo
41
Multi line echo command :
To have the output in the same line , the following commands can be used.
Syntax :
$echo text
To have the output in different line, the following command can be used.
Syntax :
$echo “text >line2 >line3”
4.Banner Command :
It is used to display the arguments in „#‟ symbol .
Syntax :
$banner
5.’who’ Command :
It is used to display who are the users connected to our computer currently.
Syntax :
$who – option‟s
Options : -
H–Display the output with headers.
b–Display the last booting date or time or when the system was lastely rebooted.
7.’tty’ Command :
It will display the terminal name.
Syntax :
$tty
8.’Binary’ Calculator Command : It will change the „$‟ mode and in the new mode, arithematic
operations such as +,- ,*,/,%,n,sqrt(),length(),=, etc can be performed . This command is used to go to
the binary calculus mode.
Syntax :
$bc operations ^d $ 1 base –inputbase 0 base – outputbase are used for base conversions.
9.’CLEAR’ Command :
It is used to clear the screen.
Syntax :
$clear
42
10.’MAN’ Command :
It help us to know about the particular command and its options & working. It is like „help‟
command in windows .
Syntax :
$man <command name>
11.MANIPULATION Command :
It is used to manipulate the screen.
Syntax :
$tput <argument> Arguments :
1.Clear – to clear the screen.
2.Longname – Display the complete name of the terminal.
3.SMSO – background become white and foreground become black color. 4.rmso –
background become black and foreground becomes white color. 5.Cop R C – Move to
the cursor position to the specified location.
6.Cols – Display the number of columns in our terminals.
12.LIST Command :
It is used to list all the contents in the current working directory.
Syntax :
$ ls – options<arguments>
If the command does not contain any argument means it is working in the Current directory.
Options :
a– used to list all the files including the hidden files. c– list all the
files columnwise.
d- list all the directories.
m- list the files separated by commas.
p- list files include „/‟ to all the directories.
r- list the files in reverse alphabetical order.
f- list the files based on the list modification date. x-list in
column wise sorted order.
2.MKDIR Command :
To create or make a new directory in a current directory .
Syntax :
$mkdir<directory name>
3.CD Command :
To change or move the directory to the mentioned directory .
Syntax :
$cd <directory name>
43
FILE RELATED COMMANDS :
1.CREATE A FILE :
To create a new file in the current directory we use CAT command.
Syntax :
$cat ><filename
The > symbol is redirectory we use cat command.
2.DISPLAY A FILE :
To display the content of file mentioned we use CAT command without „>‟ operator.
Syntax :
$cat <filename.
Options –s = to neglect the warning /error message.
3.COPYING CONTENTS :
To copy the content of one file with another. If file doesnot exist, a new file is created and if the file exists
with some data then it is overwritten.
Syntax :
$ cat <filename source> >> <destination filename>
$ cat <source filename> >> <destination filename> it is avoid overwriting.
Options : -
-n content of file with numbers included with blank lines.
Syntax :
$cat –n <filename>
4.SORTING A FILE :
To sort the contents in alphabetical order in reverse order.
Syntax :
$sort <filename >
Option : $ sort –r <filename>
To copy the contents from source to destination file . so that both contents are same.
Syntax :
$cp <source filename> <destination filename>
$cp <source filename path > <destination filename path>
6.MOVE Command :
To completely move the contents from source file to destination file and to remove the source file.
Syntax :
$ mv <source filename> <destination filename>
7.REMOVE Command :
To permanently remove the file we use this command .
Syntax :
$rm <filename>
44
8.WORD Command :
To list the content count of no of lines , words, characters .
Syntax :
$wc<filename>
Options :
-c – to display no of characters.
-l – to display only the lines.
-w – to display the no of words.
9.LINE PRINTER :
To print the line through the printer, we use lp command.
Syntax :
$lp <filename>
10.PAGE Command :
This command is used to display the contents of the file page wise & next page can be viewed by pressing
the enter key.
Syntax :
$pg <filename>
45
Section IV: HTML
46
Assignment No 10: Introduction to HTML
HTML :
Hyper Text Markup Language is a simple markup language used to create platform-independent
hypertext documents on the World Wide Web.
Most hypertext documents on the web are written in HTML. HTML is the standard markup language for
creating Web pages.
HTML tags label pieces of content such as "heading", "paragraph", "table", and so on.
Browsers do not display the HTML tags, but use them to render the content of the page
<!DOCTYPE html>
<html>
<head>
<title> My First HTML Page</title>
</head>
<body>
Welcome to HTML
</body>
</html>
47
Explanation of example:
Web Browsers
The purpose of a web browser (Chrome, IE, Firefox, Safari) is to read HTML documents and display
them.
The browser does not display the HTML tags, but uses them to determine how to display the
document:
48
HTML Page Structure
HTML Headings
<h1> defines the most important heading. <h6> defines the least important heading:
<!DOCTYPE html>
<html>
<body>
</body>
</html>
49
50
Some HTML tags required to design simple web pages are given below
51
all the
2.behavior=scroll|slide way from one end to
| other
alternate </marquee>
- Specifies how the text
should behave.
-Scroll is the default
setting and means the
text should start
completely off one side,
scroll all the
way across and
completely off, then
start over again.
-Slide stops the scroll
when the text touches
the other margin.
- Alternate means
bounce back and forth
within the marquee.
3.bgcolor="#rrggbb" or
color name
<IMG> loads an inline image src= “ text” Provides the
URL
of the graphic file to be
displayed
alt="text" Provides
alternate
text if the image cannot
be
displayed.
height=number
Specifies the height of
the
image in pixels.
width=number
Specifies the width of
the
image in pixels.
52
Assignment
Set A:
2. Create an html page with all the different text styles (bold, italic and underlined) and its combinations
on separate lines. State style of each line in its text.
3. Create an html page containing the polynomial expression as follows:
A0+A1X+A2X2+A3X3
Set B:
1. Write a HTML script which will demonstrate all attributes of the text tag.
2. Write a HTML script that will use image as a background and move one image from top to bottom
another image from right to left, on screen.
Set C:
Create an html page with following specifications
a. Title should be about myCity
b. Place your City name at the top of the page in large text and in blue color
c. Add names of landmarks in your city each in a different color, style and typeface
d One of the landmark, your college name should be blinking
e. Add scrolling text with a message of your choice.
f . Add some image at the bottom
2. Create an html page with red background with a message “warning” in large size blinking.
Add scrolling text “read the message” below it.
Assignment Evaluation
Signature of Instructor
53
Assignment No. 11: Working with List and Hyperlink
In addition of basic tags HTML also supports some of the features that we will discuss in this
assignment.
1. List: Lists are a great way to provide information in a structured and easy to read format.
2. Bulleted List (Unordered List): An unordered list is a collection of related items that have
no special order or sequence.
54
Tags used to add Hyperlinks in html document are given in the following table.
Sr. Tag Description Attributes Example
No
1 <A></A> Adds an anchor or href= “url” <html><body>
hyperlink specifies the url of <a
the target page. href=”http://www.google.com”>Clic
k here to
search</a></body></html>
55
Assignment
Set A
1. Write the HTML code which generates the following output.
Coffee
Tea
Black Tea
Green Tea
1] Africa
2] China
Milk
2. Create an html5 page with which generates the following output.
o Cold Drinks
Juices
Lemon Water
Soda Water
o Hot Drinks
Tea
Coffee
o Milk
Set B
1. Create an HTML5 program for unordered list of flowers with its color in nested list.
Modify it to change the shape of the bullet, also reduce the size of bulleted items one
smaller than the heading.
2. Write a HTML script to display following screen
3. Write the HTML code for generating the form as shown below
City Gallery
London
Paris
Tokyo
Assignment Evaluation
Signature of Instructor
57
Assignment No. 12: Working with Table
Table: A table is a two dimensional matrix, consisting of rows and columns. HTML tables are
intended for displaying data in columns on a web page. Table contains information such as text,
images, forms, hyperlinks etc.
58
Example
<html>
<head>
<title> Example of Table</title>
</head>
<body>
<center>
<table border="1">
<caption>Student Information</caption>
<tr>
<th rowspan=2>Roll No. </th>
<th colspan=2>Student Name </th>
<th rowspan=2>City </th>
</tr>
<tr>
<th>First Name</th>
<th>Last Name</th>
</tr>
<tr>
<td>1 </td>
<td>Amruta </td>
<td>More </td>
<td>A'Nagar </td>
</tr>
</table>
</center>
</body>
</html>
59
Assignment
Set A
2 C programming 250 00
Set B
1. Create an html page to generate your class time table
2. Create an html page to generate Bus Schedule from Aurangabad to Pune and from Pune to
Kolhapur.
60
Set C
INDIA 1998 85
1999 90
2000 100
USA 1998 30
1999 35
2000 40
Assignment Evaluation
Signature of Instructor
61
Assignment No.13 Working with Frames
Frame: Using frames, one can divide the screen into multiple scrolling sections, each of which can
display a different web page into it. It allows multiple HTML documents to be seen concurrently
Inline Frame: It is a new frame tag introduced in HTML5. It is having same properties and
attribute options as in <FRAME> tag. An <iframe> tag is used to display a web page within a
web page. Inline frames can be included within the text block in HTML5 document.
Tags used to add frame and iframe in html document are given in the following table.
Sr. Tags Description Attributes Example
No
1. <frame> Splits the 1.rows=number <frameset rows = “10%,40%,*”>
</frame> webpage into Divides the browser
frames. screen into horizontal
section.
2.cols=number
Divides the browser
screen into vertical
section.
The number written in
the rows and cols
attribute can be given
as absolute number
value or an asterisk (*)
can be used to indicate
the remaining space.
2. <frameset> Defines a 1. name=text <html>
</frameset> single frame assigns name to a <frameset rows=”50%,*”>
in a frameset. frame <frameset cols=”50%,*”>
2. noresize- prevents <frame src=”welcome.html”
to resize the frame name=”frm1”>
3. src=url </frameset>
Specifies initial html <frame src=”menu.html”
file to be displayed as name=”mnu”>
home screen </frmeset>
4.bordercolor=”rrggbb” </html>
Specifies the border
color of the frame
62
Example:
<html>
<head>
<title> Frame </title>
</head>
<frameset cols="*,*,*">
<frame src="f1.html">
<frame src="f2.html">
<frame src="f3.html">
</frameset>
</html>
63
Assignment
Set A:
Page 1
Page 2
Page 3
Set B:
1. Create an html page with which generates the following output. Divide the frame into
different sections as shown below and add appropriate html files to each frame.
64
2. Write an html script to generate following output.
2 3 4
Set C
1. Write an html script to generate following output.
a. About Us
Image
b. Employees
c. Careers
Bat
Good Bye!!
Ball
Stumps
3. Create an html page with appropriate frames containing Heading and other Information.
Add an ordered list of your educational qualifications. For each course make a nested list
that contains, university or board name, the year and the percentage scored
Assignment Evaluation
Signature of Instructor
65
Assignment : 14 Working with Forms
HTML Forms:
HTML5 provides better & more extensive support for collecting user inputs through forms. A
form can be placed anywhere inside the body of an HTML document. You can have more than
one form in the document
Tags used to add input forms are given in the following table.
7. align=(“texttop/
absmiddle
/baseline/bottom”)
66
which 3.cols="(no. of cols.)"
the user
can select
one or more
items.
4. <textarea> used for 1.name=name of data <textarea rows=10
</textarea> multiline field columns=40>
text entry 2.size=#of items to display </textarea>
multiple allows multiple
selections
5 <option> indicates a 1.selected=default <select name=”age”
possible selection size=1>
item within 2.value="data submitted <option selected>21-30
a select if this option is <option>31-40
widget selected" </select>
Example:
<html>
<head>
<title> form tag </title>
</head>
<body>
<center>
<h3 align="center">To illustrate form based tags</h3> <hr color="red">
<form action="">
<p>This is a text box to enter any text.<input type="text" >
<p>This is a text box to enter password.<input type="password" >
<p>This is a text area to enter large text<textarea> </textarea>
<p>This is a button.<input type="button" Value="Click" >
<p><b><u>Radio Options</u></b><br>
<input type="radio" name="y" checked> yes
<input type="radio" name="n" > no </p>
<p><b><u>Checkbox Options</u></b><br>
Sunday<input type="checkbox" checked >
Monday<input type="checkbox" >
Tuesday<input type="checkbox" >
</p>
<p><b><u>Menu driven options </u></b>
<select name="cars">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="fiat">Fiat</option>
<option value="audi">Audi</option>
</select></p>
</form>
</center>
</body>
</html>
67
Output
68
Assignment
Set A:
1. Write an HTML code for creating a following form
2. Write an HTML code for creating Login Form. Login form contains Username,
Password, Confirm Password fields with Submit Button.
Set B:
1. Write an HTML code for creating a following form
Set C:
1. Write an HTML code for creating a form, which accepts the birth date from the user in a
textbox and displays the day of the week in a message box on the click of a button.
2. Design an html form to take the information of a article to be uploaded such as file path,
author name, type (technical, literary, general), subject topic ( to be selected from a list) etc.
One should provide button to Submit as well as Reset the form contents.
Assignment Evaluation
Signature of Instructor
69