Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
49 views4 pages

Aurdino C Module 1 Labsheet 1

This document is a lab sheet for a Computer Programming course at Presidency University, detailing the process of developing programs in C. It includes examples of simple C programs for addition, area calculation, average computation, and arithmetic operations, along with exercises for students to practice. The exercises involve calculating average marks, total shopping expenses with discounts, and determining the number of balls that can fit in a specified volume.

Uploaded by

grishma.renuka
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views4 pages

Aurdino C Module 1 Labsheet 1

This document is a lab sheet for a Computer Programming course at Presidency University, detailing the process of developing programs in C. It includes examples of simple C programs for addition, area calculation, average computation, and arithmetic operations, along with exercises for students to practice. The exercises involve calculating average marks, total shopping expenses with discounts, and determining the number of balls that can fit in a specified volume.

Uploaded by

grishma.renuka
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 4

COMPUTER PROGRAMMING PRESIDENCY UNIVERSITY SCHOOL OF ENGINEERING-B.

TECH

LABSHEET -1

Developing Programs in C:
1. Creating the Program:
The source program can be written or modified using editor and can be saved with the
extension of .C

2. Compiling the program.


Where the program is checked for the Syntax and Semantics of the language and
reports the errors to the user. These errors have to be corrected by the users in the
source program.

3. Executing the Program.


Once the error free code is generated after the compilation process, the program can
be executed with valid inputs by linking to the required header files.

1 COMPUTER PROGRAMMING- CSE151 LABSHEET-1


COMPUTER PROGRAMMING PRESIDENCY UNIVERSITY SCHOOL OF ENGINEERING-B.
TECH

Programs done in the lab


Problem 1: Write a program to perform the addition of two numbers.

#include <stdio.h> //Header file


void main () // Program starts from main function
{
int a, b, c; //Taking three variables to perform addition operation
printf ("Enter the values for a and b"); // Display statements
scanf ("%d %d", &a, &b); // Reading a and b values from keyboard
c=a+b; //performing addition and storing result in c
printf ("Addition of a and b are %d", c); //Displaying the value stored in c
}

Problem 2: Write a program to find Area of a Circle.

#include <stdio.h> //Header file


void main() // Program starts from main function
{
float radius, area; //Declaring two variables
printf ("Enter the radius value of circle"); //Display statements
scanf("%f", &radius); //Reading radius value from keyboard
area=3.14*radius*radius; //Formula to calculate area of circle
printf("The area of circle is %f", area); //Displaying the value of area
}

Problem 3: Write a program to find the average of 5 numbers

#include <stdio.h> //Header file


void main() // Program starts from main function
{
float avg; //Declaring variable to store average of 5 number
avg=(10+20+30+40+50)/5; //Calculating the average
printf("The average of 5 numbers are %f",avg); //Displaying the avg value
}

Problem 4: Write a C program to perform different arithmetic operations

#include <stdio.h> //Header file


void main() // Program starts from main function
{
int x ,y, add, sub, mul, mod;
float div;
printf("Enter the value for x and y to perform arithmetic operation "); //Display statements
2 COMPUTER PROGRAMMING- CSE151 LABSHEET-1
COMPUTER PROGRAMMING PRESIDENCY UNIVERSITY SCHOOL OF ENGINEERING-B.
TECH

scanf("%d %d", &x, &y); //Reading the values for x and y to perform arithmetic operation
add=x+y; // addition operation
sub=x-y; //subtraction operation
mul=x*y; //multiplication operation
mod=x%y; //modulus operation
div=x/y; //division operation
printf("Addition is %d\n",add); //Displaying addition value
printf("subtration is %d\n",sub); //Displaying subtraction value
printf("multiplication is %d\n",mul); //Displaying multiplication value
printf("modulus is %d\n",mod); //Displaying modulus value
printf("division is %f\n",div); //Displaying division value

Exercise program for students

Exercise 1:
Computer Programming teacher conducts test for 20 marks for 10 students. Teacher wants
to know the average marks scored by the students.
Following are requirements to solve the problem
Teacher should have capture the marks scored by the student.
Teacher should compute the average marks scored by the students.
Teacher should display the average marks scored by the students.

Exercise 2:
As there is lock down everywhere, and the time allocated for shopping is restricted, Mr.
Umar went for shopping in the specified time, He went to the vegetable super market, He
purchased some vegetables and fruits. The total bill was “m” Rs. and he got a discount of
10% there. Next he went to Buy n Save shop and purchased the groceries and the bill
amount generated there was “n” Rs and here he got a discount of 12.5%. Later he went to
buy medicines and there the bill was “p” Rs. and there also he got a discount of 18%.
His mother asked the bill details and the total amount he spent today. Help to create a C
application for the same.
Requirements.
Capture the bill m, n,p
Compute the amount paid at individual place after discount.
Display the bill amount paid at each place.
Calculate the total amount spent
Display the total amount spent by Mr. Umar

Exercise 3:
In a box of total area 10000cm3, Mr. Varun has to pack the balls of given radius “r” and all the
balls have the same volume, Help Mr. Varun to find the total number of balls that he can pack
3 COMPUTER PROGRAMMING- CSE151 LABSHEET-1
COMPUTER PROGRAMMING PRESIDENCY UNIVERSITY SCHOOL OF ENGINEERING-B.
TECH

in the given box.


Requirements
Capture the radius of the ball “r”
Compute the volume (Hint: Volume=4/3πr3)
Calculate how many number of balls can be placed in the box of 10000cm3 box
Display the number of balls packed by Mr. Varun

4 COMPUTER PROGRAMMING- CSE151 LABSHEET-1

You might also like