Problem using arrays

I'm in a begginer c++ class. So far I am doing good until we got to the array section.I been given two questions to answer and I am having problems starting them off. I just need help starting the thinking process.
1. Write a program to count letter 'a' in a given character string

2. Write a program to sort 5 integers using arrays.
Last edited on
1
2
3
4
const char *string="The quick brown fox jumps over the lazy dog.";
//???
            if (/*???*/=='a')
//??? 
thanks that helped alot.
char a[20]=("my name");
for( int n=0;n<20;n++){
if(a[20]=='a')
counter=counter+1;
}
cout<<counter<<endl;




Now I know how to find the smallest integer in an array but not sort them smallest to biggest or vice versa.

int number[5];
for (int n=0;n<5;n++){
cout << "Enter numbers" <<endl;
cin >> number[n];}

// display array element
int sum=100;
for (int k=0;k<5;k++){
if(number[k]<sum){
sum=number[k];
cout<<number[k]<<endl;}
Topic archived. No new replies allowed.