Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

EXPERIMENT NUMBER – 1

NAME - MAHAK SAHARAN UID - 21BCS9444 BRANCH –


COMPUTER SCIENCE

SECTION/GROUP – 28(A) SEMESTER – FIRST SUBJECT – FCP

DATE OF PERFORMANCE – 14/SEP/2021

AIM OF THE EXPERIMENT – TO PERFORM INPUT OUTPUT OPERATIONS USING C.

Program 1.1: Write a program that reads two nos. from key board and gives their addition,
subtraction, multiplication, division and modulo.

Program 1.2: The distance between two cities (In KM) is input through key board. Write a program
to convert and print this distance in meters, feet, inches & centimeters.

FLOWCHART/ ALGORITHM:

FOR PROGRAM 1.

FOR PROGRAM 1.2

SUBJECT NAME-Fundamentals of Computer Programming SUBJECT CODE-


21CSH101
PROGRAM CODE 1.1

#include <stdio.h>
int main()
{
int num1, num2;
int sum, sub, mult, mod;
float div;

/*
* Read two numbers from user separated by comma
*/
printf("Input any two numbers separated by comma : ");
scanf("%d,%d", &num1, &num2);

/*
* Performs all arithmetic operations
*/
sum = num1 + num2;
sub = num1 - num2;
mult = num1 * num2;
div = (float)num1 / num2;
mod = num1 % num2;

/*
* Prints the result of all arithmetic operations
*/
printf("The sum of the given numbers : %d\n", sum);
printf("The difference of the given numbers : %d\n", sub);
printf("The product of the given numbers : %d\n", mult);
printf("The quotient of the given numbers : %f\n", div);
printf("MODULUS = %d\n", mod);

return 0;
}

SUBJECT NAME-Fundamentals of Computer Programming SUBJECT CODE-


21CSH101
PROGRAM 1.2

#include<stdio.h>
int main()
{
float km, m, cm, f, in;
printf("Enter distance in kilometers: ");
scanf("%f", &km);
/* calculate the conversion */
m = km * 1000;
cm = km * 1000 * 100;
f = km * 3280.84;
in = km * 39370.08;
printf("The distance in Feet: %f\n", f);
printf("The distance in Inches: %f\n", in);
printf("The distance in Meters: %f\n", m);
printf("The distance in Centimeters: %f\n", cm);
return (0);
}

SUBJECT NAME-Fundamentals of Computer Programming SUBJECT CODE-


21CSH101
ERRORS ENCOUNTERED DURING PROGRAM’S EXECUTION
(Kindly jot down the compile time errors encountered)

Program 1.1

SUBJECT NAME-Fundamentals of Computer Programming SUBJECT CODE-


21CSH101
PROGRAM 1.2
No error

PROGRAMS’ EXPLANATION (in brief)

PROGRAM 1.1
Math in your C source code is brought to you by the +, –, *, and / operators. These
are the basic math symbols, with the exception of * and /, mostly because the × and
÷ characters aren’t found on the typical computer keyboard.

PROGRAM 1.2
This program is a unit converter that changes a unit in one form to another form.
Input the distance between two cities in kilometers, we have to calculate the
distance in meters, feet, and inches.
In the program, we are taking of the distance between two cities in kms and
converting them into meters, cms, feet and inches.

SUBJECT NAME-Fundamentals of Computer Programming SUBJECT CODE-


21CSH101
OUTPUT

PROGRAM 1.1

PROGRAM 1.2

SUBJECT NAME-Fundamentals of Computer Programming SUBJECT CODE-


21CSH101
LEARNING OUTCOMES

Remember the concepts related to fundamentals of C language, draw flowcharts


and write algorithm/pseudocode.

Understand the way of execution and debug programs in C language.

Apply various constructs, loops, functions to solve mathematical and scientific


problem.

Analyze the dynamic behavior of memory by the use of pointers.

Design and develop modular programs for real world problems using control
structure and selection structure.

EVALUATION COLUMN (To be filled by concerned faculty only)


Sr. No. Parameters Maximum Marks
Marks Obtained
1. Worksheet Completion including writing 10
learning objective/ Outcome
2. Post-Lab Quiz Result 5

3. Student engagement in Simulation/ 5


Performance/ Pre-Lab Questions
4. Total Marks 20

SUBJECT NAME-Fundamentals of Computer Programming SUBJECT CODE-


21CSH101

You might also like