Question

How do i finish this code: #include <stdio.h> int main() { long long decimal, tempDecimal, binary;...

How do i finish this code:

#include <stdio.h>

int main()
{
  long long decimal, tempDecimal, binary;
  int reminder, weight = 1;
  binary = 0.0;

  //Input decimal number from user
  printf("Enter any decimal number: ");
  scanf("%lld", &decimal);
  
  // Since we do not want change the value of decimal in the code
  // let us use tempDecimal to store the value of decimal
  tempDecimal = decimal;

  printf("\n\n");

  // Let us use while loop first to implement
  printf("while loop part:\n");
  
  
  
  /**************START FROM HERE *******************
    Please write you code here. 
    Nore more than 4 lines of the body of the while.
    Don't forget to write the codition.
  */
  while(  )
  {




  }
  //*************STOP UNTIL HERE*******************
  
  
  
  printf("Decimal number = %lld\n", decimal);
  printf("Binary number = %lld\n", binary);

  printf("\n\n");
  
  // Let us try do ... while loop to implement
  printf("do ... while loop part:\n");
  tempDecimal = decimal;
  binary = 0.0;
  weight = 1;



  /**************START FROM HERE *******************
  Please write you code here. 
  Nore more than 4 lines of the body of the while.
  Don't forget to write the codition.
  */
  do
  {
   



  }while();
  //*************STOP UNTIL HERE*******************

  printf("Decimal number = %lld\n", decimal);
  printf("Binary number = %lld\n", binary);

  return 0;
}
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Coding

#include <stdio.h>
int main()
{
long long decimal, tempDecimal, binary;
int reminder, weight = 1;
binary = 0.0;
//Input decimal number from user
printf("Enter any decimal number: ");
scanf("%lld", &decimal);
// Since we do not want change the value of decimal in the code
// let us use tempDecimal to store the value of decimal
tempDecimal = decimal;
printf("\n\n");
// Let us use while loop first to implement
printf("while loop part:\n");
/**************START FROM HERE *******************
Please write you code here.
Nore more than 4 lines of the body of the while.
Don't forget to write the codition.
*/
while(tempDecimal!=0)//here we put condition
{
   printf("Value of temporary Decimal is %d \n",tempDecimal);//here is print temp decimal value and increment it
   tempDecimal=tempDecimal+10;//increment temp variable here
}

//*************STOP UNTIL HERE*******************

printf("\n\nDecimal number = %lld\n", decimal);//display output
printf("Binary number = %lld\n", binary);//display output here

printf("\n\n");

// Let us try do ... while loop to implement
printf("do ... while loop part:\n");
tempDecimal = decimal;
binary = 0.0;
weight = 1;

/**************START FROM HERE *******************
Please write you code here.
Nore more than 4 lines of the body of the while.
Don't forget to write the codition.
*/
printf("Here is Binary ::");
do
{
reminder=tempDecimal%2;
tempDecimal=tempDecimal/2;
printf("%d ",reminder);//output display here
}while(tempDecimal>0);//here tempDecimal condition
//*************STOP UNTIL HERE*******************

printf("Decimal number = %lld\n", decimal);
printf("Binary number = %lld\n", binary);

getch();
}

output:

if you still have any Problem regarding this question please comment and if you like my code please appreciate me by thumbs up thank you.........

