Question

In: Computer Science

Explain the following code using comments next to the code: void foo() { uint8_t a=2; uint8_t...

Explain the following code using comments next to the code:

void foo() {
uint8_t a=2;
uint8_t b[]={b0, b1, b2}; // They are the last three digits of your A#
uint8_t* c=b;
uint8_t* d=&a;

Solutions

Expert Solution


#include <stdio.h>
#include <stdint.h>

int main() {
        
        uint8_t a;
        for(int i=0;i<300;i++){
                a=i;
                printf("%d \n",a);
        }
    return 0;
}

1
2
3
4
5
...
252
253
254
255
0
1
2
3
...



void foo(){  // foo() is a function of type void. It does not return anything
        uint8_t a=2;   // a is a varible of 8 bit unsigned integer type
        
        uint8_t b[]={b0, b1, b2}; // b[] is an 8 bit unsigned integer type array which 
                                  //currently stores three 8 bit unsigned integer value 
                                  // of the elements b0, b1, b2
        
        uint8_t* c=b;            // c is an 8 bit unsigned integer type pointer to array b[]
                                 // initially c points to base address of b[] i.e. b[0]
                                 
                                 
        uint8_t* d=&a;           // d is an 8 bit unsigned integer type pointer 
                                // it stores the address of a 
}

___________________________________________________________________


Note: If you have queries or confusion regarding this question, please leave a comment. I would be happy to help you. If you find it to be useful, please upvote.


Related Solutions

Your task is to take the below code, and insert comments (using the “%” symbol) next...
Your task is to take the below code, and insert comments (using the “%” symbol) next to each line of code to make sure that you know what every line does. clc clear close all NMax = 100; partialSum = 0; exactAnswer = pi^2; for k=1:NMax partialSum = partialSum + 6/k^2; percentDiff(k) = abs(partialSum - exactAnswer)/exactAnswer*100; end NVector = [1:NMax]; plot(NVector,percentDiff); xlabel('{{Noob}}'); ylabel('% Difference');
Your task is to take the above code, and insert comments (using the “%” symbol) next...
Your task is to take the above code, and insert comments (using the “%” symbol) next to each line of code to make sure that you know what every line does. close all; clear all; clc; thetaAB = 0; angleIncrement = 0.1; numOfLoops = 360/angleIncrement; thetaABVector = [angleIncrement:angleIncrement:360]; rAB = 5; rBC = 8; for i=1:numOfLoops bothResults = SliderCrankPosn(rAB,rBC,thetaAB); rAC(i) = bothResults(1); thetaBC(i) = bothResults(2); thetaAB = thetaAB+angleIncrement; end subplot(2,1,1) plot(thetaABVector,thetaBC,'Linewidth',3); xlabel('\theta_{AB} [degrees]'); ylabel('\theta_{BC} [degrees]'); xlim([0 360]); ylim([300 400]); grid...
#python. Explain code script of each part using comments for the reader. The code script must...
#python. Explain code script of each part using comments for the reader. The code script must work without any errors or bugs. Ball moves in a 2D coordinate system beginning from the original point (0,0). The ball can move upwards, downwards, left and right using x and y coordinates. Code must ask the user for the destination (x2, y2) coordinate point by using the input x2 and y2 and the known current location, code can use the euclidean distance formula...
Understand the code and explain the code and answer the questions. Type your answers as comments....
Understand the code and explain the code and answer the questions. Type your answers as comments. #include #include using namespace std; // what is Color_Size and why it is at the end? enum Color {        Red, Yellow, Green, Color_Size }; // what is Node *next and why it is there? struct Node {        Color color;        Node *next; }; // explain the code below void addNode(Node* &first, Node* &last, const Color &c) {        if (first == NULL)...
JAVA CODE, BEGINERS; Please use comments to explain For all of the following words, if you...
JAVA CODE, BEGINERS; Please use comments to explain For all of the following words, if you move the first letter to the end of the word, and then spell the result backwards, you will get the original word: banana dresser grammar potato revive uneven assess Write a program that reads a word and determines whether it has this property. Continue reading and testing words until you encounter the word quit. Treat uppercase letters as lowercase letters.
**Add comments to existing ARM code to explain steps** Question that my code answers: Write an...
**Add comments to existing ARM code to explain steps** Question that my code answers: Write an ARM assembly program to calculate the value of the following function: f(y) = 3y^2 – 2y + 10 when y = 3. My Code below, that needs comments added: FunSolve.s LDR R6,=y LDR R1,[R6] MOV R2,#5 MOV R3,#6 MUL R4,R1,R1 MUL R4,R4,R2 MUL R5,R1,R3 SUB R4,R4,R5 ADD R4,R4,#8 st B st y DCD 3
Source code with comments explaining your code in C# Program 2: Buh-RING IT! For this assignment,...
Source code with comments explaining your code in C# Program 2: Buh-RING IT! For this assignment, you’re going to simulate a text-based Role-Playing Game (RPG). Design (pseudocode) and implement (source) for a program that reads in 1) the hero’s Hit Points (HP – or health), 2) the maximum damage the hero does per attack, 3) the monster’s HP and 4) the maximum monster’s damage per attack. When the player attacks, it will pick a random number between 0 and the...
Given the following Java code: class C { public int foo(C p) { return 1; }...
Given the following Java code: class C { public int foo(C p) { return 1; } } class D extends C { public int foo(C p) { return 2; } public int foo(D p) { return 3; } } C p = new C(); C q = new D(); D r = new D(); int i = p.foo(r); int j = q.foo(q); int k = q.foo(r); (Remember that in Java every object is accessed through a pointer and that methods...
Task 2/2: Java program Based upon the following code: public class Main {   public static void...
Task 2/2: Java program Based upon the following code: public class Main {   public static void main( String[] args ) {     String alphabet = "ABCDEFGHIJKLMNMLKJIHGFEDCBA";     for( <TODO> ; <TODO> ; <TODO> ) {       <TODO>;     } // Closing for loop   } // Closing main() } // Closing class main() Write an appropriate loop definition and in-loop behavior to determine if the alphabet string is a palindrome or not. A palindrome is defined as a string (or more generally, a token) which...
write the code in MATLAB with comments and show the inputs and results of the code...
write the code in MATLAB with comments and show the inputs and results of the code for the question below. Write an .m file in MATLAB, that records audio (you can record your own voice for 20 seconds that was recorded using your phone), then take Fourier transform of the signal (probably FFT).
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT