Help needed in verifiying the code

There are some kind of Errors in the Following item:


For some Reason SetAt,str.SetAt(pos), &
for( char c : s ) if( !std::isdigit(c) )
throw std::domain_error( "non numeral in string '" + s + "'" ) ;
return true ;


Full Code: header file
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <string>
#include <cctype>
#include <stdexcept>
#include "WCS_String.h"

class digit_string
{
digit_string();   
digit_string( const WCS_String& s ) : str(s) { are_digits(str) ; }
~digit_string();

bool WCS_String::SetAt( char c, std::size_t pos )
    {
        if( !std::isdigit(c) )
            throw std::domain_error( WCS_String("non numeral character '") + c + "'" ) ;
        else str.SetAt(pos) = c ; // std::string will throw if pos is out of range
        return true ;
    }

    digit_string operator= ( const WCS_String& s ) { if( are_digits(s) ) str = s ; return *this ; }

		


    friend inline std::ostream& operator<< ( std::ostream& stm, const digit_string& s )
    { return stm << s.str ; }

    private:
       WCS_String str ;
       bool are_digits( const WCS_String& s )
       {
           for( char c : s ) if( !std::isdigit(c) )
                 throw std::domain_error( "non numeral in string '" + s + "'" ) ;
           return true ;
       }
please help me
thanks
thanks
Last edited on
please help
i told about this problem , tomorrow my friend will helps you do not worry about ok :) since he is computer engineer in turkey
thank you so much for your concern.. but i need to verify this today and submit the assignment ):
#include <iostream>

using namespace std;

int main()
{
bool number=true;

int number;
int one_digit=0;
int two_digit=0;
int three_digit=0;

while(true)
{
cout<<"please enter the number from 0 to 999"<<endl;
cin>>number;
if (number<=9) {

cout<<"one_digit="<<++one_digit<<endl;
cout<<"two_digit="<<two_digit++<<endl;
cout<<"three_digit="<<three_digit++<<endl;

}
else if (9<number<=99)
{

cout<<"one_digit="<one_digit++<<endl;
cout<<"two_digit="<<++two_digit<<endl;
cout<<"three_digit="<<three_digit++<<endl;


}
else if (99<number<=999)
{
cout<<"one_digit="<<one_digit++<<endl;
cout<<"two_digit="<<two_digit++<<endl;
cout<<"three_digit="<<++three_digit<<endl;
}

else (number>999){

cout<<"byee";
break;
return 0;
}
#include <iostream>
#include <string>
using namespace std;
int main () {
int counter =0;
int integer;
string even_or_not
int even=0;
int odd=1;


cout<<"Please enter the integer"<<endl;

cin>>integer;

while(counter<=100){

cout<<counter<<"please enter even or odd"<<endl;

cin>>even_or_not;

if(even_or_not=="even"){

counter+=2;

}

else{

cout<<"you enter the odd number"<<endl;
counter+=2;
}
cout<<"odd number"<<odd<<endl;

cout<<"even integer"<<even<<endl;

system "pause";
}
#include <iostream>

using namespace std;

int main(){

int i;
int n;
cout<<"enter NUM"<<endl;
cin>>i;

for(n=i; n<=100; n += 2){
if(n % 2 == 0){
cout<<"They are even numbers"<<endl;}
else{
cout<<"They are odd numbers"<<endl;
}
cout<<n<<endl;
}

return 0;
}
Last edited on
#include <iostream>
using namespace std;
int main()
{
int firstinteger,secondinteger,result,x;
cout<<"Plesae enter first number"<<endl;
cin>>firstinteger;
cout<<"Please enter second number"<<endl;
cin>>secondinteger;
result=1;
if(firstinteger<secondinteger){
for(x=1;x<=firstinteger;x++){
result=secondinteger*result;
cout<<"Result :"<<result<<endl;

}
}

else
{
for(x=1;x<=secondinteger;x++)
{
result=result*firstinteger;

cout<<"Result :"<<result<<endl;

}
}
main();
return 0;
}
closed account (3qX21hU5)
Wow.... This is a perfect example of people not reading the forum rules AND NOT USING CODE TAGS ;p lol.

I'm personally thinking this is a troll or soemthing
#include <iostream>
using namespace std;
int x,y,z,t=1;
int main(){
cout<<"Please enter first integer"<<endl;
cin>>x;
cout<<"Please enter second integer"<<endl;
cin>>y;
z=1;
if(x<y){
while(z<=x){
z++;
t=t*y;
}
cout<<"Result :"<<t<<endl;
}
else
{
while(z<=y){
z++;
t=t*x;
}
cout<<"Result :"<<t<<endl;
}
return 0;
}
Bu benden Halile gelsin :)
#include <iostream>
#include <string>
using namespace std;

double addition(double first, double second){
double temp= first+second;
return temp;
}

int main(){

double first;
double second;
double result;
int choice;
bool decision = true;
while(decision){
cout<<"Please enter first number"<<endl;
cin>> first;
cout<<"Please enter second number"<<endl;
cin>>second;
cout<<"Please enter your choice /n1-addition n2-substraction"<<endl;
cin>>choice;
cout<<"3-multipication /n4-division/n5-print/n6-draw/n6-finish"<<endl;
cin>>choice;
}

switch (choice){
case 1:
result=addition( first, second);
cout<<"result="<<endl;
break;
}

system ("pause");
return 0;
Topic archived. No new replies allowed.