C++ Sum of Individual Characters In String

Method One - Using Counter and Loop

#include <iostream>
using namespace std; // so you don't have to use std::
int n,k,i,z,target; //declaring variables
int m=1; // initializing variable counter to one
string balloon; //declaring variable string that is named balloon
int main(){ //declare main function - required in every c++ program
cin>>n>>balloon; //setting up inputs for different variables
for (i=0;i<n;i++){ // for clause to run through string balloon
m=0; //setting up a counter for each character
target=balloon[i]; // setting up a target value for each character
for (z=0;z<n;z++){ //checking each character
if (target == balloon[z]) { //if clause to check if target character is equal to character in string
m=m+1; //if characters match, increase counter
}
cout<<m;//output total of each character
}
}
[stdio.h](https://en.wikipedia.org/wiki/C_file_input/output#cite_note-1) is the standard input/output library (i.e.- scanf,printf)
[iostream](https://en.wikipedia.org/wiki/Input/output_(C%2B%2B))- alternative to stdio.h. Contains cin and cout.