Jump to content

c++ statements

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
5 replies to this topic

#1
kumamako

kumamako

    Newbie

  • Members
  • PipPip
  • 16 posts
write c++ statements to accomplish each of the following:

1) Display the value of element 6 of character array f.
2) Input a value into element 4 of one-dimensional floating-point array b.
3) Initialize each of the 5 elements of one-dimensional integer array g to 8.
4) Total and print the elements of floating-point array c of 100 elements.

1) cout<<f[5]<<endl; or cout<<f[6]<<endl;
is this correct. if yes, then what is character all about? do i have to include it somewhere

2) cin>>b[4] or cin<<b[3]; (confused btn position index and element)
is this correct? i do not get the floating part bit.

3) int g[5]={8,8,8,8,8}

4) (int i=0;i<100,i++)
total+=c[i]

cout<<"Total : "<<total;


is it correct? what do they mean by floating point array c?

thank you.

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts

kumamako said:

write c++ statements to accomplish each of the following:

1) Display the value of element 6 of character array f.
2) Input a value into element 4 of one-dimensional floating-point array b.
3) Initialize each of the 5 elements of one-dimensional integer array g to 8.
4) Total and print the elements of floating-point array c of 100 elements.

1) cout<<f[5]<<endl; or cout<<f[6]<<endl;
is this correct. if yes, then what is character all about? do i have to include it somewhere
cout<<f[5]<<endl;

The declaration of f would have been:
char f[6];

kumamako said:

2) cin>>b[4] or cin<<b[3]; (confused btn position index and element)
is this correct? i do not get the floating part bit.
cin>>b[3];
b would have been declared as:
float b[4];

kumamako said:

3) int g[5]={8,8,8,8,8}
correct

kumamako said:

4) (int i=0;i<100,i++)
total+=c[i]

cout<<"Total : "<<total;


is it correct? what do they mean by floating point array c?

thank you.
I would specifiy total=0.0; before the loop. You also need the for keyword.
c would have been declared:
float c[100];
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
kumamako

kumamako

    Newbie

  • Members
  • PipPip
  • 16 posts
THANKS ALOT BRO! I really appreciate it man.

#4
kumamako

kumamako

    Newbie

  • Members
  • PipPip
  • 16 posts
1) Copy array a into the first portion of array b. Assume double a[ 11 ], b[ 34 ];

2)Determine and print the smallest and largest values contained in 99-element floating point array w.

#5
chili5

chili5

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 7,247 posts
It is starting to seem like you are asking people to do trivial things for you.

1. Use a loop
2. Use a loop and a comparison with a variable.

#6
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
We don't do homework. You have to at least offer an idea before we'll do much.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog