Arun
Thank you Rose
Eirik
And download
Alternatively you could try installing Geany. I am pretty sure it ships with GCC. So you'd have a text editor and just have to click the "compile" button to run it
Eirik
Has anyone here ever tried the Tiny C Compiler?
Nana
Hello guys, I just wrote this code but it cannot catch string errors. Pls help me
Nana
Marcio
Nana
#ifndef RECTANGLE_H
#define RECTANGLE_H
class Rectangle
{
public:
void setLength(double);
void setWidth(double);
double getLength() const
{
return length;
}
double getWidth()const
{
return width;
}
double getArea()const
{
return length * width;
}
class NegativeLength
{
private:
double value;
public:
NegativeLength(double val)
{
value = val;
}
double getValue() const
{
return value;
}
};
class NegativeWidth
{
private:
double value;
public:
NegativeWidth(double val)
{
value = val;
}
double getValue() const
{
return value;
}
};
private:
double length;
double width;
};
#endif // RECTANGLE_H
Nana
Nana
#include "Rectangle.h"
void Rectangle::setLength(double len)
{
if(len >= 0)
length = len;
else
throw NegativeLength(len);
}
void Rectangle::setWidth(double w)
{
if(w >= 0)
width = w;
else
throw NegativeWidth(w);
}
Nana
Nana
Pls I'm waiting for your feedback
Nana
It's unfortunate that the source code is not well organized. Pls you can send me a private message for the source code if only you wanna assist me
J
Anonymous
Good Bye World
Hi group, sorry if this is a repeated question here, but I'm feeling a bit lost and would appreciate some help.
I learned a bit of C++ and C in high school, and went on to work as a C++ dev (C++ 03 version) for a year before switching to mostly C# and Python. I lost touch with C++ completely and it has been kind of intimidating to me ever since the more recent versions have come along and I feel I'm too far behind everyone else.
Can someone point me in the right direction so I can catch up on the latest versions of C++ and get a bit more familiar with the language?
Kaashᅠ
wht happened ?
Good Bye World
Kaashᅠ
thanks, now its opened, i returned back previously bcoz the site wasn't opening
J
For GCC, I will stick with something like Manjaro than void. Also, I wouldn't recommend Arch unless they know something about Linux. (Example, Recent bluez(Bluetooth) bug.)
\Device\NUL
Use Artix if want init freedom arch or Devuan for init freedom debian
Anonymous
hi...I'm a biginner(c++). Am trying to reverse all the characters of a sentence...plz anyone help me to correct the errors.
#include <iostream>
using namespace std;
int main(){
cout<<"\n\nInput your message : ";
int size=100;
char string[size];
cin>>string;
char rev_string[100];
int j = 0;
for (int i = 100; i < 0; i--){
while(string[j] =! NULL){
string[j] = rev_string[i];
j++;
}break;
}cout<<rev_string;
return 0;
}
\Device\NUL
Prince Of Persia
\Device\NUL
\Device\NUL
Oh sorry, i miss read it
Prince Of Persia
Prince Of Persia
\Device\NUL
People still ignoring compiler messages '-'
\Device\NUL
Prince Of Persia
Prince Of Persia
Prince Of Persia
The loop is so confusing
Prince Of Persia
He could have done this much better
Prince Of Persia
By a single loop and other thing is the rev_string always contains the last character in string
Prince Of Persia
If the string is "abcdef"
rev_string would be "fffffffff..."
Prince Of Persia
Oh what's that break😐
Prince Of Persia
This code has many wonders😂
Anonymous
Anonymous
Morax
#include <iostream>
using namespace std;
int main()
{
int n;
cin>>n;
int i;
for(i=2;i<n;i++){
if(n%i==0){
break;
}
}
if(i==n){
cout<<"Prime";
}
else
cout<<"Not prime";
return 0;
}
Morax
this is a program to tell whether a given number is prime or not
Morax
but if i do.... for(i=2;i<=n;i++)
Morax
the program still works fine
Morax
someone pls explain this...
Pavel
but if i do.... for(i=2;i<=n;i++)
You actually can check up to n/2, e.g. if you have 31, then dividing by 16 doesn't make sense already since 2 was checked
So the checks above n/2 don't really add value
Pavel
But I see you asking about a different thing
Pavel
but if i do.... for(i=2;i<=n;i++)
So, in this case the n+1 will not be reached because it will break on your condition when i == n, because any value is divisible by itself without reminder
Morax
Morax
Pavel
I think there are even more optimal ways of doing that (which I heard of but can't understand :))
Morax
Morax
Morax
Anonymous
hey
Anonymous
Azure RDP available
Gilded
\Device\NUL
More like : "Can you optimized my code" But you didn't provide your code
\Device\NUL
Maybe your code is too complex.
Anonymous
Don't use online for serious code compilation
\Device\NUL
redacted
artemetra 🇺🇦
artemetra 🇺🇦
use a for loop
\Device\NUL
The conditional is too complex too
\Device\NUL
for(; a <= b; a++) {
switch (a)
//bla-bla-blah
}
std::cout << b % 2 ? "odd" : "even"
artemetra 🇺🇦
Prince Of Persia
I read this before I read the question
I thought this is some kind of kernel code🥲
but after reading the question ...
\Device\NUL
\Device\NUL
The code is too complex for this question, You don't even need if (a == b) line. It's include on while (a <= b) block
\Device\NUL
\Device\NUL
\Device\NUL
I prefer pointer of char that allocated in data segment