Basic programme in c
1. Brief Introduction:
This program is a simple attendance program written in C language. It prompts the
user to enter the total number of students, and then asks for the attendance status of
each student using the character input 'y' or 'n' to indicate whether a student is present
or absent, respectively.
The program keeps track of the number of present and absent students using two
separate counters, and then displays the attendance summary at the end of the input
process, which includes the total number of students, number of students present, and
number of students absent.
If the user enters an invalid input (i.e., a character other than 'y' or 'n'), the program
prints an error message and repeats the current iteration of the loop so that the user
can input the attendance status again.
2. Aim of Project:
The aim of this program is to take input from the user regarding the attendance of
students in a class and then summarize the attendance by displaying the total number
of students, number of students present and absent.
3. Course Outcome Addressed:
Develop programming skills: The program requires the use of various programming
constructs such as loops, conditional statements, and input/output functions to achieve
the desired functionality. Implement user input validation: The program checks for
valid user input by validating if the user has entered either 'y' or 'n'. Apply basic
arithmetic and logical operations: The program uses arithmetic and logical operators
such as addition, subtraction, and logical OR to calculate the total number of students
present and absent.
4. Uses of C language:
C is the oldest and most fundamental programming language, and it is extensively
used all over the world. C is fast, portable language with a large library. It is a middle
level language with the advantage of both low-level and high-level languages. And
it’s disheartening to learn that C programming is becoming less popular day by day. C
has left an indelible mark on practically every field and is widely used for application
development and system development.
Sharad institute of technology polytechnic, Yadrav
1
Basic programme in c
5. Applications of C Language:
Fast
Portability
Function-Rich library
Dynamic memory management
Modularity with structured language
Mid-level programming language
Pointers with the use of pointers in C, you can directly interact with memory
Recursion C language provides the feature of recursion
6. Advantages:
Portable language
Structured programming language
Powerful and efficient language
Building block for many other programming language
Quality to extend itself
7. Disadvantages:
Run-time checking
Constructor or destructor
Low-level of abstraction
Concept of name space
No strict type checking
Sharad institute of technology polytechnic, Yadrav
2
Basic programme in c
STUDENT ATTENDANCE PROGRAM
This program provides a way to take the attendance of a class in C programming
language. The program prompts the user to enter the total number of students and then asks
whether each student is present or absent. Based on the user's input, the program increments
the count of present or absent students. At the end of the program, it displays the attendance
summary, which includes the total number of students, the number of students present, and
the number of students absent.
This program is useful for teachers or professors who need to keep track of attendance
in their classes. It can help automate the attendance-taking process and provide a quick
summary of the attendance status for the class.
PROGRAM SOURCE CODE:
Sharad institute of technology polytechnic, Yadrav
3
Basic programme in c
ABOUT THIS CODE:
In this code, we use a for loop to iterate over each student, from 1 to n. Inside the
loop, we prompt the user to enter whether the student is present or absent. We use the scan
function to read a single character from the user input, and store it in the attendance variable.
We then use an if-else statement to check whether the user entered 'y' or 'n', and
update the present count or absent count variable accordingly. If the user entered anything
other than 'y' or 'n', we print an error message and decrement the loop variable I so that the
current iteration can be repeated.
Finally, we print a summary of the attendance, including the total number of students,
the number of students who are present, and the number of students who are absent.
OUTPUT:
Output for 4 students:
Sharad institute of technology polytechnic, Yadrav
4
Basic programme in c
Output for 12 students:
Sharad institute of technology polytechnic, Yadrav
5