Lab Tips
Using End of file marker in C. Try:
while(!feof(stdin))
Just look at the pseudocode that has been provided for you as a help for solving Lab 7 assignment.
If you think your ideas are better than mine, go ahead. and do that.
Note:- In the code below I have done thw hole thing in a single file whereas you are expected to do it in seperate files. Do not forget to do that, because that contains a substantial %age of points.
An enumeration is a data-type, where the members are constants thar are written as identifiers, though they have signed integer values. These constants represents values that can be assigned to corresponding enumeration variables. So, a enum definition look like
typedef enum {member1, member2, . . . , member m} var_name;
An example can be
A variation to this can be
Now I can use the above example in a piece of my code
Now if I have the prototype of the get_value function as int get_value(); then based upon what the function is returning I can switch. If it is returning 0, I print black and if it prints 1 then blue and for everything else prints others.
I hope that helped :)
If you are confused about call by reference, then looking at the following small example may help. In this problem, we will swap 2 numbers in a function and print them from main. Thus we will be requiring call by reference since we are not able to return two values from the function.
The code is not proper commented. Comment your code properly
If you follow the directions provided in the problem definition, you will probably be able to solve the problem. The structure of your program should be more or less like this.
Moreover if you are using math.h in your code, you should have the (-lm) part in your makefile
lab3: lab8.o
gcc -lm -o lab3 lab3.o
lab3.o: lab3.c
gcc -c lab3.c
Most of the students who attended the lab completed the assignment. Further if you need help contact me during my office hours. The input and out in C is done by the respective statements
scanf("%d %f", &a, &b); //input where a is an integer (%d) and b is a float (%f)
printf("The output is %d and %.2f.", a, b); //out will be The output is 5 and 6.07.
Moreover in C you have to declare the variables at the beginning of the program.
References :-
3. Program Solving & Program Design in C by Hanly Koffman
4. Wikipedia
5. Schaum's Outline of Programming with C by Byron Gottfried (Enum example)