Why is the answer b), for this question? I came up with C) for my incorrect answer. This is under c programming.
a) *p = 5
b) *p = 55
c) *p = 0
d) None of the above
int main ()
int n = 5;
int *p = &n ;
n = 0;
*p = 55;
printf("*p = %d\n", n);
return 0;
Answer:- b) *p = 55 is correct output for this
explanation:-
int n = 5;
int *p = &n ; // here *p hold the address of n
n = 0; //here n is change to 0, but address of n is same
*p = 55; // here it is assigning 55 to the address of n, so the final value of n have 55.
printf("*p = %d\n", n);
Why is the answer b), for this question? I came up with C) for my incorrect...
Please answer the above queston (in terms of C programming) and
explain answer
Semester 2 & Trimester 3B, 2015 COMP1004 Engineering Programming Question 3 - Repetition (20 marks) Q3(a) What will be printed when the following code is executed? (5 marks] #include <stdio.h> int main() int i, j; for(i=1;i<17;i=i+2) { printf("%d==", i); for(j=i; j>0;j--) printf("#"); printf("\n"); return 0; == # 3 = = # # # 5 == ### ## 7 #### #
I have a question on an assignment for C++. I have my code available here and just want someone to look over it using MS VS 2010 express, for that is what my instructor is using. Write a program that mimics a calculator. The program should take as input two integers and the opreation to be performed. It should then output the numbers, the operator, and the result. (For division, if the denominator is zero, output an appropriate message.) //**This...
Hello, I have my piece of C programming code and I have a pointer initialized to point to my array and I need help to display the contents of my array using a while loop or do-while loop. The stop condition should be when the pointer reaches '\0'. The code is below: #include <stdio.h> int main () { char array[80]; printf("Enter a string: "); scanf("%[^\n]", &array); printf("%s\n", array); char * p; p = array; }
I am trying to figure out why my C code is outputting "exited, segmentation fault". The game is supposed to generate 4 random numbers and store them in the "secret" array. Then the user is suppose to guess the secret code. The program also calculates the score of the user's guess. For now, I printed out the random secret code that has been generated, but when the game continues, it will output "exited, segmentation fault". Also, the GetSecretCode function has...
Incorrect Question 12 0/4 pts What of the following are true for the following piece of code? int main() int a[ ] = { 2, 4, 6, 8, 10 } int i; change ( a, 5); for (i = 0; i <= 4; i++) printf("\n%d", a[i]); return 0; void change ( int *b, int n) int i; for (i - @;i<n; i++) this line void change(int *b, int n) has an error. We must have to use int b[] as...
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()...
c/c++
This is a simple debugging question. The program (as written) tries to add up the elements of two arrays and store the results into a third array. The idea is that every element of the third array equals the sum of the two corresponding (i.e same index or position in the array) elements in the first two arrays. There is a syntax error, because the way it is written is not the correct way to do it. You are...
any help! my program not working , there is an error but cannot
solve it
i did this program after editing a previous
program and i tried to follow the following ;
1. Instead of printing the prime numbers from 2 to n, your
program will print the first n prime numbers.
2. It will be an error if n is less than 1.
Exampl:
$ ./a 1
2
3 #include<stdio.h> 4 int p; // p is the global variable. 5...
10 What does the last printf in this code print to the screen? a)n-7 b)n- 0 c)n--1 d) None of the above 鬐include< stdio. h> int main) int n-0 for (n-7: n<O; n-- printf (n") printf ("n *%d", n); - return 11-What does the code print to the screen? 鬐include< stdio.h> void fun (int) int main) b) 8 d) None of the above fun (3) return void fun (int a) int x-10 while(a !_ 3 x > s} if a...
Original question is above, and is for C programming. As you
will see in my code below, I am not sure how to properly implement
the functions I made for g(x) and h(x) (I call them g_x and h_x)
into my function called trap. I know that in my main function in my
function call to trap, I have to put something in the parentheses
of g_x() and h_x() since they both take a type double argument,
however I'm not...