Preview

C coding

Satisfactory Essays
Open Document
Open Document
384 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
C coding
Assignment 1 (FIT5003)
User Manual

Scope:
Create threads based on user input to share the processor time.

Steps:
1. The codes are written in C language compiled in a virtual machine (gcc -lpthread -o soft soft.c).
2. First, the program will give the user the option to input number of threads to be processed 1, 2..., etc using the scanf function.

3. The threads will increment using while loop.
4. After mentioning number of threads the first thread will be created for processing. The user will be asked to enter his/her student ID.
5. The user should enter the value of two integers A and B.
6. Get the modulus of student ID by 3 using if condition in order to achieve the below functionality:
If the mode is equal to (0) then calculate the sum.
Else if, the mode is equal to (1) then calculate the sum of squares.
Finally, if the mode is equal to (2) calculate the factorial.
7. Print the time used for each thread to process individually in seconds using (gettimeofday) function.
8. Also, the program will print the current date, month and time at the end.

Example:
Let’s assume that the use will enter 1170 as his user ID so, 1170 mod 3 which will equal to 0 it will calculate Sum of integers based on A and B entries. Then the program will ask the user to enter A: 25 and B: 50 (25+26+27…. +49) so, the total = 925. The last value is 49 based on the end value (b-1) so, 50 will not be included in the calculation.

Assumption and justification:
1. Allowing the user to enter the value of A and B is more practical than just assigning static value for A and B.
2. Specifying in if condition that input B must be greater than A, according to the condition of the end value (b-1).
3. Because of the size of the program the processor doesn’t require much time to execute and that’s the reason why the output is 0.000000 seconds.

Limitation:
In calculating the factorial and sum of squares if the user entered large numbers (four

You May Also Find These Documents Helpful

  • Better Essays

    5. It is capable of executing instructions on its own after the data and program have been fed into its memory.…

    • 4310 Words
    • 17 Pages
    Better Essays
  • Good Essays

    c. Modify the program of Part b so that at the option of the user, it displays…

    • 300 Words
    • 2 Pages
    Good Essays
  • Powerful Essays

    Mat 540 Week 4 Paper

    • 1775 Words
    • 8 Pages

    A worm is moving toward an apple. Each time it moves, the worm cuts the distance between itself and the apple by its own body length until the worm is close enough to enter the apple. The worm can enter the apple when it is within a body length of the apple.…

    • 1775 Words
    • 8 Pages
    Powerful Essays
  • Satisfactory Essays

    CMIS 102 Homework 3

    • 342 Words
    • 3 Pages

    Program Description - This program will allow a user to input their name and final grades from their courses and calculate their GPA accordingky. The amount of students as well as the amount of classes each student is taking, are undetermined.…

    • 342 Words
    • 3 Pages
    Satisfactory Essays
  • Satisfactory Essays

    carloe :)

    • 253 Words
    • 2 Pages

    Problem 1: Write an application that prints every integer value from 1 to 20 along with the squared value of each integer.…

    • 253 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Variable and Meal Price

    • 1236 Words
    • 9 Pages

    10.) Design a subroutine called timesTen. The subroutine should accept an integer argument. When the subroutine is called, it should display the product of its argument multiplied by 10.…

    • 1236 Words
    • 9 Pages
    Satisfactory Essays
  • Good Essays

    Programming

    • 1575 Words
    • 7 Pages

    Lab – 1 (2 Hrs Real Time) 1.1 Write a C + + program to display any message. 1.2 Sum of digit 1.2.1 Reverse the number 1.2.2 Factorial of a number 1.2.3 Fibonacci series 1.2.4 Armstrong number checking 1.2.5 Prime no checking 1.2.6 Palindrome Checking 1.2.7 Odd or even number. 1.2.8 Perfect number checking. Lab – 2 (2 Hrs Real Time) 2.1 2.2 2.3 2.4 2.5 Write a program to calculate the following: Find Maximum of N numbers. Find Minimum of N numbers. Find Summation of N numbers. Find Average of N numbers.…

    • 1575 Words
    • 7 Pages
    Good Essays
  • Powerful Essays

    System Programming

    • 30057 Words
    • 121 Pages

    (SIC) - Machine architecture - Data and instruction formats - addressing modes instruction sets - I/O and programming.…

    • 30057 Words
    • 121 Pages
    Powerful Essays
  • Satisfactory Essays

    Ddasd

    • 908 Words
    • 4 Pages

    4.if the clock period of 8085 is 0.2 µs calculate the time required to execute…

    • 908 Words
    • 4 Pages
    Satisfactory Essays
  • Powerful Essays

    Basics of Computer

    • 3726 Words
    • 15 Pages

    The computer performs basically five major operations of functions irrespective of their size and make. These are 1) it…

    • 3726 Words
    • 15 Pages
    Powerful Essays
  • Satisfactory Essays

    mr shravan

    • 881 Words
    • 4 Pages

    equals to the largest digit of your student ID number or N=5 (if the highest digit of your…

    • 881 Words
    • 4 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Java assignments

    • 272 Words
    • 2 Pages

    4. Write a program that prints prime numbers between 1 to n. Number n should be…

    • 272 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    INSTRUCTION: Write TRUE if the statement is correct and FALSE if the statement is incorrect on the space provided before each number.…

    • 824 Words
    • 4 Pages
    Satisfactory Essays
  • Good Essays

    C Program

    • 767 Words
    • 4 Pages

    Directions 1. Some of the questions/programs are required to be typed, complied, run and then observed. 2. If possible try experimenting with concepts revealed by each question. 3. There are 20 objective type questions on ANSI C. PART - A…

    • 767 Words
    • 4 Pages
    Good Essays
  • Satisfactory Essays

    The jobs are assumed to have arrived at time 0 and in the order p, q, r, s, t. Calculate the departure time (completion time) for job p if scheduling used is the Round Robin with time quantum of 1.…

    • 351 Words
    • 2 Pages
    Satisfactory Essays