Professional Documents
Culture Documents
Fcp+Worksheet+Exp+1 1
Fcp+Worksheet+Exp+1 1
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.
#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;
}
#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);
}
Program 1.1
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.
PROGRAM 1.1
PROGRAM 1.2
Design and develop modular programs for real world problems using control
structure and selection structure.