First question
1#include <iostream>2#include <cctype>3 using namespacestd;4 intMain ()5 {6 Chararr[ the];7 Charch;8Cin.getline (arr, the);9 intI=0;Tench=arr[0]; One while((ch!='@') && (i<= the)) A { - if((ch>='a') && (ch<='Z')) cout<<Char(ToUpper (CH)); - Else if((ch>='A') && (ch<='Z')) cout<<Char(ToLower (CH)); the Elsecout<<ch; -i++; -Ch=Arr[i]; - } + return 0; -}
Second question
1#include <iostream>2#include <cctype>3 using namespacestd;4 intMain ()5 {6 Doubletemp;7 Doubledonation[Ten];8 Doublesum=0;9 intCount=0;Ten DoubleAve=0; One inti; A for(i=0;i<Ten&&cin>>temp;i++) - { -donation[i]=temp; thesum+=Donation[i]; - } -ave=sum/i; - for(intj=0; j<i;j++) + { - if(Donation[j]>ave) count++; + } A if(i!=Ten) cout<<"Input Error"<<Endl; atcout<<"The number of digit you has input"<<i<<Endl; -cout<<"ave="<<ave<<Endl; -cout<<"count="<<count<<Endl; - return 0; -}
Sixth Chapter programming Exercises