What is the output of the following program? Show each step to get to the output
#include <stdio.h>
int f(int* a, int* b);
int main() {
int a = 6, b = 7, c = 8;
b = f(&c, &a);
printf("a = %d, b = %d, c = %d\n", a, b, c);
return 0;
}
int f(int* a, int* b) {
*a = *a + *b;
*b = *a - *b;
printf("a = %d, b = %d\n", *a,
*b);
return 3*(*b);
}
b = f(&c, &a); f(8,6) Here the function call is b = f(&c, &a); and the function definition is int f(int* a, int* b) Here, variable c in main represents variable a in function f and variable a in main represents variable b in function f a will be 8 and b will be 6 *a = *a + *b = 8 + 6 = 14 *b = *a - *b = 14 - 6 = 8 Then it prints a = 14, b = 8 and then returns 3*8 = 24 Then main prints a = 8, b = 24, c = 14 So, the output is a = 14, b = 8 a = 8, b = 24, c = 14
What is the output of the following program? Show each step to get to the output #include...
1. What is the output of the following program? include <stdio.h> int wilma (int x) if (x<5) x = 7; return (x) int main (void) int x-1 x=wilma (x) ; printf ("%d", x); return (0) b)3 c) 4 d) 7 a) 1 e) none of these
OPERATING SYSTWM Question 31 What is the output of this C program? #include #include void main() int mptr, *cptr mptr = (int*)malloc(sizeof(int)); printf("%d", "mptr); cptr = (int)calloc(sizeof(int),1); printf("%d","cptr); garbage 0 000 O garbage segmentation fault Question 8 1 pts If this program "Hello" is run from the command line as "Hello 12 3" what is the output? (char '1'is ascii value 49. char '2' is ascii value 50 char'3' is ascii value 51): #include<stdio.h> int main (int argc, char*argv[]) int...
In C language 5. What is the OUTPUT of each of these programs? If you aren't confident of an answer, type mpile and run the program to test it. (a) <stdio.h> #include int main main int count; int sum0; for (count 1; count10; count++) sum sum+ count; for count printf("sum= %d\n", return 0; sum); )main (b) #include int main ) <stdio.h> main/ int count; int sum -0 for (count 1 count10; count 2) sum sum + count; for count print...
C programming problem please help my computer crashed what is the output of each program ? (c) #include <stdio.h> int main() { /* main */ int f3, t = 9; int func3 (int x); printf("Inside main, t = $d\n", t); f3 - func3(t); printf("Inside main, f3 = %d\n", f3); return 0; } /* main */ int func3 (int x) { /* func3 */ printf("Inside func3, X = %d\n", x); return x; } /* func3 */ (d) #include <stdio.h> int main()...
What is the output of the following c program. Why, Can you tell me how do you solve it? #include <stdio.h> int fun(int n) { if(n==0) { return 1; } else return 7 + fun(n-2); } int main() { printf("%d", fun (4)); return 0; | }
What is going to be the output of the following program: # include <stdio.h> int main(void) {struct dob {int month; int day; int year;}; struct student {int sid; int yearOfAdmission; float currentGPA; struct dob bday; struct student stdnt = {123, 2015, 8.3, 11, 26, 1993}; printf(" Id is: %d \n", stdnt.sid); printf("Year of admission is: %d \n", stdnt.year OfAdmission); printf("Current GPA is: %.2f\n\n", stdnt.currentGPA); printf("Date of Birth is: %d/%d/%d", stdnt. bday. month, stdnt. bday.day, stdnt. bday.} return 0;}
Question 8 Predict the output of the following C program: 5 #include <stdio.h> void binaryCode(int n) printf("1"); if(n=2) return; binaryCode(n-1); int i = 0; for(; i<n;i++) printf("O"); binaryCode(n-2); } void main() { binaryCode(3); 12pt v Paragraph Β Ι Ο Avor T²v ...
What is the output of the following code? #include« stdio.h» 2 4 int main() 6 int a=15,b=12,c=5, d-e; 7 printf("the value of d is %d",d); return 0; 8 9 10 Ly 0 29 O 30 0 28 O 31
1 Rewrite the following program so that it will use function. include <stdio.h> Int main) printf ("Hello!") return 0 2 Assume a program has the following declarations: short s- 4 int i--5; long m-3 float f-19.3f; double d-3.6; What are the following values? (a) s+m (b) (float) d (c) d s (e) (int) f 3 What will be the output of the following program: int x = 3 float a 2.76; y-2* x; print f("X-2d, y*ta, z»%d", x, y, z);...
Part D. On executing the below program, what will be the output of the following program if the source file contains a line "This is a sample."? [5 marks] #include <stdio.h> int main() { char ch; int k, n=0; FILE * fs = fopen("source.txt", "r"); while(1) { ch = fgetc(fs); if(ch == EOF) break; else { for(k=0;k<4;k++) fgetc(fs); printf("%c", ch); n += k; } } printf("%d\n", n); fclose(fs); return 0; } ---------------------------------- Any one can explain the question to me...