INVESTIGATORY PROJECT
REPORT
In
COMPUTER SCIENCE
(‘C’ Programming Language)
On
Accept & display marks for five
student using array
SUBMITTED TO –
MRS.RAJNI GAUTAM
(COMPUTER FACULTY)
Submitted by –
Name : Aparna Tiwari
Father’s Name : Mr.Pradeep Tiwari
Class-Section : X-C
Roll No. : 08
Aparna Tiwari Class- X-C
TABLE OF CONTENTS
Introduction
Certificate
Acknowledgement
Aim
Introduction to the topic
Program
Coding
Output
Conclusion
Aparna Tiwari Class- X-C
INTRODUCTION TO ‘C’
Introduction
‘C’ is a programming language developed in 1972 at Bell Laboratories by Dennis
Ritchie. The ‘C’ programming language used for development the different types of
software.
Some Features of ‘C’ Language
1. All programs written in lower case alphabets.
2. Compile a program using ALT+F9.
3. Run a program using CTRL+F9.
4. Display output using ALT+F5.
5. Display full screen of coding window F5.
Structure of a program
Every C program consists of one of more modules called functions. One of these
functions is called main. The programs begin executing by main function and access
other function, if any. Functions are written after or before main function separately.
A function has -
(1) Heading consists of name with list of arguments (optional) enclosed in
parenthesis.
(2) Argument declaration (if any) and
(3) Compound statement enclosed in two braces { } such that each statement
ends with a semicolon.
Comments, which are not executable statement, of necessary can be placed in
between /* and */.
Aparna Tiwari Class- X-C
#include<stdio.h>This statement used for include Standard Input Output
Header files in our program. This header file performs all standard input
output operations like printf and scanf.
#include<conio.h>This statement used for include Console Input Output
Header file in our program. This header file perform all Console operations or
functions like clrscr( ) and getch( ).
clrscr( ) Function – Used for clear output screen.
getch( ) Function – Used for hold the output screen until press any key.
Keywords – Keywords are the reserved words in ‘C’ language. They have
own meaning and are used for some special purpose. Standard keywords are
auto, break, case, char, int, void, float etc.
Identities – Identities are names given to various program elements like
variables, arrays, and functions. The name should begin with a letter and other
characters can be letters and digits and also can contain underscore character (
_ ) like area, average, x12, name, place_name etc.
Data Type
‘C’ language has five types data type –
1. Integer
2. Character
3. Floating Point
4. Double
5. Void
Integer:-Integer data type is used to operate integer arithmetic operations
and this type variable always store integer values. This types of variable take
two byte in the memory.
Syntax - <data type><variable name>
Example – intnum; ---> where int is a data type and num is a variable
Aparna Tiwari Class- X-C
Character:- Character data type is used to hold character in 8 bits or 1 byte.
Syntax –
<data type><list of parameters or variables>
Example – char name, address etc.
Floating Point: (Real Number or Real Data)
The float data type is used to define real numbers or real data types.
Syntax –
<data type><list of parameters or variables>
Example – float salary, amount;
Void:
Has three uses –
1. To declare void with the name of the function means returning no value.
2. To declare void within the function argument means no arguments..
3. To create a generic pointer.
Syntax –
void name of function
Escape Sequence: An escape sequence is used to express non printing
characters like a new line, tab etc. It begin with backslash ( \ ) followed by
letter like a, n, b, t, v, r etc. The commonly used escape sequences are –
\a – for alert
\b – backspace
\n – new line
\f – form feed
\0 – null
Aparna Tiwari Class- X-C
Variable: - A variable is an identifier that is used to represent some specified
type of information. Only a single data can be stored in a variable. The data
stored in the variable is accessed by its name, before using a variable in a
program, the data type it has to store is to be declared.
int a, b, c;
a=10;
b=20
Declarations of Variable:
This is for specifying data type. All the variables, functions etc must be
declared before they are used. A declaration tells the compiler the name and
the type of a variable you will be using in your program. A declaration
consists of the type, the name of the variable, and a terminating semicolon.
Operators:
There are for types of operator –
1. Arithmetic Operator: - Used for arithmetic operation like (+, -, x, /, %)
2. Unary Operator: - A operator acts up on a single operand to produce a
new value is called a unary operator. The Increment (++) and Decrement
(- -) operator, they increase the value by 1.
3. Relational Operator: - < (less than), <= (less than or equal to), >
(greater than), >= (greater than or equal to), = = (equal to) and != (not
equal to) are relational operator.
4. Logical Operator: - && (and) and || (or) are logical operators which are
used to connect logical expressions.
5. Assignment Operator:- These operator are used for assigning a value
of expression to another identifier. =, +=, -=, *=, /= and %= are
assignment operator.
6. Conditional Operator:- The operator ?: is conditional operator. It is
used as Variable1=expression1 ?expression2 : expression3.
Aparna Tiwari Class- X-C
Data Input Output
For inputting and outputting data we use library function, the important of
these functions are getchar( ), putchar( ), printf ( ), gets( ), puts( ). For using
these functions in a ‘C’ program there should be a preprocessor statement
#include<stdio.h>.
getchar function:
It is used to read a single character (char type) from keyboard. The syntax is
char variable name = getchar( );
Example –
char c;
c=getchar( );
putchar function:
It is used to display single character. The syntax is –
putchar (char c);
Example –
char c;
c=’a’;
putchar(c);
scanf Function
This function is generally used to read any data type – int, char, double, float, string.
Syntax – scanf(control string, list of arguments);
The control string consists of group of characters, each group beginning % sign and
a conversion character indicating the data type of the data item.
Example –
scanf(“%d%s%f”,&x,name,&salary);
Aparna Tiwari Class- X-C
Printf Function
This is the most commonly used function for outputting a data of any type.
Syntax –
printf(control string, list of arguments)
Aparna Tiwari Class- X-C
CERTIFICATE
This is to certify that “Aparna Tiwari”has completed this project report under
my guidance on application “Accept & display marks for five student using
array” in ‘C’ Programming Language during the year 2019-2020. They are
submitting this project report in partial fulfillment of the requirements for the
award of qualifying examination.
Ms. Rajni Gautam
(Computer Teacher
Aparna Tiwari Class- X-C
ACKNOWLEDGEMENT
I, Aparna Tiwari wish to express our gratitude with a great pleasure towards
respected principal Mrs. Rajni Ohri for providing all the facilities. I am equally
indebted Ms. Rajni Gautam for the constant encouragement and able to
guidance the rendered to me for completing this study.
I am also highly obliged to my parents who helped me financially to undertake
and complete this work last but not the least I am immensely grateful to
colleagues for their coordination in completing this work.
Submitted By:-
Name : Aparna Tiwari
Father’s Name : Mr.Pradeep Tiwari
Class-Section : X-C
Roll No. : 08
Aparna Tiwari Class- X-C
AIM
“Accept & display marks for five student using array” using ‘C’
Programming Language.
Aparna Tiwari Class- X-C
Introduction to the Topic
Arrays
Introduction
An array refers to a group of objects of the same data type.It is a data structure
through which a programmer can store and perform operations on a collection of
data values of same data type and same size. An array can holds multiple values at a
time.
Types of Arrays –
1. Single Dimension Array or one dimension array consists of finite number of
homogeneous elements.
2. Multi-Dimension Array consists of finite number of homogeneous elements
each of which itself is an array.
Single Dimension Array – A single dimension array is an array that stores a
group of values, all of same type in continues memory locations. Single dimension
array have one subscript or index.
Declaration of 1-D Array –
Syntax - <data type><variable name> [size];
Example –
intnum[5];
num[5] means, this is a group of 5 elements num[0], num[1], num[2], num[3],
num[4];
Array index start from 0 and ending with less then one.
If the array elements declare with 5 index or subscripts of int data type, it take 10
byte memory of computer. It depends on the data type used with array declaration.
Initialization of Single Dimension Array –
1. intnum[5] = {10, 25, 35, 96, 41}
2. num[0]=10, num[1] = 21, num[2] =47 etc.
3. with string char name[10]=”Mayank”;
Aparna Tiwari Class- X-C
Understanding of Two-Dimension Array
A two dimension array is an array with two subscripts or index. It is interpreted in
terms of Rows and columns, the fist index corresponds to arrow number and the
second index corresponds to column number.
Syntax - <data type><array name> [rows][column];
Example -
float marks[3][4];
where 3 rows and 4 columns and total element in this declaration 3 x 4 = 12.
Representation – A two dimension array is stored in the main memory as a grid of
rows and column in contiguous locations.
Marks[3][3]; = marks[0][0];
marks[0][1];
marks[0][2];
marks[1][0];
marks[1][1];
marks[1][2];
marks[2][0];
marks[2][1];
marks[2][2];
Array of String
A two dimensional array of characters can be used as an array of strings.
Example – char student[3][10] = {“Vishal”,”Arun”,”Anil”}
Aparna Tiwari Class- X-C
Program to accept and display marks for five students from the user and
display them using for loop.
#include<stdio.h>
#include<conio.h>
void main( )
{
clrscr( );
ini, mark[5];
printf(”Enter the marks of five subject of a student : “);
for(i=1;i<=5;i++)
{
printf(”\n Marks of Subject : %d“,i);
scanf(“%d”,&mark[i-1];
}
printf(”\n The Marks you have entered are : “);
for(int i=1;i<=5;i++)
{
printf(”\n Marks of Subject : %d\t“, i, marks[i-1]);
}
getch( );
}
Aparna Tiwari Class- X-C
CODING IN Turbo ‘C’
Aparna Tiwari Class- X-C
OUTPUT
Aparna Tiwari Class- X-C
CONCLUSION
In this project we want to show the use of Array in ‘C’ Programming. This program
Accept & display marks for five student using array.
An array refers to a group of objects of the same data type.It is a data structure
through which a programmer can store and perform operations on a collection of
data values of same data type and same size. An array can holds multiple values at a
time.
Types of Arrays –
1. Single Dimension Array or one dimension array consists of finite number of
homogeneous elements.
2. Multi-Dimension Array consists of finite number of homogeneous elements
each of which itself is an array.
Aparna Tiwari Class- X-C