English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

what is the dev c++ formula that declares an array of 20 integers. Accept a number to determine the number of 0 or 1 inputs(binary digits). Display decimal value using the output format:

Enter size: 4
1
0
1
1
Equivalent: 11
1x8=8
0x4=0
1x2=2
1x1=1

2007-01-09 19:34:11 · 4 answers · asked by Edrew c 2 in Computers & Internet Programming & Design

4 answers

Hello Edrew !!

Here is your solution:


#include
#include
#include

void main()
{
int num[20]={0};
int total,i;
double sum=0;
clrscr();
cout<<"How many digits do you wish to Enter : ";
cin>>total;

if(total>0 && total<=20)
{
cout< for(i=0;i {
cin>>num[i];
}


for(i=0;i {
sum=sum + num[i]*pow(2,total-i-1);
cout< }
else
cout<<"Please Enter value between 0 and 20..";

getch();
}

2007-01-09 20:53:16 · answer #1 · answered by Anonymous · 0 0

int array[20]; i'm unlikely to offer you the full code, yet an array is written like the only above. declare the variable form (int) declare the array call (array) declare what proportion areas are interior the array ([20]); Now, in case you ever ought to easily start up the array with values in there you ought to form it like this: int array[20] = {a million, 2, 3, 4, 5, 6, 7, 8, 9} ^^ in that occasion, after huge form 9 something of the areas could start up as 0.

2016-12-12 08:13:49 · answer #2 · answered by ? 4 · 0 0

Try searching the net for C++ tutorials and resources. It's worth bearing in mind that Dev C++ is an editor, not a language - the languages it edits are C or C++.

2007-01-09 19:46:38 · answer #3 · answered by Anonymous · 0 0

Try searching the net for C++ tutorials and resources

2007-01-09 20:01:12 · answer #4 · answered by Sonu G 5 · 0 0

fedest.com, questions and answers