it1050-2022-feb / tutorial-01-it21257568 Goto Github PK
View Code? Open in Web Editor NEWtutorial-01-IT21257568 created by GitHub Classroom
License: MIT License
tutorial-01-IT21257568 created by GitHub Classroom
License: MIT License
[![Open in Visual Studio Code](https://classroom.github.com/assets/open-in-vscode-f059dc9a6f8d3a56e377f745f24479a46679e63a5d9fe6f495e02850cd0d8118.svg)](https://classroom.github.com/online_ide?assignment_repo_id=6964308&assignment_repo_type=AssignmentRepo) ![logo](/resources/tutelogo.png) ## <div align="center">Tutorial 01</div> ## Objectives : Revise writing C Programs This week we will revisit writing C programs. In IT1050 the programming language you will use C++ is based on the C language and you have to use your C knowledge to write C++ programs ## Exercise 1 - Calculations Write a C program to input marks of two subjects. Calculate and print the average of the two marks. Program File - [Tute01.c](Tute01.c) โ ## Exercise 2 - Selection Write a program to calculate the amount to be paid for a rented vehicle. * Input the distance the van has travelled * The first 30 km is at a rate of 50/= per km. * The remaining distance is calculated at the rate of 40/= per km. e.g. ``` Distance -> 20 Amount = 20 x 50 = 1000 Distance -> 50 Amount = 30 x 50 + (50-30) x 40 = 2300 ``` Program File - [Tute02.c](Tute02.c) ## Exercise 3 - Repetition Write a C program to calculate the sum of the numbers from 1 to n. Where n is a keyboard input. e.g. ``` n -> 100 sum = 1+2+3+....+ 99+100 = 5050 n -> 1- sum = 1+2+3+...+10 = 55 ``` Program File - [Tute03.c](Tute03.c) ## Exercise 4 - Functions Implement the three functions ```minimum()```, ```maximum()``` and ```multiply()``` below the ```main()``` function. Do not change the code given in the main() function when you are implementing your solution. ```c int main() { int no1, no2; printf("Enter a value for no 1 : "); scanf("%d", &no1); printf("Enter a value for no 2 : "); scanf("%d", &no2); printf("%d ", minimum(no1, no2)); printf("%d ", maximum(no1, no2)); printf("%d ", multiply(no1, no2)); return 0; } ``` Program File - [Tute04.c](Tute04.c)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.