Golden Singh
shi
Is there any freelance programmer here?
Rio
How to write a Matrix using codeblocks ?
Rio
??
klimi
Are you writing in c or c++ or codeblocks language?
Anonymous
Aron
I have to sleep. had brief look. Just parse/deserialise xml and extract first Previous object from a collection
Medi
Hi, is there any way using kind of regexp format that string str1 str2 str3 1 2 3 4 5 and get only the integers, having in mind can be 5 numbers or more
Edward Wu | Happy Hacking !!
Hello , I'm new at learning C++
I have some questions.
Aron
I need som help
Anonymous
How to check whether the input is integer or not ?
Anonymous
Like if I need to add all the digits of an integer 245 output as 11
Anonymous
If input is 2a5 then I need to recognise it as invalid integer
Anonymous
Please help me out
Anonymous
Please help me out
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
int main()
{
int sum = 0;
char n;
/* Input integer from user */
printf("Enter the integer: ");
scanf("%c", &n);
if (isdigit(n) ==0)
{
while (n != 0) //this will not work if n is char type
{
sum = sum + n % 10;
n = n / 10;
}
printf(" %d ", sum);
return 0;
}
else
{
printf("Input entered is invalid");
}
}
Vladimir
Anonymous
ctype.h
I had put already in code
Anonymous
No
Anonymous
Input : 256
Output : 13
Anonymous
Input : 4a1
Output : Invalid
Anonymous
That's what I needed
Hsn
Float × int = (float or int) ?
Float / int = (float or int)?
914
Both should be float
VladV1V
is there any way to use , in float numbers instead of .
Igor🇺🇦
VladV1V
Igor🇺🇦
Ah, that's different. Just parse them character by character till you reach comma. N = N *10 + current_char
Igor🇺🇦
After comma do the same for numbers after comma. After you finish divide it be 10^(size of string after comma).
Your number is a sum of both numbers.
Peace
This program is showing error : binding reference of type 'int&' to 'const int' discards qualifiers
It is working fine when I do not use const. Why ?
int &print(const int a){
return a;
}
int main(){
int a=1;
cout << print(a);
return 0;
}
Peace
when returning by reference is useful ?
Pavel
Peace
when does returning value by reference is useful ? which situations ?
Peace
we can return value by value , address . then why do we return by reference ?
Peace
a basic question :use of returning value by reference
Pavel
when does returning value by reference is useful ? which situations ?
One example can be returning a reference to a member variable of a class.
Imagine you have some class that stores heavy data as a private member variable, you want the users of this class to read this data without copying it, you can make a getter function that returns a const reference to that data.
Pavel
Peace
Peace
Peace
Pavel
Pavel
Buki
Any C++ graphics designerr inbox
klimi
Peace
Pavel
it's high level for me 😁
Then just the simple rule - don't return references to local variables.
Unfortunately compiler won't stop you from doing that.
Igor🇺🇦
Kaashᅠ
how can we parse cout data into a variable? Can it happen? in C++
Бүләт
Hi!
How can I read one line until '\n' from text file, using only open, read, malloc and free functions? BUFFER_SIZE in read(fd, buf, BUFFER_SIZE) everytime different and sets by user.
Function must be written on C
\Device\NUL
Бүләт
Using Linux syscall ?
I cant use it)
Only: open, read, malloc, free. And ok, I can write my own strlen and other functions, that use this four functions
✨Justina
#include <iostream>
using namespace std;
int findLargest(vector<int>&);
int main()
{
vector<int>hebat;
int Size;
int Value;
int Largest;
cout<<"How many integers would you like to enter?";
cin>>Size;
for (int i=0; i<size; i++)
{
cout<<"Enter your Number "<<i+1<<":";
cin>>Value;
hebat.push_back(value);
}
Largest = findLargest(hebat);
cout<<"The Largest Value is :"<<Largest;
return 0;
}
int findLargest(vector<int>& temp)
{
int max=temp[0];
for(int j=i; j<temp.Size();j++)
{
if(temp[j]>max)
max=temp[j];
}
return max;
}
✨Justina
plz help to solve this problem
✨Justina
artemetra 🇺🇦
what's the error, then?
✨Justina
#include <iostream>
using namespace std;
int findLargest(vector<int>&);
✨Justina
At this part
artemetra 🇺🇦
artemetra 🇺🇦
you haven't specified the parameter name
✨Justina
Bcoz 1st time I'm doing vector question
artemetra 🇺🇦
olli
#include <iostream>
using namespace std;
int findLargest(vector<int>&);
A decent compiler will tell you what's wrong there (however there are more compiler errors)
<source>:3:17: error: 'vector' was not declared in this scope
3 | int findLargest(vector<int>&);
| ^~~~~~
<source>:2:1: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
1 | #include <iostream>
+++ |+#include <vector>
2 | using namespace std;
<source>:3:24: error: expected primary-expression before 'int'
artemetra 🇺🇦
your function declaration (findLargest with the ;) signature must match the function definition signature (findLargest in the bottom with {})
otherwise, the compiler will see those functions as different
artemetra 🇺🇦
but yeah, you have a syntax error there
https://t.me/programminginc/428149
olli
✨Justina
#include <iostream>
#include <vector>
using namespace std;
int findLargest(vector<int>&temp);
int main()
{
vector<int>hebat;
int Size;
int Value;
int Largest;
cout<<"How many integers would you like to enter?";
cin>>Size;
✨Justina
Nw this part correct rdy
olli