The file data1 contains: 0 3 6 9 12 The file data2 contains: 10 8 6 4 2 The file
ID: 3724114 • Letter: T
Question
The file data1 contains: 0 3 6 9 12 The file data2 contains: 10 8 6 4 2 The file data3 contains: 20 10 0 20 80 Give the output when run with: /a.out data1 data2 data3 #include int main( int argc, char *argv) What is the output of the C program shown below? #include include int fone (int x, int y) return (y-x) (y-x)) void fTwo (int *a, int *b) int temp = *a; *a*a *b *bb temp return: FILE EpOne fopen (argvl,) FILE fpTwo fopen (argv[2],") FILE EpThree fopen (argv[3), int a, numi, num2, num3, sun1=0, sum2m0 ; for (a=0; aExplanation / Answer
Solution:
first, let me tell you what each function is doing exactly.
so fOne is returning the value of (y-x)^2
and
fTwo is manipulating a to be a+b and b to be a-b
fThree is sending three arguments and it is replacing the second argument with the third one id it is same as the character present in the str which is Alabama
Output:
first a = 3, and b = 5
now fTwo is called
so, now a = 8, and b = 2
8 2 will be printed
fOne(c, d), fOne(e, f) = fOne(fOne(7, 9), fOne(11, 14)) = fOne(4, 9) = 25
Now
25 will be printed
fThree(str, 'a', 'x') => will change Alabama to Alxbxmx
and fThree (str, 'A', 'a')=> will change to alxbxmx
alxbxmx will be printed.
2)
Output:
20
13
0
80
160
3 // this is the value of sum1
12// This is the value of sum2
Explanation:
The program has three files with the name data1, data2, data3, the loop insode the program is accessing all three files with some if conditions
so if num1<num2 the sum of num1 and num 3 will be printed
else the sum of num2 and num3 will be printed
when the condition is true sum1 is keepingtrack of sum of num1
else sum2 is keeping track of sum of num2
I hope this helps if you find any problem. Please comment below. Don't forget to give a thumbs up if you liked it. :)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.