Add a comment
Know the answer?
Add Answer to:
How do i finish this code: #include <stdio.h> int main() { long long decimal, tempDecimal, binary;...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • #include<stdio.h> #include<stdlib.h> #include <time.h> int main() { /* first you have to let the computer generate...

    #include<stdio.h> #include<stdlib.h> #include <time.h> int main() { /* first you have to let the computer generate a random number. Then it has to declare how many tries the user has for the game loop. we then need the player to enter their guess. After every guess we have to give an output of how many numbers they have in the right location and how many they have the right number. The player will keep guessing until their 10 tries are...

  • #include <stdio.h> #include<string.h> int main() { char strText[100] ="Start"; char i; int nTextASCIISum = strText[0] +...

    #include <stdio.h> #include<string.h> int main() { char strText[100] ="Start"; char i; int nTextASCIISum = strText[0] + strText[1] + strText[2]; int nTextLen = strlen(strText); int count = 0; printf("Welcome to token generator!\n"); printf("Enter a word to use in the token generator.\n You may enter as many words as you like. \n Press q and key when finished.\n"); scanf("%c", &strText[i]); //compute when to stop loop //check nTextLen == 1 and strText[0] == 'q' for(i=0;i< nTextLen;i++) if ((strlen(strText) != 1) || (strText[0] !=...

  • Do you have a flowgorithim flow chart for this code? #include <stdio.h> int main() { int num,i=0,sum=0; float aver...

    Do you have a flowgorithim flow chart for this code? #include <stdio.h> int main() { int num,i=0,sum=0; float average; int customerNumbers[num]; int customerSales[num]; printf("How many customers do you want to track?\n"); scanf("%d",&num); while(i<num) { printf("Enter the customer number. "); scanf("%d",&customerNumbers[i]); printf("Enter the sales for the customer "); scanf("%d",&customerSales[i]); i++; } printf("Sales for the Customer"); printf("\nCustomer Customer"); printf("\nNumber Sales"); for(i=0;i<num;i++) { printf("\n %d \t %d",customerNumbers[i], customerSales[i]); sum=sum+customerSales[i]; } average=(int)sum/num; printf("\n Total sales are $%d",sum); printf("\n Average sales are $%.2f",average); printf("\n --------------------------------------------");...

  • i need flowchart for the following c code #include <stdio.h> int main() {     int n,...

    i need flowchart for the following c code #include <stdio.h> int main() {     int n, i, sum = 0;     printf("Enter an integer: ");     scanf("%d",&n);     i = 1;     while ( i <=n )     {         sum += i;         ++i;     }     printf("Sum = %d",sum);     return 0; }

  • #include <stdio.h> #include <string.h> #include <ctype.h> #include <stdlib.h> int main(void) { /* Type your code here....

    #include <stdio.h> #include <string.h> #include <ctype.h> #include <stdlib.h> int main(void) { /* Type your code here. */ int GetNumOfNonWSCharacters(const char usrStr[]) { int length; int i; int count = 0; char c; length=strlen(usrStr); for (i = 0; i < length; i++) { c=usrStr[i]; if ( c!=' ' ) { count++; } }    return count; } int GetNumOfWords(const char usrStr[]) { int counted = 0; // result // state: const char* it = usrStr; int inword = 0; do switch(*it)...

  • #include<stdio.h> int main() {       int data[10], i, j, temp;       printf("Enter 10 random number to...

    #include<stdio.h> int main() {       int data[10], i, j, temp;       printf("Enter 10 random number to sort in ascending order:\n");       for(i = 0; i < 10; i++)             scanf("%d", &data[i]);       /* Sorting process start */     ****** INSERT YOUR CODE TO COMPLETE THE PROGRAM ******       printf("After sort\n");       for(i = 0; i < 10; i++)             printf("%d\n",data[i]);       return 0; } Looking for alternative solutions for the program code.

  • In C Code provided: #include <stdio.h> int recursive_sequence(int n) { //type your code here } int...

    In C Code provided: #include <stdio.h> int recursive_sequence(int n) { //type your code here } int main() { int number; scanf("%d", &number); printf("recursive_sequence(%d) = %d",number, recursive_sequence(number)); return 0; } The nth term in a sequence of numbers called recursive_sequence can be defined as follows: • recursive_sequence(0) = 0 • recursive_sequence(1) = 1 If n is greater than 1, then recursive_sequence(n) = 2* recursive_sequence(n - 2) + recursive_sequence(n-1) The first 6 terms in this sequence are: 0,1, 1, 3, 5, 11...

  • Given the following pseudo code: int result; (result is 1 byte) int count; (count is 1...

    Given the following pseudo code: int result; (result is 1 byte) int count; (count is 1 byte) for (result= 10, count= -10; count < result ; count++) { if(count > 2) result--; else result ++; } 1) write an assembly language program that will implement this pseudo code using a while construct. 2) write an assembly language program that will implement this pseudo code using a do-until construct Note: For both 1) and 2), do not forget to include the...

  • sort.c #include <stdlib.h> #include <stdio.h> #include "libsort.h" int main() {     int* array;     int size,...

    sort.c #include <stdlib.h> #include <stdio.h> #include "libsort.h" int main() {     int* array;     int size, c;     float median;     printf("Enter the array size:\n");     scanf("%d", &size);     array = (int*) malloc(size * sizeof(int));     printf("Enter %d integers:\n", size);     for (c = 0; c < size; c++)         scanf("%d", &array[c]);     sort(array, size);     printf("Array sorted in ascending order:\n");     for (c = 0; c < size; c++)         printf("%d ", array[c]);     printf("\n");     median = find_median(array,...

  • lab3RGB.c file: #include <stdio.h> #define AlphaValue 100 int main() { int r, g,b; unsigned int rgb_pack...

    lab3RGB.c file: #include <stdio.h> #define AlphaValue 100 int main() { int r, g,b; unsigned int rgb_pack; int r_unpack, g_unpack,b_unpack; int alpha = AlphaValue; printf("enter R value (0~255): "); scanf("%d",&r); printf("enter G value (0~255): "); scanf("%d",&g); printf("enter B value (0~255): "); scanf("%d",&b); while(! (r<0 || g<0 || b <0) ) { printf("A: %d\t", alpha); printBinary(alpha); printf("\n"); printf("R: %d\t", r); printBinary(r); printf("\n"); printf("G: %d\t", g); printBinary(g); printf("\n"); printf("B: %d\t", b); printBinary(b); printf("\n"); /* do the packing */ //printf("\nPacked: value %d\t", rgb_pack); printBinary(rgb_pack);printf("\n");...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT