Escolar Documentos
Profissional Documentos
Cultura Documentos
August 9 2016
2
USES OF C PROGRAMMING LANGUAGE:
The C programming language is used for developing system applications that forms a
major portion of operating systems such as Windows, UNIX and Linux. Below are some
examples of C being used.
Database systems
Graphics packages
Word processors
Spreadsheets
Operating system development
Compilers and Assemblers
Network drivers
Interpreters
WHICH LEVEL IS C LANGUAGE BELONGING TO?
1
High Level
High level languages
provide
almost
everything
that
the
programmer might need
to do as already built
into the language.
Examples:
Java, Python
4
Middle Level
Middle level languages dont
provide all the built-in
functions found in high level
languages, but provide all
building blocks that we need
to produce the result we
want.
C, C++
Low Level
Low
level
languages provides
nothing other than
access
to
the
machines
basic
instruction set.
Assembler
Object oriented
Non structure
for
programming
this
functions
language
N/A
systems
from
function to another
N/A
N/A
Bottom UP Approach
Examples:
BASIC, COBOL,
sharp)
FORTRAN
Modula-2
C Basic Program
2
We are going to learn a simple Hello World C program in this section. Also, all the
below topics are explained in this section which are the basics of a C program.
1. C basic program with output and explanation
2. Steps to write C programs and get the output
3. Creation, Compilation and Execution of a C program
How to install C compiler and IDE
4. Basic structure of a C program
1
Command
Explanation
#include <stdio.h>
int main()
/*_some_comments_*/
getch();
return 0;
8
2
C BASIC PROGRAM:
#include<stdio.h>
void main()
3
{
/* our first simple C basic program */
printf(Hello World);
getch();
return 0;
}
OUTPUT:
Hello World
3
Below are the steps to be followed for any C program to create and get the output.
This is common to all C program and there is no exception whether its a very small C
program or very large C program.
Create
Compile
Execute or Run
Get the Output
4
4.1
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
Please note that a C program maynt have all below mentioned sections
S.No
1
Sections
Description
Documentation
section
by
compiler
for
compilation
compilation.
Link Section
Definition Section In this section, variables are defined and values are
5
Global
declaration
section
Function
prototype
declaration
section
6
Main function
User defined
function section
Printf () and scanf() functions are inbuilt library functions in C which are
available in C library by default. These functions are declared and related macros
C PRINTF () FUNCTION:
printf() function is used to print the character, string, float, integer, octal and
integer variable.
Similarly %c is used to display character, %f for float variable, %s for string
Note:
6
C language is case sensitive. For example, printf() and scanf() are different from
Printf() and Scanf(). All characters in printf() and scanf() functions must be in
lower case.
C SCANF () FUNCTION:
Scanf() function is used to read character, string, numeric data from keyboard
Consider below example program where user enters a character. This value is
displayed.
EXAMPLE PROGRAM FOR PRINTF() AND SCANF() FUNCTIONS IN C:
#include <stdio.h>
void main()
{
char ch;
char str[100];
printf(Enter any character \n);
scanf(%c, &ch);
printf(Entered character is %c \n, ch);
printf(Enter any string ( upto 100 character ) \n);
scanf(%s, &str);
printf(Entered string is %s \n, str);
}
Output:
Enter any character
a
Entered character is a
Enter any string ( upto 100 character )
hai
Entered string is hai
The format specifier %d is used in scanf() statement. So that, the value entered is
ALGORITHM
8
Step 2:
Step 3:
Calculate x1 using x1 (b + d) / (2 x a)
Step 4:
Calculate x2 using x2 (b d) / (2 x a)
Step 5:
Print x1 and x2
FLOW CHART
A graphical representation of the sequence of operations in an information system
or program is called.
Information system flowcharts show how data flows from source documents
through the computer to final distribution to users. Program flowcharts show the
sequence of instructions in a single program or subroutine. Different symbols are
used to draw each type of flowchart.
A Flowchart
Symbol
Use in Flowchart
Oval
Denotes the beginning or end
of the program
Parallelogram
Rectangle
Denotes a process to be
carried out e.g. addition,
subtraction, division etc.
Denotes a decision (or
branch) to be made. The
program should continue
along one of two routes. (e.g.
IF/THEN/ELSE)
Diamond
Hybrid
Denotes an output operation
Flow line
11
2.
Now its time to write and run the program. Below i have explained simple steps
for both c and c++.
For C Program
1. Enter the command given below in terminal window to open text editor.
gedit prog.c
Here prog.c is the name of the program. After entering above code it will ask for
password.
2. Now write your program, for your convenience i have given an sample program
below, you can copy and paste it in gedit text editor.
#include<stdio.h>
int main()
{
printf(\n This is C Programming in Ubuntu);
return 0;
}
3. Now save and close the editor.
4. To compile the program enter the command given below in terminal window.
gcc prog.c -o prog
12
5.
If there will be no error in the program then nothing will be shown. And if error
occurs, it will be shown. In case you get an error you have to open the text editor
again by repeating step 1 and remove it and again save and close the editor.
Exercise -1 Basics
a) What is an OS Command, Familiarize of Editors vi, Emacs
13
Vi:
1.
Command mode:
The letters of the key word perform editing functions.
To enter command mode, press the escape & <ESC> key.
14
2.
Insert mode:
The letters you type form words and sentences.
Unlike, many word processors, vi start up in command mode.
1.
The command to quit out of vi is :q. Once in command mode, type colon, and 'q',
followed by return. If your file has been modified in any way, the editor will warn you
of this, and not let you quit. To ignore this message, the command to quit out of vi
without saving is :q!. This lets you exit vi without saving any of the changes.
The command to save the contents of the editor is :w. You can combine the above
command with the quit command, or :wq and return.
The easiest way to save your changes and exit out of vi is the ZZ command. When you
are in command mode, type ZZ and it will do the equivalent of :wq.
You can specify a different file name to save to by specifying the name after the :w. For
example, if you wanted to save the file you were working as another filename called
filename2, you would type :w filename2 and return.
Emacs:
Emacs is another editor available in UNIX.
Like vi, 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, unlessit includes a command
prefix.
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.
15
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
If the file named filename exists, then the first screen's worth of the file is
displayed; if it doesn't exist, a help message is displayed.
The easiest way to learn emacs is to start it up and go through the on-line tutorial.
To access the on-line tutorial, type ESC help-with-tutorial immediately after you
have started emacs.
The tutorial directs you further in learning the basic commands. One notational
point you should know is that the tutorial uses M- to mean ESC.
To give you a head start, the following table lists the basic commands you need to
know to use emacs to edit a file.
An asterisk (* or star) to the left of a command indicate it is one to learn
immediately.
b) Using commands like mkdir, ls, cp, mv, cat, pwd, and man.
MKDIR COMMAND:
MKDIR file name will create a new directory i.e. here file name directory is
created.
aiet@ubuntu:~$ mkdir file name
LS COMMAND:
LS command is most widely used command and it displays the context of
directory.
aiet@ubuntu:~$ ls
CP COMMAND:
CP command copies a file. if I want to copy a file named old file in a current
directory to a file named new file in a current directory.
16
OPERATION
Addition
Subtraction
Multiplication
Division
Modulus It
returns the
remainder after
17
EXAMPLE
10 + 2 = 12
10 2 = 8
10 * 2 = 20
10 / 2 = 5
10 % 2 = 0 (Here
remainder is zero). If it
is 10 % 3 then it will
the division
ALGORITHM:
Step: 1 Read the numbers first, second;
Step: 2 Calculate
add = first+second
subtract = first-second
multiply = first*second
divide = first/second
FLOWCHART:
18
be 1.
19
#include <stdio.h>
void main()
{
int first, second, add, subtract, multiply;
float divide;
printf("\n Enter two integers:");
scanf("%d%d", &first, &second);
add = first + second;
subtract = first - second;
multiply = first * second;
divide = first / second;
printf("Sum = %d\n",add);
printf("Difference = %d\n",subtract);
printf("Multiplication = %d\n",multiply);
printf("Division = %f\n",divide);
return 0;
}
OUTPUT:
aiet@ubuntu:~$ gcc add.c
aiet@ubuntu:~$ ./a.out
Enter two integers: 4
Sum = 9
Difference = -1
Multiplication = 20
Division = 0.00000
4. What is an Operator
Answer: An operator is a symbol that tells the compiler to perform specific
mathematical or logical functions.
The total distance travelled by vehicle int seconds is given by s = ut+1/2at2 where 'u'
and 'a' are the initial velocity (m/sec.) and acceleration (m/sec2).
ALGORITHM:
Step1: [declaring variables]
declaration of variables u, a, s, t
Step2: [reading variables]
read a, u, t
Step3: [calculating value of s]
s= (u*t)+(a*t*t)/2
Step4: [print the value of s]
print the distance is equal to: s
Step5: [end of program]
stop
FLOWCHART:
{
float u,a,s;
int t;
clrscr();
printf(" Enter the value of a: ");
scanf("%f",&a);
printf(" Enter the year of u: ");
scanf("%f",&u);
printf(" Enter the value of t: ");
scanf("%d",&t);
s = (u * t) + (a * t * t)/2;
printf("\n The distance equal to: %f",s);
getch();
}
OUTPUT:
aiet@ubuntu:~$ gcc motion.c
aiet@ubuntu:~$ ./a.out
Enter the value of a: 4
Enter the year of u: 5
Enter the value of t: 6
The distance equal to: 102.000000
F=9/5*c+32
Step: 3 Print the Celsius and Fahrenheit value.
Step: 4 Read the temperature in degree Fahrenheit.
Step: 5 Convert the Fahrenheit to Centigrade using the formula
C=5/9*(F-32)
Step: 5 Print the Fahrenheit and Celsius value.
Step: 6 Stop
FLOWCHART:
c,f;
24
clrscr();
printf("\n Enter the temperature in centigrade:");
scanf("%f",&c);
f=1.8*c+32;
printf("\n\t%f Centigrade=%f Fahrenheit",c,f);
printf("\n\n Enter the temperature in Fahrenheit:");
scanf("%f",&f);
c=(f-32)/1.8;
printf("\n\t%f Fahrenheit=%f Centigrade",f,c);
getch();
}
OUTPUT:
aiet@ubuntu:~$ gcc temperature.c
aiet@ubuntu:~$ ./a.out
Enter the temperature in centigrade: 45
45.00 Centigrade=113.00 Fahrenheit
Enter the temperature in Fahrenheit: 114
114.0
Fahrenheit=45.56 Centigrade
FLOWCHART:
27
void main()
{
int year;
clrscr();
printf("\n Enter any year: ");
scanf("%d",&year);
if(((year%4==0)&&(year%100!=0))||(year%400==0))
printf("%d is a leap year",year);
else
printf("%d is not a leap year",year);
getch();
}
OUTPUT:
aiet@ubuntu:~$ gcc leap.c
aiet@ubuntu:~$ ./a.out
Enter any year: 2015
Is not a leap year
FLOWCHART:
30
#include<conio.h>
void main()
{
int num,sum=0,r;
clrscr();
printf("\n Enter a number: ");
scanf("%d",&num);
while (num)
{
r=num%10;
num=num/10;
sum=sum+r;
}
printf("Sum of digits of number: %d",sum);
getch();
}
OUTPUT:
aiet@ubuntu:~$ gcc digit.c
aiet@ubuntu:~$ ./a.out
Enter a number: 123
Sum of digits of number: 6
FLOWCHART:
33
#include<conio.h>
void main()
{
int num,mul=1,r;
clrscr();
printf("\n Enter a number:");
scanf("%d",&num);
while (num)
{
r=num%10;
num=num/10;
mul=mul*r;
}
printf("multiplication of digits of number: %d",mul);
getch();
}
OUTPUT:
aiet@ubuntu:~$ gcc multiplication.c
aiet@ubuntu:~$ ./a.out
Enter a number:124
multiplication of digits of number: 8
Answer: getch() is used to hold the console window on the screen after the whole
program run is compileted.
36
DESCRIPTION:
This is a C code tutorial to check the input number is prime number or not by using
conditional if-else statement and display on the output screen.
PRIME NUMBER:
A prime number is a natural number greater than 1 that has no positive divisor other
than 1 and itself (or) we can say that prime number is divided without a reminder only
by itself and by 1. (i.e: 2, 3, 5, 7, 11, 13, 17.....etc.)
ALGORITHM:
Step1: [declaration of variables]
Declare variables n, i, c=0
Step2: [read n value]
read n
Step3: [repitition using loop]
for i=1 to n
Step4: [decision making loop]
if (n%i==0) then follow the steps otherwise go to step6
Step5: [increment c]
c++
Step6: [decision making loop]
if (c==2) then follow the steps otherwise go to step 8
Step7: [print about the number]
print n is a prime number
Step8: [decision making loop]
else
Step9: [print about the number]
print n is not a prime number
Step10: [end of program]
stop
FLOWCHART:
37
{
int n, i, c = 0;
clrscr();
printf("\n Enter any number n:");
scanf("%d", &n);
/*logic*/
for (i = 1; i <= n; i++)
{
if (n % i == 0)
{
c++;
}
}
if (c == 2)
{
printf("n is a Prime number");
}
else
{
printf("n is not a Prime number");
}
getch();
}
OUTPUT:
aiet@ubuntu:~$ gcc prime.c
aiet@ubuntu:~$ ./a.out
Enter any number n: 7
39
n is a Prime number
40
ARMSTRONG NUMBER:
Armstrong number is a special number whose sum of cube of its digits is equal to the
original number.
For example: 371 is an Armstrong number because 33 + 73 + 13 = 371 .
Example:
Input Numbers
Armstrong Number
34
32 + 42 = 25 34
No
153
13 + 53 + 33 = 153 = 153
Yes
1634
Yes
54748
55 + 45 + 75 + 45 + 85 = 54748 = 54748
Yes
ALGORITHM:
Step1: [declaration of variables]
declare number, original number, remainder,result=0
Step2: [read number]
read number
Step3: [storing the value of number in original number]
41
FLOWCHART:
42
void main()
{
int number, originalNumber, remainder, result = 0;
clrscr();
printf("\n Enter a three digit integer:");
scanf("%d", &number);
originalNumber = number;
while (originalNumber != 0)
{
remainder = originalNumber%10;
result += remainder*remainder*remainder;
originalNumber /= 10;
}
if(result == number)
printf("%d is an Armstrong number.",number);
else
printf("%d is not an Armstrong number.",number);
getch();
}
OUTPUT:
aiet@ubuntu:~$ gcc armstrong.c
aiet@ubuntu:~$ ./a.out
Enter a three digit integer: 371
371 is an Armstrong number.
b).Write a c program to print Floyd's triangle
DESCRIPTION:
Number of rows of Floyd's triangle to print is entered by the user.
44
FLOWCHART:
45
PROGRAM:
aiet@ubuntu:~$ gedit
floyd.c
#include <stdio.h>
void main()
{
int n, i, c, a = 1;
printf("Enter the
number of rows of
Floyd's triangle to print:
\n");
scanf("%d", &n);
for (i = 1; i <= n; i++)
{
for (c = 1; c <= i; c+
+)
{
printf("%d ",a);
a++;
}
printf("\n");
}
return 0;
}
OUTPUT:
aiet@ubuntu:~$ gcc floyd.c
aiet@ubuntu:~$ ./a.out
Enter the number of rows of Floyds triangle to print: 4
1
46
2 3
4 5
7 8
6
9
10
1
2
3
4
1
3
1
4
48
While(conditional-expression);
Exercise 5 Functions
1. Write a C program demonstrating of parameter passing in function and
return values.
DESCRIPTION:
Parameter Passing is a technique for communication of data (or) information between the
calling function and the called function. It can be achieved either by passing the value or
address of the variable.
There are two types of parameter passing techniques:
1. Call by value: It does not change the argument variable in the calling function,
even if they are changed in the called function.
2. Call by Address: C provides another means of passing values to a function
known as call by address.
PROGRAM: aiet@ubuntu:~$ gedit parameter.c
#include<stdio.h>
#include<conio.h>
#include<math.h>
int sum(int a,int b);
int main()
{
int a,b,c;
printf("\n enter the two numbers:");
scanf("%d%d",&a,&b);
c=sum(a,b);
printf("\n total=%d",c);
50
}
int sum(int a,int b)
{
int result;
result=a+b;
return result;
}
OUTPUT:
30
Total=50
51
b=nonrecfactorial(n);
printf("\n The factorial of given number using nonrecursion is:%d",b);
getch();
}
int recfactorial(int x)
{
int f;
if(x==0)
return 1;
else
{
f=x*recfactorial(x-1);
return f;
}
}
int nonrecfactorial(int x)
{
int i,f=1;
for(i=1;i<=x;i++)
{
f=f*i;
}
return f;
}
OUTPUT:
aiet@ubuntu:~$ gcc factorial.c
aiet@ubuntu:~$ ./a.out
Enter the number:6
The factorial of given number using recursion is:720
The factorial of given number using nonrecursion is:720
53
13
21
..
The recursive definition for the Fibonacci sequence of integers may be defined as
follows:
fib(n)=n; if n=0 or n=1
fib(n)=fib(n-1)+fib(n-2); for n>=2
#include<stdio.h>
#include<conio.h>
void main()
{
int i,n;
int recfib(int);
void nonrecfib(int);
clrscr();
printf("\n Enter the numbers:");
scanf("%d",&n);
printf("\n The Fibonacci series using recursion is:");
for(i=0;i<n;i++)
printf("%d\t",recfib(i));
printf("\n The Fibonacci series without using recursion is:");
nonrecfib(n);
}
int recfib(int x)
{
if(x==0)
return 0;
else if(x==1)
return 1;
else
return recfib(x-1)+recfib(x-2);
}
void nonrecfib(int c)
{
int a=0,b=1,d,i;
printf("\n%d\t%d",a,b);
55
for(i=3;i<=c;i++)
{
d=a+b;
printf("\t%d",d);
a=b;
b=d;
}
}
OUTPUT:
aiet@ubuntu:~$ gcc fibonacci.c
aiet@ubuntu:~$ ./a.out
Enter the numbers: 8
The Fibonacci series using recursion is: 0
13
56
1. What is Recursion?
Answer: Recursion function is a function that calls itself directly or indirectly.
2. What is a Function?
Answer: It contains the block of code to perform a specific task i.e. in this case,
adding two numbers and returning it.
3. Define Call by Value?
Answer: Call by value mechanism does not change the contents of the argument
variable in the calling function.
4. Define Call by Reference?
Answer: The address of the argument is copied into a memory location instead of
the values.
5. Write Syntax for DO- WHILE Statement?
Answer: do
{
Statement-block;
}
While (conditional-expression);
6. What is Loop Control Statements?
Answer: for, while, do while
Exercise 6 Functions
1. Write a C Program to make a simple Calculator to Add, Subtract, Multiply
or Divide Using switchcase.
DESCRIPTION:
57
Switch Statement:
We want to check more possible condition for a single variable, a number of statements
are necessary.
Example: To check the category of Employee.
if (category = = 1)
printf (\n principal);
if (category = = 2)
printf (\n professor);
.
.
.
if (category = = 7)
printf (\n non-teaching staff);
Is there any chance to reduce the repeated usage of if statement? Yes, we have the switch
case statement to check multiple conditions at a time, which reduces the number of
repetitions of the statement.
Syntax of the switch statement:
Switch (expression)
{
case value -1: Statement-1;
case value -2: Statement-2;
case value -3: Statement-3;
[default: statement n;]
}
{
int n1, n2, ch;
clrscr();
printf("\n Enter the first number:");
scanf("%d", &n1);
printf("\n Enter the second number:");
scanf("%d", &n2);
printf("\n [1] -> Addition ");
printf("\n [2] -> Subtraction ");
printf("\n [3] -> Multiplication ");
printf("\n [4] -> Division ");
printf("\n\n Enter your choice <1...4>:");
scanf("%d", &ch);
switch(ch)
{
case 1 :
printf("\n %d + %d = %d", n1, n2, n1 + n2) ;
break ;
case 2 :
printf("\n %d - %d = %d", n1, n2, n1 - n2) ;
break ;
case 3 :
printf("\n %d * %d = %d", n1, n2, n1 * n2);
break ;
case 4 :
printf("\n %d / %d = %.2f", n1, n2, (float)n1 / n2);
break ;
default :
printf("\n Invalid choice");
break ;
}
getch();
59
}
OUTPUT:
aiet@ubuntu:~$ gcc calculator.c
aiet@ubuntu:~$ ./a.out
Enter the first number: 3
Enter the second number: 6
[1] Addition
[2] Subtraction
[3] Multiplication
[4] Division
Enter your choice <14> : 1
3+6 = 9
FLOWCHART:
62
#include<stdio.h>
#include<conio.h>
#include<math.h>
void dec_bin(long int num) // Function Definition
{
long int rem[50],i=0,length=0;
while(num>0)
{
rem[i]=num%2;
num=num/2;
i++;
length++;
}
printf("\n Binary number:");
for(i=length-1;i>=0;i--)
printf("%ld",rem[i]);
}
//=============================
void main()
{
long int num;
clrscr();
printf("\n Enter the decimal number:");
scanf("%ld",&num);
dec_bin(num); // Calling function
getch();
}
OUTPUT:
aiet@ubuntu:~$ gcc binary.c
64
aiet@ubuntu:~$ ./a.out
Enter the decimal number: 7
Binary number: 111
65
Hexadecimal Number System: It is base 16 number system which uses the digits from 0
to 9 and A, B, C, D, E, F.
Decimal Number System: It is base 10 number system which uses the digits from 0 to 9
Decimal to Hexadecimal conversion Example:
For example we want to convert decimal number 900 in the hexadecimal.
Step 1: 900 / 16 Remainder: 4, Quotient: 56
Step 2: 56 / 16 Remainder: 8, Quotient: 3
Step 3:
3 / 16 Remainder: 3, Quotient: 0
FLOWCHART:
67
#include<stdio.h>
#include<conio.h>
#include<math.h>
void dec_hex(long int num) // Function Definition
{
long int rem[50],i=0,length=0;
while(num>0)
{
rem[i]=num%16;
num=num/16;
i++;
length++;
}
printf("\n Hexadecimal number:");
for(i=length-1;i>=0;i--)
{
switch(rem[i])
{
case 1:
printf("A");
break;
case 2:
printf("B");
break;
case 3:
printf("C");
break;
case 4:
printf("D");
break;
69
case 5:
printf("E");
break;
case 6:
printf("F");
break;
default :
printf("%ld",rem[i]);
}
}
}
//========================
void main()
{
long int num;
clrscr();
printf("\n Enter the decimal number:");
scanf("%ld",&num);
dec_hex(num); // Calling function
getch();
}
OUTPUT:
aiet@ubuntu:~$ gcc hexadecimal.c
aiet@ubuntu:~$ ./a.out
Enter the decimal number: 7894
Hexadecimal number: A1413F
VIVA QUESTION AND ANSWERS
1. Write the Syntax for Switch Case Statement?
70
[ d ]
Exercise 7 Functions
1. Write a C program to compute the values of sin x and cos x and e^x values
using series expansion (use factorial function).
PROGRAM: aiet@ubuntu:~$ gedit series.c
71
#include<stdio.h>
#include<math.h>
#define PI 3.1415
float exp_x( int, int );
double sin_x( int, int );
double cos_x( int, int );
int fact( int );
int main()
{
int choice, x, n;
do
{
printf( "\n Menu\n[1] e^x)\n[2] Sin(x)\n[3] Cos(x)\n[4] Exit\n" );
scanf( "%d", &choice );
switch ( choice )
{
case 1: // to find exponential value
printf( "e^x\nEnter x and n:\t" );
scanf( "%d %d", &x, &n );
printf( "e^%d(%d) = %f\n", x, n, exp_x( x, n ) );
break;
case 2: // to find sinx
printf( "sin(x)\nEnter x and n:\t" );
scanf( "%d %d", &x, &n );
printf( "\n sin(%d)(%d) = %f\n", x, n, sin_x( x, n ) );
break;
case 3: // to find cosx
printf( "cos(x)\nEnter x and n:\t" );
scanf( "%d %d", &x, &n );
printf( "\n cos(%d)(%d) = %f\n", x, n, cos_x( x, n ) );
72
break;
case 4: // exit
break;
default: // wrong choice
printf( "Wrong choice" );
break;
}
}
while ( choice != 4 );
}
float exp_x( int x, int n )
{
int i = 1;
float ex = 1;
while ( i < n )
{
ex += ( float ) pow( x, i ) / fact( i );
++i;
}
return ex;
}
double sin_x( int ang_deg, int no_of_terms )
{
int term, j;
double value = 0.0, ang_rad = 0.0;
ang_rad = ( double ) ang_deg * PI / 180;
for ( term = 1, j = 2;term < no_of_terms*2;term += 2, j++ )
{
value += ( double ) pow( -1.0, j ) * pow( ang_rad, term ) / fact( term );
}
return value;
73
}
double cos_x( int ang_deg, int no_of_terms )
{
int term, j;
double value = 1.0, ang_rad = 0.0;
ang_rad = ( double ) ang_deg * PI / 180;
for ( term = 2, j = 1;term <= no_of_terms;term += 2, j++ )
{
value += ( double ) pow( -1.0, j ) * pow( ang_rad, term ) / fact( term );
}
return value;
}
int fact( int num )
{
int f = 0;
if ( num == 1 )
return 1;
else
f = num * fact( num - 1 );
return f;
}
OUTPUT:
aiet@ubuntu:~$ gcc series.c
aiet@ubuntu:~$ ./a.out
Menu
[1] e^x)
[2] Sin(x)
[3] Cos(x)
74
[4] Exit
1
e^x
Enter x and n: 2 3
e^2(3) = 5.000000
Menu
[1] e^x)
[2] Sin(x)
[3] Cos(x)
[4] Exit
2
Sin(x)
Enter x and n: 90
2
Sin(90)(2) = 0.924843
Menu
[1] e^x)
[2] Sin(x)
[3] Cos(x)
[4] Exit
3
Cos(x)
Enter x and n: 90
1
Cos(90)(1) = 1.000000
Menu
[1] e^x)
[2] Sin(x)
[3] Cos(x)
[4] Exit
4
75
d) What is a compiler?
Answer: A compiler is system software which converts programming language
code into binary format in single steps.
Exercise 8 Arrays
Demonstration of arrays:
C Array is a collection of variables belongings to the same data type. You can store group
of data of same data type in an array.
Always, Contiguous (adjacent) memory locations are used to store array elements
in memory.
It is a best practice to initialize an array to zero or null while declaring, if we dont
assign any values to array.
int a[10];
// integer array
char b[10]; // character array i.e. string
Here 10 means size of the array.
TYPES OF C ARRAYS:
There are 2 types of C arrays. They are,
1. One dimensional array
2. Multi dimensional array
77
Example
Integer array example:
int age [5];
int age[5]={0, 1, 2, 3, 4};
age[0]; /*0 is accessed*/
age[1]; /*1 is accessed*/
age[2]; /*2 is accessed*/
Example
Integer array example:
int arr[2][2];
INTRODUCTION TO SORTING:
Sorting is nothing but storage of data in sorted order, it can be in ascending or descending
order. The term Sorting comes into picture with the term Searching. There are so many
things in our real life that we need to search, like a particular record in database, roll
numbers in merit list, a particular telephone number, any particular page in a book etc.
Sorting arranges data in a sequence which makes searching easier. Every record which is
going to be sorted will contain one key. Based on the key the record will be sorted. For
example, suppose we have a record of students, every such record will have the following
data:
80
Roll No.
Name
Age
Class
Here Student roll no. can be taken as key for sorting the records in ascending or
descending order. Now suppose we have to search a Student with roll no. 15, we don't
need to search the complete record we will simply search between the Students with roll
no. 10 to 20.
Sorting Efficiency:
There are many techniques for sorting. Implementation of particular sorting technique
depends upon situation. Sorting techniques mainly depends on two parameters. First
parameter is the execution time of program, which means time taken for execution of
program. Second is the space, which means space taken by the program.
4. Quick Sort
5. Merge Sort
6. Heap Sort
return (0);
OUTPUT :
aiet@ubuntu:~$ gcc linear.c
aiet@ubuntu:~$ ./a.out
Enter no.of elements: 5
Enter the values: 9
5
3
4
7
Enter the elements to be searched: 4
Number found at the location = 4
84
85
bubble_sort(arr, num);
getch();
}
void bubble_sort(int iarr[], int num)
{
int i, j, k, temp;
printf("\n Unsorted Data:");
for (k = 0; k < num; k++)
{
printf("%5d", iarr[k]);
}
for (i = 1; i < num; i++)
{
for (j = 0; j < num - 1; j++)
{
if (iarr[j] > iarr[j + 1])
{
temp = iarr[j];
iarr[j] = iarr[j + 1];
iarr[j + 1] = temp;
}
}
printf("\nAfter pass %d : ", i);
for (k = 0; k < num; k++)
{
printf("%5d", iarr[k]);
}
}
}
OUTPUT:
aiet@ubuntu:~$ gcc bubble.c
aiet@ubuntu:~$ ./a.out
Enter no of elements: 5
Enter array elements: 10
55
21
Unsorted Data:
10
55
21
After pass 1:
10
21
55
87
After pass 2:
10
21
55
After pass 3:
10
21
55
After pass 4:
10
21
55
88
In the first pass, the smallest element found is 1, so it is placed at the first position, then
leaving first element, smallest element is searched from the rest of the elements, 3 is the
smallest, so it is then placed at the second position. Then we leave 1 nad 3, from the rest
of the elements, we search for the smallest and put it at third position and keep doing this,
until array is sorted.
{
scanf("%d",&array[i]);
}
//calling selectionSort function defined above and gettting
//sorted array in sortArray variable
int *sortArray = selectionSort(array,n);
//print sorted array
printf("Sorted list:");
for(i = 0; i < n; i++ )
{
printf("%d\t",sortArray[i]);
}
}
OUTPUT:
aiet@ubuntu:~$ gcc selection.c
aiet@ubuntu:~$ ./a.out
How many elements you want to sort: 6
Enter the values one by one:
Enter element 1: 6
Enter element 2: 8
Enter element 3: 9
Enter element 4: 1
Enter element 5: 5
Array before sorting:
91
scanf("%d", &row2);
printf("\n Enter the number of Columns of Mat2:");
scanf("%d", &col2);
/* Before accepting the Elements Check if no of
rows and columns of both matrices is equal */
if (row1 != row2 || col1 != col2)
{
printf("\n Order of two matrices is not same");
exit(0);
}
//Accept the Elements in Matrix 1
for (i = 0; i < row1; i++)
{
for (j = 0; j < col1; j++)
{
printf("Enter the Element a[%d][%d] : ", i, j);
scanf("%d", &mat1[i][j]);
}
}
//Accept the Elements in Matrix 2
for (i = 0; i < row2; i++)
for (j = 0; j < col2; j++)
{
printf("Enter the Element b[%d][%d] : ", i, j);
scanf("%d", &mat2[i][j]);
}
//Addition of two matrices
93
10
11
95
(b). iostream.h
(c). stdio.h
[a]
(d). conio.h
2. # include is a directive
(a). compiler (b). processor
[d]
(c). Pre-compiler (d). Pre-processor
Exercise 9 Structures
1. Write a C Program to Store Information of a Movie Using Structure
PROGRAM: aiet@ubuntu:~$ gedit movie.c
#include<stdio.h>
#include<conio.h>
struct movie
{
char title[100];
int year;
char directorname[100];
char actor[500];
};
void main()
97
{
struct movie movie;
clrscr();
printf("\n Enter title:");
gets(movie.title);
printf("\n Enter year:");
scanf("%d",&movie.year);
printf("\n Enter directorname:");
scanf("%s",&movie.directorname);
printf("\n Enter actor:");
scanf("%s",&movie.actor);
printf(\n\n\n);
printf("Name of the movie: %s \n",movie.title);
printf("year of the movie: %d \n",movie.year);
printf("directorname of the movie: %s \n",movie.directorname);
printf("actor of the movie: %s \n",movie.actor);
getch();
}
OUTPUT:
aiet@ubuntu:~$ gcc movie.c
aiet@ubuntu:~$ ./a.out
Enter title: A Aa
Enter year: 2016
Enter director name: trivikram
Enter actor: Samantha
Name of the movie: A Aa
Year of the movie: 2016
Directorname of the movie: trivikram
Actor of the movie: samantha
98
OUTPUT:
aiet@ubuntu:~$ gcc memory.c
aiet@ubuntu:~$ ./a.out
Enter number of records: 2
Enter name of the subject and marks respectively:
Programming
22
Enter name of the subject and marks respectively:
Structure
33
Displaying Information:
Programming
Structure
22
33
100
102
4. Which of the following operator is used to open the contents of all structure
elements of different data type to another structure variable of its type [ c ]
(a). ->
(b). &
(c). =
(d). *
error.
3
5
4
You entered:
1
2
3
5
2. Write a C Program to find the sum of numbers with arrays and pointers.
PROGRAM: aiet@ubuntu:~$ gedit pointer.c
#include<stdio.h>
#include<conio.h>
void main()
{
int numArray[10];
int i, sum=0;
int *ptr;
printf("\n Enter 10 elements:");
for(i=0;i<10;i++)
scanf("%d",&numArray[i]);
ptr=numArray;
for(i=0;i<10;i++)
{
sum=sum+*ptr;
ptr++;
}
printf("\n The sum of array elements:%d",sum);
}
OUTPUT:
105
13
14
15
16
17
18
19
20
OUTPUT:
aiet@ubuntu:~$ gcc dynamic.c
aiet@ubuntu:~$ ./a.out
Enter number of elements:5
Enter elements of array:3
7
9
2
4
Sum= 25
107
108
OUTPUT:
aiet@ubuntu:~$ gcc allocate.c
aiet@ubuntu:~$ ./a.out
109
(b). *
(c). #
[b]
(d). &
3. Define String?
Answer: A string is a collection of characters that are enclosed within double
quotes ( ).
4. Malloc( ) allocates bytes of memory.
110
Exercise 12 Strings
1. Implementation of string manipulation operations with library function.
i. Copy
ii. Concatenate
iii.
Length
iv. Compare
PROGRAM: aiet@ubuntu:~$ gedit with.c
#include<stdio.h>
#include<conio.h>
#include<string.h>
int main()
{
char str[20],str1[20];
int ch,i,j;
clrscr();
do
{
printf("\n****MENU****");
printf("\n1:Find Length");
printf("\n2:Copy the Strings");
printf("\n3:Compare the Strings");
printf("\n4:Concatenate the Strings");
printf("\n5:Exit");
printf("\n Enter your choice:");
scanf("%d",&ch);
switch(ch)
{
case 1:
printf("\n Enter the string: ");
scanf("%s",&str);
i=strlen(str);
printf("\n The Length of given string is: %d",i);
break;
case 2:
111
112
OUTPUT:
aiet@ubuntu:~$ gcc with.c
aiet@ubuntu:~$ ./a.out
****MENU****
1:Find Length
2:Copy the Strings
3:Compare the Strings
4:Concatenate the Strings
5:Exit
Enter your choice: 1
Enter the string: VINIT
The Length of given string is: 5
****MENU****
1:Find Length
2:Copy the Strings
3:Compare the Strings
4:Concatenate the Strings
5:Exit
Enter your choice: 2
Enter the first string: VINIT
Enter the second string: JAIN
The Copied string is: JAIN
****MENU****
1:Find Length
2:Copy the Strings
3:Compare the Strings
4:Concatenate the Strings
5:Exit
Enter your choice: 3
Enter the first string: VINIT
113
114
if(len1!=len2)
return 1;
for(i = 0; i < len1; i++)
{
if(string1[i] == string2[i])
count++;
}
if(count == len1)
return 0;
return 1;
}
void copy_string(char destination[], char source[])
{
int len,i;
len = find_length(source);
for(i = 0; i < len; i++)
{
destination[i] = source[i];
}
destination[i] = '\0';
}
int main()
{
char string1[20], string2[20]; //string variables declaration with size 20
int choice;
while(1)
{
printf("\n1. Find Length \n2. Concatenate \n3. Compare \n4. Copy \n5. Exit\n");
printf("Enter your choice: ");
scanf("%d",&choice);
switch(choice)
{
case 1:
printf("Enter the string: ");
scanf("%s",string1);
printf("The length of string is %d", find_length(string1));
break;
116
case 2:
printf("Enter two strings: ");
scanf("%s%s",string1,string2);
join_strings(string1,string2);
printf("The concatenated string is %s", string1);
break;
case 3:
printf("Enter two strings: ");
scanf("%s%s",string1,string2);
if(compare_strings(string1,string2)==0)
{
printf("They are equal");
}
else
{
printf("They are not equal");
}
break;
case 4:
printf("Enter a string: ");
scanf("%s",string1);
printf("String1 = %s\n");
printf("After copying string1 to string 2\n");
copy_string(string2,string1);
printf("String2 = %s",string2);
break;
case 5:
exit(0);
}
}
return 0;
}
117
OUTPUT:
aiet@ubuntu:~$ gcc without.c
aiet@ubuntu:~$ ./a.out
1. Find Length
2. Concatenate
3. Compare
4. Copy
5. Exit
Enter your choice: 1
Enter the string: siddhu
The length of string is 6
1. Find Length
2. Concatenate
3. Compare
4. Copy
5. Exit
Enter your choice: 2
Enter two strings: venkata bhavani
The concatenated string is venkatabhavani
1. Find Length
2. Concatenate
3. Compare
4. Copy
5. Exit
Enter your choice: 3
Enter two strings: venkata prasad
They are not equal
1. Find Length
2. Concatenate
3. Compare
4. Copy
5. Exit
Enter your choice: 3
Enter two strings: venkata venkata
They are equal
1. Find Length
2. Concatenate
3. Compare
4. Copy
118
5. Exit
Enter your choice: 4
Enter a string: prasad
String1 = prasad
After copying string1 to string 2
String2 = Prasad
1. Find Length
2. Concatenate
3. Compare
4. Copy
5. Exit
Enter your choice:5
3. A string is an array of
(a). integers
[c]
(c). characters
(b). %s
(c). %c
(b). strrsa( )
[c]
(c). strrev( )
(d). strcmp( )
[b]
(d). %f
[b]
(b). Concatenation
(c). Joining
(d). Addition
#include<conio.h>
#include<stdlib.h>
void main()
{
FILE *fp1, *fp2;
char ch;
clrscr();
fp1 = fopen("Sample.txt", "r");
fp2 = fopen("Output1.txt", "w");
while (1)
{
ch = fgetc(fp1);
if (ch == EOF)
break;
else
putc(ch, fp2);
}
printf("File copied Successfully!");
fclose(fp1);
fclose(fp2);
}
OUTPUT:
aiet@ubuntu:~$ gcc copy.c
aiet@ubuntu:~$ ./a.out
File copied successfully.
Exercise - 14 Files
1. Write a C program merges two files and stores their contents in another file.
PROGRAM: aiet@ubuntu:~$ gedit merge.c
122
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
main()
{
FILE *fs1, *fs2, *ft;
char ch, file1[20], file2[20], file3[20];
printf("\n Enter name of first file: ");
gets(file1);
printf("\n Enter name of second file: ");
gets(file2);
printf("\n Enter name of file which will store contents of two files: ");
gets(file3);
fs1 = fopen(file1,"r");
fs2 = fopen(file2,"r");
if( fs1 == NULL || fs2 == NULL )
{
perror("Error ");
printf("Press any key to exit...\n");
getch();
exit(EXIT_FAILURE);
}
ft = fopen(file3,"w");
if( ft == NULL )
{
perror("Error ");
printf("Press any key to exit...\n");
exit(EXIT_FAILURE);
}
while( ( ch = fgetc(fs1) ) != EOF )
fputc(ch,ft);
123
OUTPUT:
aiet@ubuntu:~$ gcc merge.c
aiet@ubuntu:~$ ./a.out
Enter name of first file: 222.c
Enter name of second file: copy1.c
Enter name of file which will store contents of two files: output.txt
Two files were merged into output.txt file successfully.
int status;
char file_name[25];
printf("Enter the name of file you wish to delete\n");
gets(file_name);
status = remove(file_name);
if( status == 0 )
printf("%s file deleted successfully.\n",file_name);
else
{
printf("Unable to delete the file\n");
perror("Error");
}
return 0;
}
OUTPUT:
aiet@ubuntu:~$ gcc delete.c
aiet@ubuntu:~$ ./a.out
Enter the name of file you wish to delete:
111.c
111.c file deleted successfully.
3. Which of the following function is used for storing information in a disk file [ d ]
(a). scanf( )
(b). fscanf( )
(c). printf( )
(d). fprintf( )
4. The C library that contains the prototype statement for the file operation is
(a). proto.h
(b). file.h
(c). stdio.h
[b]
(d). stdlib.h
Exercise 15
1) System Assembling, Disassembling and identification of Parts / Peripherals.
Steps for Assembling:
Insert the preprocessor into the slot provided such that the corner with no pin
coincide with corner without pinhole on motherboard.
Apply the appropriate adhesive on the processor for fixing the processor fan.
Fix the processor fan on the processor and use clips on it to keep it firm.
Insert the RAM card into the slots provided on the motherboard.
Fix the hard disc drive in the space provided in the PC cabinet using screws
provided.
Fix the FDD in the space provided in the PC cabinet using screws provided.
Fix the CD-ROM in the space provided in the PC cabinet using screws provided.
Connect power supply to the HDD, FDD, CD-ROM drive using the cables from
the SMPS.
Connect the network interface and other cards to motherboard by inserting in right
slots and fix them in cabinet using the screws provided.
127
6.
CPU socket.
7. Floppy.
8. System memory.
9. Chipset south bridge.
10. Panel connector.
11. Power supply.
12. IDE connectors.
ATX Connectors:
1. PS, Mouse.
2. Key board.
3. USB.
4. Parallel ( Prints )
5. Serial COM1.
6. Serial COM 2.
7. Joystick.
8. Sound.
Fitting the processor:
1. Raise the small lever at the side of the socket.
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.
Install the heat sink over it (Different type for each processor). Heat sink /
CPU fan.
SD RAM.
DDR SD RAM.
RD RAM.
3. The mother boards chipset determines which type of RAM may be used.
Installing the PCI Cards:
1. Most of the cards are inbuilt these days.
2. NIL, Sound Cards etc. are fitted into PCI slots.
Fitting the hard disk and Floppy disk:
1. Place the floppy and hard disks in their slots.
2. Leave some space above HDD to prevent heat building.
3. Check the jumper configuration.
4. Fix the screws.
Installing the CD-ROM Drives:
1. CD-ROM drive is similar to installing a hard disk.
2. 1st check that the jumper configuration is correct.
3. Fix the screw.
Connecting the ribbon Cables:
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.
3. PWR, PW, PWSW, PS or power SW: Power switch, the pcs 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. Its 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?
Disconnect the NIC and other cards from mother board by removing from slots
and unscrewing from cabinet.
Remove power supply cables from HDD, FDD, CD-ROM drive etc.
Disconnect the HDD, FDD, CD-ROM drive from mother board by removing flat
ribbon cable.
4) COMPUTER stands for: common operation machine particular used for trade
education research.
3. CPU
4. Memory (RAM), (ROM)
5. Power supply
6. Hard drive
7. CD or DVD drive
8. I/O Slots
9. Network Ports
10. Floppy drive
11. Monitor
12. Keyboard
13. Mouse
PC Overview
Personal Computer (PC) - A small, single-user computer based on a microprocessor as it's
central "brain". In addition to the microprocessor,
a mouse for selecting items that show up on the monitor, and a storage device for
saving data.
135
INPUT UNIT:
The process of sending the data and instructions for the processing through some suitable
devices such as Keyboard, Mouse, Scanner, Barcode reader and Digital Camera etc. is
called input. The devices translate the data from human understandable from into
electronic impulses which are understood by the computer.
1. Memory Unit:
136
This holds the data in terms of program and files. The data stored can be accessed
and used whenever required by the CPU for necessary processing. This memory
unit is usually refereed as primary storage section. The units in which memory
unit is measured are known as BYTES.
BYTE is the space required to store 8 characters or alphabet or digits to any other
special character.
2. Control Unit:
This unit which coordinates all the activities of each and every element of
computer. It decodes the instructions given by various users and it seeds
commands and signals that determine the sequence of various instructions.
Through this unit does not process data but it acts as the central system for data
manipulation, as it controls the flow of data to and from the main storage.
3. Arithmetic and Logic Unit:
This unit performs arithmetic operations such as addition, subtraction,
multiplication and division. It also does Logical Operations such as comparison of
numbers etc. Thus this unit helps by processing data and taking logical decisions.
OUTPUT UNIT:
The processing of extracting the data from CPU through some suitable devices is
called Output. The common used output devices are Speakers, Monitors, Printers,
and Projectors etc.
137
138
2. What is a Motherboard
c) Sound card
d) Hard disk controller
e) Memory (RAM)
f) External peripheral devices.
Some motherboards support AMD CPUs, while others support Intel processors.
Within the manufacturer's categories.
There are different grades of CPUs. An AMD 64-bit processor requires a different
CPU socket than an AMD 32-bit processor.
Today most motherboards are color-coded with controllers built-in, making it very
easy to build a computer from scratch.
Most motherboard today was designed for IBM compatible computers which hold
over 96% of the computers in the market today.
3. What is CPU
4. What is Memory
The term memory identifies data storage that comes in the form of chips,
and the word storage is used for memory that exists on tapes or disks.
The term memory is usually used as shorthand for physical memory, which
refers to the actual chips capable of holding data.
Some computers also use virtual memory, which expands physical memory
onto a hard disk.
PRIMARY MEMORY
RAM
SECONDARY MEMORY
ROM
HARD DISK
DRIVE
FLOPPY
DRIVE
CD/DVD
DRIVE
a) PRIMARY MEMORY:
i.
This is the same as main memory. When used by itself, the term
RAM refers to read and write memory.
You can both write data into RAM and read data from RAM.
This is in contrast to ROM which permits you only to read data.
Most RAM is tempary (volatile) storage device.
As soon as the power is turned off, whatever data was in RAM is
lost.
There are three types of RAMs
a) SD-RAM (synchronous dynamic random access memory)
b) RD-RAM (rambus dynamic random access memory)
c) DDR (double data rate (or) dual data rate random access
memory)
141
ii.
ROM:
ROM stands for Read Only Memory.
The CPU can only fetch or read instructions
from Read Only Memory (or) ROM.
142
ROM comes with instructions permanently stored inside and these instructions
cannot be over-written by the computers CPU.
ROM memory is used for storing special sets of instructions which the computer
needs when it starts up.
When we switch the computer off, the contents of the ROM does not become
erased but remains stored permanently.
Therefore it is non-volatile.
The following is a diagram showing the relationship between the Central
Processing Unit and Main Memory (RAM and ROM).
b) SECONDARY MEMORY:
i.
It as 6 or 8 pins.
We can insert 4 SATA hard disk in computer
depends upon the capacity.
Speed of this hard disk 8,300 Rpm.
Speed of data reading 53Mb/sec.
Hard disk cable Red wire and power supply cable
Red should be co inside.
144
DVD-ROM has data which can only be read but cannot be written
over. It has the same size and form with CD-ROM
CD
DVD
Voltage:
Red
: +5 volts
Yellow
: +12 volts
Blue
: -12 volts
White
: -5 volts
Black
: 0 volts
146
Orange
8. What is Monitor
Connects to the computer via the video card.
The Computer Monitor is the computer user's window into the workings
of the computer.
It consists of a television picture tube that had been modified to accept the
type of video signal created by the computer's electronics.
Conventional televisions can be used as computer monitors if a translation
device is used to connect them.
The picture quality leaves something to be desired.
There are two types of Monitors:
a) Cathode Ray Tube (CRT):
Cathode-ray tube (CRT) monitor is the most common
monitor type.
Most televisions also use this technology.
148
149
KEYBOARD
PS/2
USB
MOUSE
PS/2
I/O PORTS:
150
USB
POST:
151
ABBREVATIONS
CPU
ALU
AMD
ZIF
I \ O Slots
ISA
SIS
PCI
AGP
MCA
EISA
VESA
RAM
ROM
S-RAM
: Static Ram
D-RAM
: Dynamic Ram
SIMM
DIMM
SD-RAM
DDR-RAM
RD-RAM
BIOS
CMOS
IDE
SCSI
MOSFET
RPM
SMPS
AT
: Advanced Technology
ATX
POST
: Power On Self-Test
OPERATING SYSTEM
Definition: It is interface between user and hard ware is called the operating system.
There are three types of operating system.
Single user single Task ----- MS-Dos
Single user Multi Task ----- Windows
Multi user Multi Task
User interface:
155
Application management:
Open Graphics Library (OpenGL) DirectX
Graphical User Interface (GUI): The user interacts with menus and icons.
Shares peripherals.
Used on a network.
156
7. After reading the License Agreement, press F8 to accept it and continue the
installation.
8. You will now see a list of the partitions on your hard drives. Use the cursor keys
to select an item not labeled as un-partitioned space.
158
9. Press the D key to delete the selected partition. If you receive the following
prompt, press Enter to continue. Otherwise, proceed to the next step.
160
161
162
19. Once all necessary files have been copied, the system
will be automatically restarted. You may now remove
the CD. If you choose to leave the CD in the drive, do
not press any key when prompted to press any key to
boot from CD.
163
164
OR
165
Click Next.
For help finding your product key, see the note at the
beginning of this document.
166
OR
167
225. Set the date, time, and time zone. Click Next.
168
169
27. If you are prompted for workgroup or domain settings, leave the default entries and click Next.
128. Setup will continue and will eventually reboot. If you have left the CD in the drive, do not press
any key when prompted to press any key to boot from CD.
129. After rebooting, you may see a display settings box. If you do, click OK. The screen may flicker
for a moment and ask you whether you can see the image. If you can, click Yes.
31. If you are asked to setup a network or Internet connection at this time, click on Skip.
32. You will now be prompted to register your copy of Windows. Since we have not connected to
the network yet, select No and click Next. If prompted to activate Windows, choose the appropriate
option to skip this step as well. Windows will prompt you to do this later if it is required.
33. Click Finish on the Thank You screen. The Windows XP operating system itself should now be
installed.
171
2) XP abbreviation?
Answer: Extreme professional
3) How many characters does a product key contain from windows XP?
Answer: characters (total blocks: 5 and each block contains:5 characters).
4) Describe different kinds of Microsoft Operating systems?
Answer: Windows 95, windows 2000, windows XP, windows 7
5) FAT stands for: file allocation table
6) NTFS stands for: new technology file system.
Exercise 16
1. Network Configuration & Software Installation-Configuring TCP/IP, Proxy, and
Modem
Hub
Brides (switches)
Routers
Servers
Printers ,scanners
TYPES OF NETWORKS:
Networks are divided into three primary categories.
TOPOLOGY:
It the is similar properties of the object.
PROCESSORS
LOCATED IN SAME
EXAMPLES
Circuit board
1m
System
Multi computer
10m
Room
100m
Building
1km
Campus
Lans
175
10km
City
Man
100km
Country
Wan
1000km
Continent
Wan
10,000km
Planet
The internet
INTERNET:
HYPERTEXT:
HYPERMEDIA:
PROTOCOL:
TCP/IP:
Class A
Class B
Class C
Class D
IP ADDRESS FORMAT:
The 32 bit IP address is grouped eight bits at a time , separated by dots , and
represented in the decimal format (known as decimal notation).
Each bit in the octet has a binary weight (128,64,32,16,8,4,2,1).
The minimum value for an octet is 0.
The maximum value for an octet is 255.
32 bits
NETWORK ID
8 bits
172
HOST ID
8 bits
32
8bits
144
8bits
202
NETWORK ID
HOST ID
IP ADDRESS CLASSES:
IP
ADDRES
S CLASS
HIGH
ORDE
R BITS
NO. BITS
NETWORKIN
G / HOST
MAX.
HOSTS
1.0.0.0 to
126.0.0.0
7/24
224-2
ADDRESS
RANGE
FORMAT
PURPOSE
N.H.H.H
Few large
organization
N.N.H.H
Medium-size
organization
1,0
128.1.0.0 to
191.254.0.0
14/16
216-2
N.N.N.H
Relatively
small
organization
1,1,0
192.0.1.0 to
223.255.254.0
21/8
28-2
Multicast
groups
1,1,1,0
178
224.0.0.0 to
239.255.265.25
N/A
N/A
(RFC-1112)
N/A
Experimenta
l
240.0.0.0 to
254.255.255.25
5
1,1,1,1
N Network
N/A
H Host
SUBNET MASK:
Each physical segment has a unique network ID.
Class A
Class B
Network
Host
1 0 Network
Network
Host
Host
Class C
1 1 0 Network
Host
Network
Network
Host
Host
DOMAIN:
N/A
BROWSER:
DISPLAY:
Verify whether LAN CARD (or) ETHERNET CARD is there in the system.
Right click on
my computer
properties
system properties
hardware device manager
network adapter.
If the LAN CARD is not installed , then install the drivers and restart the
system.
On the desktop right click on the icon MY NETWORK PLACES.
Select the internet protocol (TCP/IP) option and click its properties and give
the IP address with subnet mask and press OK.
In order to connect a small office networks , goto network tasks in my
network places , click setup a home (or) small office network.
Click on next for both the windows.
Select the option This computer does not have internet connection and press
next , give the computer and its work group name which should be unique for
all the systems in that LAN.
After the giving the work group name , select the option turn on file and print
sharing and press next , that will show the network settings.
After the completion of the setup press finish.
Select the option views work group computer and we can view the
computers that are in this LAN and ready to share the data. Click on the icon
of any system seen in the work group we can get that system views.
In order to get our system drives view to others we should give sharing
permission.
180
ETHERNET:
It is widely used network technology.
BOOK MARK:
INTERNET BOOKMARK:
181
Bookmarks are pointers- primarily to URLs- built-in to the various Internet web
browsers.
Bookmarks have been incorporated into almost every browser since the Mosaic
browser and are normally stored on the software client.
A folder metaphor may be used for organization. Various shareware utilities and
server-side web utilities have been developed to better manage bookmark,yet none
has gained widespread acceptance.
The most recent development in internet bookmarks was the introduction of live
bookmarks by Mozilla Firefox in 2004.
Utilizing Web feeds, live bookmarks sit in the bookmarks menu or sidebar like
any other, but contain a regularly updated list to recent articles supplied by a news
site or Weblog.
POP-UP BLOCKER:
Pop-up blocker refers to any software or application that disables any pop-up,
pop-over or pop-under advertisement window that you would see while using a
Web browser.
Some pop-up blockers may try to close all pop-up windows, some may remove all
advertising from a publishers Web site, and still others may help you choose which
pop-up window you want to be closed with block list feature.
182
PROCEDURE:
183
License agreement will open . Click I accept the terms of the license
agreement and then click next.
Choose a setting
Click OK
Windows Firewall:
184