Professional Documents
Culture Documents
To Calculate Total Marks & Percentage
To Calculate Total Marks & Percentage
REPORT
In
COMPUTER SCIENCE
(‘C’ Programming Language)
On
To calculate total marks &
Percentage
SUBMITTED TO –
MRS. RAJNI GAUTAM
(COMPUTER FACULTY)
Submitted by –
Name : Meghna
Father’s Name : Mr. Kuldeep Daga
Class-Section : X-A
Roll No. : 21
Meghna Class-X-A
TABLE OF CONTENTS
Introduction
Certificate
Acknowledgement
Aim
Program
Coding
Output
Conclusion
Meghna Class-X-A
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.
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 -
(3) Compound statement enclosed in two braces { } such that each statement
ends with a semicolon.
Meghna Class-X-A
#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.
Data Type
‘C’ language has five types data type –
1. Integer
2. Character
3. Floating Point
4. Double
5. Void
Meghna Class-X-A
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.
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
Meghna Class-X-A
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.
Meghna Class-X-A
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.
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);
Meghna Class-X-A
Printf Function
This is the most commonly used function for outputting a data of any type.
Syntax –
Meghna Class-X-A
CERTIFICATE
This is to certify that “Meghna” has completed this project report under my
Programming Language during the year 2019-2020. They are submitting this
qualifying examination.
(Computer Teacher)
Meghna Class-X-A
ACKNOWLEDGEMENT
I, Meghna wish to express our gratitude with a great pleasure towards respected
principal Mrs. Rajni Ohri for providing all the facilities. I am equally indebted
Mrs. Rajni Gautam for the constant encouragement and able to guidance the
and complete this work last but not the least I am immensely grateful to
Submitted By:-
Name : Meghna
Father’s Name : Mr. Kuldeep Daga
Class-Section : X-A
Roll No. : 21
Meghna Class-X-A
AIM
Language.
Meghna Class-X-A
Introduction to the Topic
Control Statements
When we run a program, the statements are executed in the order in which they
appear in the program. Also each statement is executed only once. But in many
cases we may need a statement or a set of statements to be executed a fixed number
of times or until a condition is satisfied. Also we may want to skip some statements
based on testing a condition. For all these we use control statements –
Branching –
1. If …. Else Statement – it is used to carry out one of the two possible
actions depending on the outcome of a logical test. The else partion is
optional.
Syntax – if(expression)
statement1
else
statement2
2. Nested if statement
Within if block or else block another if…else statement can come. Such
statements are called nested if statement.
Syntax –
if (expression1)
statement1
if (expression2)
Statement2
else
statement3
Meghna Class-X-A
3. Ladder if statement –
In order to create a situation in which one of several courses of action is
executed we used ladder..if statement
Syntax –
if (expression1) statement1
if (expression2) Statement2
if (expression3) Statement3
----------------------------
else statement n
Meghna Class-X-A
Make a program to calculate total marks, %age, division of a
student in five subject in C.
#include<stdio.h>
#include<conio.h>
void main()
{
inteng,maths,sci,sst,hindi;
floattotal,per,div;
clrscr();
printf(“Enter Marks of English, Maths, Science, Social, Hindi”);
scanf(“%d%d%d%d%d”,&eng,&maths,&sci,&sst,&hindi);
total=eng+sci+maths+sst+hindi;
per=total*100/500;
if (per>=60)
printf(“Ist”);
else if (per>=12)
printf(“2nd");
else if (per>=33)
printf(“3rd");
else
printf(“Failed”);
printf(“Total Marks : - %f“,total);
printf(“Percentage of Marks : - %f“,per);
printf(“Division : - %f“,div);
getch();
}
Meghna Class-X-A
CODING IN Turbo ‘C’
Meghna Class-X-A
OUTPUT
Meghna Class-X-A
CONCLUSION
Control Statements
When we run a program, the statements are executed in the order in which they
appear in the program. Also each statement is executed only once. But in many
cases we may need a statement or a set of statements to be executed a fixed number
of times or until a condition is satisfied. Also we may want to skip some statements
based on testing a condition. For all these we use control statements –
Meghna Class-X-A