CEng 2xx Laboratory System
User Manual


Introduction

2xx Laboratory system is an integrated environment for on-line quiz, program development and evaluation. During the laboratories you will have  short exams measuring your knowledge and skills about programming. This system provides automatic execution of such examinations.

There are two basic parts of a laboratory session: (1) quiz, and (2) programming problem. In the quiz part you  will take some multiple choice questions about the course. You will have a limited time and you should carefully answer the questions since wrong answers will cancel  some portion of the correct answers as it is in most multiple choice tests.

After finishing the quiz part, you will be given a programming problem like “write a program to input ..., calculate and output ...”. In the remaining part of the laboratory session you will write a computer program described in the problem definition. A compiler environment is provided in the system. After you complete your program, you can test if your program is working correctly by choosing a menu option. After you are satisfied with the grade you are to take, you can finish the laboratory by finalizing your work.

This document describes the user interface and the steps that you should take during the laboratory.

Logging in

You are authenticated by a user name and password pair in the laboratories. Your grading and attendance are based on this authentication information. At the beginning of the laboratory, you will see the following window on your computers screen:


 

 

You should write your user identifier and password in the corresponding fields and press the Login button. You will take your login information from the lab assistants in your  first laboratory  session.

If you take a login failure message after you try and you are sure that you entered  it correctly, ask help from your assistant.

Quiz

After you login, you will see the quiz screen as:

 


 

These quiz questions will be about the topic of the current week of laboratories. You will choose among the a,b,c,d,e options on the “Answer:” menu following each question. If you do not know the answer of the question, you can choose “Blank” in order to leave the question empty so that you will not loose any points from a wrong answer.

Time is limited in quiz part so watch the clock at the bottom which will show how many seconds you have left. When your time is up all your  answers will be with their current state. After you finished with the questions you can press the button “I'm done, I want to learn my quiz grade” at the top of the window. This will take you to the second part, programming.

 

Programming and Development Environment

 

Program development environment screen will look like:

 

At the top, there exists a  menu bar with options “Lab topic”, “Question” etc. Below the menu bar there is  a message area containing explanations about the laboratory topic of the week and question of the week. Below there is an program editing area that you will write your programs in. At the very bottom, there is a message line containing useful messages like the line and colon number of the cursor.

Programming Question

As default, “Lab Topic” is displayed in the message area. This gives you a summary of the topics covered in current laboratory week. You can press the “Question” button in the menu bar to see the programming question of the week in the message area. After you press, you will see:

 


The programming problem, its input and output requirements will be described in the message area. Your task is to write a complete program in the editing window to fulfill this description.

You can switch the text in the message area by pressing any of the “Lab Topic” and “Question” buttons.

Compiling your program

After reading laboratory topic and question text carefully you can start writing your program. Make sure that you are writing a full and syntactically correct program. For example you should include standard IO header file and put a correct “main()” function body in a C program.

When your program is ready to compile, press “Compile” button to compile it. Your computer will compile the file in the editing area and report you the compilation result in the message area. If it is successful you can go on testing your program by running it. However in the first trial probably your program will fail to compile because of compilation errors. Do not worry about it. Compiler provide the line of the error and other useful information in the message area. Go there, find and correct your errors. A detailed description of the compilation errors and possible correction strategies are given in the appendix.

Running your program

When your program compiles successfully, it is ready to be tested. So run it by clicking on “Run” button in the menu bar. You will see a window popping up as:

 


 

This window include three partitions: (1) output, (2) input, and input line. Output part will list all lines that you output for example by a printf(...) call. Similarly all lines that you give as input are listed in the input part. When your program requires input, for example scanf(...) is called, you can fill in the input line at the bottom of the window and it is provided as input to your program. You can finish executing your program and close this window by clicking on the “Close” button.

During this test, try possible cases of the problem and observe the reaction of your program. This information is very important while you are tracking your algorithmic mistakes. When you think your program is ready, you can evaluate it.

 

Evaluating Your Program

When you press the “Evaluate” button, your program goes under an automatic evaluation process so that you will see the point that you will take if you finalize it:


message area displays the point that you would take if you finalize it. If it is satisfactory you can go on finalizing. Otherwise turn back to your program, try to find your mistakes, correct, compile, run and evaluate it again.

It is not a good practice to evaluate your program to often. You loose to much time and after some time you will be dealing with irrelevant small mistakes and fail to see your mistakes in the greater picture. So test your programs by running them and giving inputs of different cases. This is a better way of learning the programming language.

Finalizing Your Program

After you get a satisfactory point, press “I'm done, I want to learn my progamming grade”. This will end up your session and you will not be able return back to your program. So this is the very last thing you should do at the end of the laboratory. You will see the following pop-up window:

 


You should call your laboratory assistant to approve your finish. If you do not follow the specifications (for example, do not write a function although it is required), or if s/he suspects that you cheated, s/he will reject to finalize your work.  Otherwise you will see your programming grade as follows:

 


Congratulations, the laboratory is over for you.  You can leave the laboratory.

 

Conclusions and Important Tips

 

This laboratory system is designed to make on-computer examinations. So do not rely on the idea “I will learn and do something even if I attend laboratory without any preliminary work”. You have to study the laboratory topic and  make some on-computer experiments before attending the laboratory. So that you can learn something on laboratories. Do not forget that the experimenting in a real environment is the key point in programming language learning.

During the laboratory try to form good test data. When a problem is defined, all possible ranges and cases of input is given. You should write a program to cover all these cases. So  try to cover all possibilities in your test input.

 

Appendix (Common Errors)

