Starting from:

$25

IT1050 -  Object Oriented Concepts  - Tutorial 01 - Solved

Objectives : Use the online programming Repl.IT that is used for tutorials and to refresh the programming knowledge you have learnt in IT1010 – Introduction to Programming Environments

 

Exercise 0  

Follow the Instructions given in the document Instructions in using Repl.IT to setup an account and start the first Tutorial.

Once you have completed the steps you should see the following screen.  You can tryout the 4 questions of the Tutorial.  The questions are called Assignments in Repl.IT

  

             


 

 

Use the Editor to try out the program and you can run your program using the run button.  Once you are satisfied with your solution you can submit your solution. 

 

  

 

Your solution will be checked for logical errors and you will be notified if there are errors.  In such a case modify your program and resubmit. 

 

  

             



 

  

 
 

 

The questions in the Week 01 Tutorial are given below in case you have issues in accessing the Internet. 

 

Exercise 1 - Calculations

 

Write a C program to input marks of two subjects. Calculate and print the average of the two ma   
 

 

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

 

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

 

                 

 

 

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. 

 

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; 



 

More products