Skip to content
Snippets Groups Projects
Commit 7f4b44a6 authored by RIZKALLAH ROUBA's avatar RIZKALLAH ROUBA
Browse files

Task1 done, Task3 work in progress

parent 5a04d6b1
Branches
No related merge requests found
Compilation commad: gcc T1.c -o T1
Final Output:
Search for target 5
could not find target
Search for target 1
target has been found 1000
Output report:
In all three cases the program takes an input array that is : 5 9 1 2 3.
In cases 1 and 3 the array is sorted in the ascendant order with an output being 1 2 3 5 9.
Whereas in case 2 the array is sorted in the descending order with an output being: 9 5 3 2 1
When compiling L1 the -c option says not to run the linker to get object files as output.
Assembling and Linking
......@@ -7,4 +7,6 @@ L2:
L3:
gcc -o t3_case3.o T3.c l1.c
clean:
rm *.o
\ No newline at end of file
rm *.o
ex1/T1 0 → 100755
File added
#include<stdlib.h>
#include<stdio.h>
int get_frequency(int *, int, int);
void display_results(int param1);
int get_frequency(int * in, int size, int target){
int counter=0;
for( int i=0; i<size; i++){
if(in[i]==target){
counter++;
}
}
return counter==0?-1:counter;
}
void display_results(int param1){
switch(param1){
case -1:
printf("could not find target\n");
break;
default:
printf("target has been found %d\n", param1);
}
}
int main(int argc, char *argv[]){
int total_size=1000;
......@@ -29,15 +48,5 @@ int main(int argc, char *argv[]){
return 0;
}
int get_frequency(int * in, int size, int target){
// TODO implement get_get_frequency here
}
void display_results(int param1){
switch(param1){
case -1:
printf("could not find target\n");
break;
default:
printf("target has been found %d\n", param1);
}
}
ex1/g 0 → 100644
File added
No preview for this file type
File added
File added
File added
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment