1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
r-ruslan [8.4K]
3 years ago
10

Write a C program to store each element of an array ad[] of size 8 into a single variable named data. Each element of the array

holds either a 0 or a 1. Element zero of the array should be bit zero of data, element 1 of the array should be bit 1 of data, etc. For example, if the array is:
Computers and Technology
1 answer:
levacccp [35]3 years ago
5 0

Answer:

The program in C is as follows:

#include <stdio.h>

int main(){

   char data[50];

   int ad [8];

int i;

for (i = 0; i < 8; i++) {  scanf("%d", &ad[i]);  }

   int j = 0;    

   for (i = 7; i >= 0; i--) {

       sprintf(&data[j], "%d", ad[i]);

       j++;

   }

printf("%s",data);

   return 0;

}

Explanation:

This declares data as a string

   char data[50];

This declares ad as an integer array

   int ad [8];

This declares i as a counter variable

int i;

This iterates from 0 to 7 to get input for each element of integer array ad

<em> for (i = 0; i < 8; i++) {  scanf("%d", &ad[i]);  }</em>

This declares and initializes j to 0, as a counter variable

   int j = 0;    

This iterates through array ad, backwards and appends each element to variable data

<em>    for (i = 7; i >= 0; i--) {</em>

<em>        sprintf(&data[j], "%d", ad[i]); </em>

<em>        j++;     }</em>

This prints data

printf("%s",data);

You might be interested in
How many bits are used to direct traffic to specific services running on a networked computer?
Mars2501 [29]

Answer:

The correct answer is 16 bit.

Explanation:  

The main role of the transport layer provided the communication channel of the process which are running in a different host. When the information flows there is always traffic that is arisen but the transport layer aimed is that process will go at the correct node and received at the proper destination. The 16-bit number specifies that the process or node is running in the networked traffic.

3 0
3 years ago
Dave has to create animations for a game. Which tool can Dave use?
Shtirlitz [24]
What are your answer choices?
8 0
2 years ago
Assume the following instruction mix for some program:______.
m_a_m_a [10]

Answer:

the answer is fart

Explanation:

5 0
3 years ago
Select the correct answer.
SpyIntel [72]

Answer:

i think real time fluid dynamics

Explanation:

3 0
2 years ago
Which of the following applications can be used as a data source for a Microsoft® Word® mail merge? A.Outlook Contacts B.Microso
Xelga [282]
<span>Word can pull data from a variety of data sources to perform a mail merge. As part of the Microsoft Office suite, Word easily accepts data from Outlook, Excel, and Access, and other data sources such as web pages, OpenDocument text files, and delimited data files stored as plain text. And if you don't have an existing data source, you can create a new one in Word.
ALL OF THE ABOVE

</span>
8 0
3 years ago
Read 2 more answers
Other questions:
  • A Color class has three int color component instance variables: red, green, and blue. Write a toString method for this class. It
    13·1 answer
  • Which statement best represents the denotation for the word “woman”? A woman is an adult human female. Both man and woman are re
    11·2 answers
  • Mr. Perry has bookmarked a large number of webpages in Chrome while researching class topics. Unfortunately, he's bookmarked so
    13·1 answer
  • Assuming you have a TCF free student checking account, how many maximum overdraft fees can you incur in one day?
    12·1 answer
  • The person who can give a short defination of subroutine will get the brainliest.
    9·1 answer
  • The continue statement _________.
    11·1 answer
  • What is a Stereo In (&amp; Out) in audio?
    7·1 answer
  • QueSUUN TU
    15·1 answer
  • Drag each tile to the correct box.
    15·2 answers
  • The people, procedures, hardware, software, data, and knowledge needed to develop computer systems and machines that can simulat
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!