Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Stub Program for Problem 4 HW 2
// Stub program for Problem 4 HW 2 Fall 2016 #include <stdio.h> #define SIZE 30 #define ERROR -1 ////////////////////////////////////////////////////////////////////// // Function name: int2binstr // // Description: Converts an unsigned integer to a string representing // the binary value of that integer. // // Input parameters: // unsigned int num, the input unsigned integer // // Output parameters: // char* string, the pointer to the output string. // // Returns: // void int2binstr(unsigned int num, char* string) { // Your code goes here! int i; unsigned int mask; for (i=0; i<32; i++) { mask = (1<<(31-i)); if (mask&num) { string[i] = '1'; } else { string[i] = '0'; } } string[32] = 0; } int main(void) { // number that we read in from stdin unsigned int inputNumber; // output array for the string char outputString[SIZE] = "Nothing Yet"; printf("\n*** Stub program for Problem 4 -- int2binstr ***\n\n"); // First read in an integer scanf("%d\n", &inputNumber); // print out the input number printf("Read in the value %d.\n\n", inputNumber); // Call your routine int2binstr(inputNumber, outputString); // Print out the result printf("After function call the string is \"%s\".\n\n", outputString); return 0; }
run
|
edit
|
history
|
help
0
Rudra
Max3
Project 3 part 2 Book v10.2
Star pattern
Part 1: Draw Arts
Project 5 v.01
print_odd_pointer.c
readability!
funcion quicksort
ayudantia ejercicio 2 numero nashee