C Programming: Simulate Program to Calculate xxx(17)

In summary, C programming is a high-level language used for developing system software, embedded systems, and applications. It allows for low-level manipulation of computer memory and hardware. Simulating a program in C means creating a virtual representation of a real-world process or system. To calculate a value, mathematical operations and functions are used. The "xxx(17)" in a program is a placeholder for a specific calculation. C programming can be used for various tasks, including writing operating systems and developing games.
  • #1
Maybe_Memorie
353
0

Homework Statement



Simulate the following program

#include <stdio.h>

int xxx (int n)
{
int count;

count = 0;

while ( n >=2)
{
n = n/2;
++count;
}

return count;
}

main()
{
printf( "xxx(17)=%d\n", xxx(17) );
}

Homework Equations





The Attempt at a Solution



Is this correct?

n, count
17 0
8 1
4 2
2 3
1 4

Return 4, 4 gets printed
 
Physics news on Phys.org
  • #2
Looks right.
 

1. What is C programming?

C programming is a high-level programming language that is commonly used for developing system software, embedded systems, and applications. It is a powerful and efficient language that allows for low-level manipulation of computer memory and hardware.

2. What does it mean to "simulate a program" in C programming?

In C programming, simulating a program means using the language to create a virtual representation of a real-world process or system. This can be done by writing code that mimics the steps and logic involved in the process, allowing for testing and analysis without actually executing the program on a physical system.

3. How do you calculate a value using C programming?

To calculate a value in C programming, you would use a series of mathematical operations and functions to manipulate data and variables. This can include addition, subtraction, multiplication, division, and more complex operations such as exponentiation and square root.

4. What is the purpose of the "xxx(17)" in this program?

The "xxx(17)" in this program is most likely a placeholder for a specific calculation to be performed. It could represent a function, variable, or specific value that is used in the program's logic to calculate a desired result.

5. Can C programming be used for more than just calculations?

Yes, C programming is a versatile language that can be used for a wide range of applications, including writing operating systems, developing complex software, and creating games. While it is commonly used for calculations and low-level operations, it can also be used for higher-level programming tasks.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
4
Views
914
  • Engineering and Comp Sci Homework Help
Replies
12
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
7
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
3
Views
739
  • Engineering and Comp Sci Homework Help
Replies
19
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
3
Views
656
  • Engineering and Comp Sci Homework Help
Replies
12
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
22
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
3
Views
867
Back
Top