Programming languages are formal languages and they have very strict syntax rules. One of the most time consuming task in laboratories is the detection and correction of syntax errors. It is always easier not to make errors instead of collecting lots of tiny errors. Actually people make similar mistakes. So please follow these simple rules for the C programming language:

1.Make sure that you include all header files you need. #include<stdio.h> line is required for input/output functions and #include<math.h> line is required for all mathematical functions.

2.Make sure that all executable statements are separated by a semi-colon ';' even if they are in different lines.

3.Close all matching parenthesis, brackets and curly braces '( ), [ ], { }'. They all should have corresponding matches and they should be properly nested.

4.Do not forget to start and terminate all string literals with a double quote (). Single quote is just for char constants and encloses exactly one  symbol. Do not forget to close any such quotes.

5.Do not forget to declare variables that you will be using. All declarations should precede any executable statement. So you will have a declaration part. When all declarations finish the executables should follow.

C is only tolerant to layout of your source. So as long as you follow the syntax rules you can write a C program in a single line. But this is not a good practice. Proper indentation is an important tool for you to understand and develop your problem easily. Write every statement in a separate line and indent inner blocks in the same level.

Although compiler is not tolerant to errors, it provides useful information when reporting the syntax errors.  You will see something like:

e1036745.c: In function
'main':
e1036745.c:4: Parse error before 'if'
This second line reports filename, line number and the exact place and explanation of the error. So this error is at the 4th line and before the word if. At the bottom of the development environment you will see which number your cursor is on. So you can easily go to the position of your error.

The following is a list of common errors and how they can be detected-corrected.

  1. C program is:
    #include<stdio.h>
    int main() {
      scanf("%d", &x);
      printf("%d",x*2);
      return 0;
    }
    
    You will get this error:
    te.c: In function `main':
    te.c:3: `x' undeclared (first use in this function)
    te.c:3: (Each undeclared identifier is reported only once
    
    You have used a variable called x but have not declared it. So insert a line:
    int x;
    at the 3rd line position, so that x is declared and you can use it.

  2. C program is:
    #include<stdio.h>
    int x;
    scanf("%d", &x);
    printf("%d",x*2);
    return 0;
    
    You will get the following error:
    te.c:3: parse error before string constant
    te.c:3: warning: data definition has no type or storage class
    te.c:4: parse error before string constant
    te.c:4: warning: data definition has no type or storage class
    
    In this program a main() function is not defined. Compiler expects to have your declarations out of the main() function but there are executable statement. So you have to put a int main() { line as the 2nd line and add a closing } at the end of the program.

  3. C program is:
    
    #include<stdio.h>
    int main() {
      int x;
    scanf("%d, &x); printf("%>d",x*2); return 0; }
    You will get the following error:
    te.c:5: unterminated string or character constant
    te.c:4: possible real start of unterminated constant
    
    In this program second quote symbol inside of the scanf() at line 4 is forgotten. So C considers all text up to the next quote symbol (5th line, after printf) as the first parameter of scanf() and than realizes that something is wrong. Try to find the opening quote position and close it in its appropriate place.

  4. C program is:
    #include<stdio.h>
    int main() {
      int x;
      scanf("%d",&x);
      if (x<0) {
        printf("%d",x*2);
      } 
      else {
        printf("%d",x+2);
     return 0;
    }
    
    You will get:
    te.c:11: parse error at end of input
    
    That is because you forget to close the curly brace block opened at line 7 (after else). Compiler considers all lines until the last line as the part of the else block and closes the else block with the } at the last line. Then it cannot match the { at the 2nd line (int main() { ..). Close the curly brace in its appropriate position ( after line 8).

  5. C program is:
    #include<stdio.h>
    int main() {
      int x;
      scanf("%d", &x);
      if (x<0) {
        printf("%d",x*2);
      } 
      else 
        printf("%d",x+2);
      }
      return 0;
    }
    
    You will get:
    te.c:10: parse error before `return'
    
    If you look at the 10th line, before the return. You will see the } as the preceding item. There is no corresponding { for this curly brace. So you should remove it or find the corresponding curly brace position and put it.

  6. C program is:
    #include<stdio.h>
    int main() {
      int x;
      scanf("%d", &x);
      if x<0 {
        printf("%d",x*2);
      }
      else { 
          printf("%d",x+2);
       }
     return 0;
    }
    
    You will get:
    te.c:5: parse error before `x'
    
    At line 5, before x there is an if statement. Parenthesis should enclose the expression after the if statement. So you should convert it to if (x<0) {.

  7. C program is:
    #include<stdio.h>
    int main() {
      int x;
      scanf("%d", x);
      if (x<0) {
        printf("%d",x*2);
      } else { 
        printf("%d",x+2);
      }
      return 0;
    }
    
    You do not get any syntax error. But your program behaves strangely or reports a segmentation fault when you run it. You have forgotten the & symbol preceding x in the 4th line. Compiler cannot detect this error but at run time scanf fails to input the value of x  (if not segmentation fault it puts your value in a strange place in the memory, not in x). So it is a worse error than a syntax error. Be careful in input of primitive values.

  8. C program is:
    #include<stdio.h>
    int main() {
      int x;
      scanf('%d',&x);
      printf('%d',x*2);
     return 0;
    }
    
    You will get:
    te.c:4: warning: multi-character character constant
    te.c:4: warning: passing arg 1 of `scanf' makes pointer from integer without a cast 
    
    Because you have used single quote instead of double quotes. Although your program succeed to compile, these warnings are important and your program will not work properly. So take warnings seriously.