Anonymous
I mean how it’s not true.
Go to offtopic chat
Anonymous
#ot
Ehsan
or you can just use the == operator
Anonymous
Or the <=> operator :)
Ehsan
or you can just use the == operator
it will give you the same output format
Pavel
Is there some way to reduce duplicated methods if I want to be able to return both cons and non-const references to some data from a class. class Foo { private: SomeData a; OtherData b; ThirdData c; public: SomeData& getA(); const SomeData& getA() const; OtherData& getB(); const OtherData& getB() const; ThirdData& getC(); const ThirdData& getC() const; };
Pavel
I have a lot of methods that return references and got a couple of places when it would be nice to have it const. and now I need to add a lot of boilerplate to some of my classes to support it
Ctrl_c
/get cppbookguide
Thailand import
Define a function isVowel(char c) that returns true if a character entered is a vowel ('a', 'e', 'i', 'o', or 'u'), and false otherwise. You can assume that char is a single letter of any case (ie, 'A' and 'a' are both valid vowel). Hint: You may require to include <stdbool.h>
Thailand import
how to do this question 😃
robherc
how to do this question 😃
that's a question that is answered in every class & tutorial I've seen. Have you tried a google search yet?
Thailand import
im self learner 😃
Anonymous
>'Y' is considered a vowel when a word has no other vowel, it's used at the end of a word or syllable, or is in the middle of a syllable.
Anonymous
how to do this question 😃
Most basic approach would be to use switch case statements
Diego
syl-able Then it'd be a vowel, no?
Anonymous
syl-able Then it'd be a vowel, no?
Good example! Splitting words into sylables is a difficult problem...
Diego
im self learner 😃
Asking us is not different at all from googling though, friend
Thailand import
😓
Diego
Good example! Splitting words into sylables is a difficult problem...
It really is, it'd probably require a reasonably complicated regex
Anonymous
It really is, it'd probably require a reasonably complicated regex
The system used in TeX is the best known for English and some other languages (Chinese is difficult just to get distinct WORDS). The TeX system is described in a famout PhD thesis and made the "Trie" data structure famous.
Thailand import
hmm... okok
Anonymous
https://www.tug.org/docs/liang/liang-thesis.pdf
Diego
https://www.tug.org/docs/liang/liang-thesis.pdf
I'll save this for later, thanks!
Diego
hmm... okok
My man just compare the given char against the valid scenarios and if it lands any it's true, otherwise false, don't concern yourself with 'Y' or syllables
Danny
can any one help me with a program that extracts and prints the second digit of an input data of type int in c++
Danny
i have done this
Danny
#include <iostream> using namespace std; int main() { unsigned int given; int second_value; cout << "ENTER THE VALUE= "; cin >> given; second_value = given % 100; cout << "VALUE= " << given << endl; cout << "SECOND DIGIT= " << second_value << endl; return 0; }
Danny
let me try
Danny
ENTER THE VALUE= 234 VALUE= 234 SECOND DIGIT= 23
Danny
that was the output but wat if i used the for command
Tarun
Q5 #include <stdio.h> int whole(float); float fract(float); int main() { float a; printf(" Enter a number : "); scanf("%a",&a); int w= whole(a); float f= fract(a); printf(" Integer part of entered no = %d \n",w); printf(" fractional part of entered no = %f ",f); return 0; } int whole(float a) { return a; } float fract(float a1) { int b= whole(a1); float c= a1 -b; return c; }
Tarun
Plzz help in that code whare is error?
Henry
Scanf %a instead of %f
Tarun
Scanf %a instead of %f
Not work properly
Tarun
Fractional part doesn't match in output
Anonymous
Any one who can help with a c program that can be used to generate electricity token whereby if u consume more than 1000 ksh you get 30 units and if less than 1000 you get 60 units
zdmrr
Selamün aleyküm arkadaşlar
Anonymous
Silly me 😅
Anonymous
Fractional part doesn't match in output
use double. if you want to know why https://en.wikipedia.org/wiki/IEEE_754
@
Thank you so much for accept me best regards
@
I did it thank you
Vlad
use double. if you want to know why https://en.wikipedia.org/wiki/IEEE_754
It's that mantissa has 24 bits only? And the biggest integer value without "gaps" in between is 16 mil?
robherc
given /= 10; second_digit = given % 10;
That only works for a 3-digit number. ex: 25 / 10 = 2 2 % 10 = 2 (wrong answer, should have been 5) 1394 / 10 = 139 139 % 10 = 9 (wrong answer, should have been 3)
robherc
cause I thought second digit from the right
ok, that makes your code make a lot more sense, at least.
robherc
Any one who can help with a c program that can be used to generate electricity token whereby if u consume more than 1000 ksh you get 30 units and if less than 1000 you get 60 units
#1 You need to give us more specific information on where EXACTLY you are having a problem. We will noy write a whole program "from scratch" for you. #2 Please show us what you have attempted already. If you don't prove to us that you're willing to try yourself, where is the value in educating an unmotivated student? #3 What exactly is a "ksh"???
caesar
A float or int which is more advisable to use in your code?
robherc
A float or int which is more advisable to use in your code?
do you want to store a decimal/fractional number?
Eddie
#include <iostream> #include <sstream> #include <string> using namespace std; class Student { private: int m_age,m_standard; string m_first_name, m_last_name; public: int set_age(int age) { m_age = age; } int set_standard(int standard) { m_standard = standard; } string set_first_name(string first_name) { m_first_name = first_name; } string set_last_name(string last_name) { m_last_name = last_name; } int get_age() { return m_age; } int get_standard() { return m_standard; } string get_first_name() { return m_first_name; } string get_last_name() { return m_last_name; } }; int main() { int age, standard; string first_name, last_name; cin >> age >> first_name >> last_name >> standard; Student st; st.set_age(age); st.set_standard(standard); st.set_first_name(first_name); st.set_last_name(last_name); cout << st.get_age() << "\n"; cout << st.get_last_name() << ", " << st.get_first_name() << "\n"; cout << st.get_standard() << "\n"; cout << "\n"; cout << age<<","+last_name<<","+first_name<<","+standard; return 0; }
Eddie
can any1 check my code what is wrong
robherc
can any1 check my code what is wrong
Please see pinned message & upload your code to one of the provided sites.
robherc
what’s the problem?
humorously, I remember writing pretty much that exact program as an assignment for a C++ course at Columbia College Online 😉
soote
Hi everyone, Can anyone write a c++ program can tell how many even,odd, positive and negative number from the input . Like .... I input : -5 0 -3 -4 12 The output : even 3 , odd 2 , pos 1 , neg 3 ...> Even : 0 , -4 , 12 ...etc
soote
AHMED
#include <iostream> using namespace std; int main() { int x = 10; int y = 0xA; int z = 012; int a = 0b1010; cout << "Displaying the values of variables:\n"; cout << x << endl; cout << y << endl; cout << z << endl; cout << a << endl; cout << "Displaying the size of variables:\n"; cout << sizeof(x) << endl; cout << sizeof(y) << endl; cout << sizeof(z) << endl; cout << sizeof(a) << endl; }
AHMED
The output:
AHMED
Displaying the values of variables: 10 10 10 10 Displaying the size of variables: 4 4 4 4 [Program finished]
AHMED
The size is the same. So why do someone represent the value using decimal vs hexadecimal vs octal vs binary literal?
Vlad
What ?!!
Excuse me. Range based for and a simple if(/*elem meets criteria*/) criteria_count++;