Anonymous
You know me
Giving null or wrong output,any problem in code?
Code looks ok, can you add a newline char in the print to avoid confusion for yourself and check again
C
ios_base::sync_with_stdio(false) cin.tie(nullptr) does this makes code accept user input in new line?
Anonymous
ios_base::sync_with_stdio(false) cin.tie(nullptr) does this makes code accept user input in new line?
No. If you want user input to be accepted on a new line, then you have to do it by outputting a new line (cout << "\n") yourself and by ensuring that cin remains tied to cout.
Void
len=strlen(b); int t; for(x=0;x<len-1;x++) { for(;i<len-i;i--) { if(b[i+1]<b[i]) { t=b[i]; b[i]=b[i+1]; b[i+1]=t; } } } printf("%s",b); return 0;
Void
Guys can you see any mistakes? I want to sort the elements in an array b[]
Void
I want to sort them by ASCII
Anonymous
Plz
Eugene
I ?
Anonymous
I ?
Yes bro
Eugene
where is the initialization i?
Anonymous
#Puzzle (Beginners) What will be the output of this program?
Anonymous
Use spoiler tags for your answer like this: || <answer> ||
后藤
while i use the relative path in headfile.cpp to load an image can the file main.cpp including the headfile.h load the correct image?
Anonymous
Kriss You are supposed to enclose your answer within || tags so that it will be hidden. Please edit your message to hide your answer.
Deepak Chaurasia
Please brief it
Anonymous
Giving null or wrong output,any problem in code?
Are you running that in some online judge?
Deepak Chaurasia
Yes
Anonymous
Yes
Then just print the factorial, nothing else You don't need to print "The factorial is..."
Anonymous
Anonymous
22
I thought so. Your program would exhibit Undefined Behavior. An int is capable of storing not more than 12! and an unsigned long long is capable of storing factorials till 20!. So your code would result in an overflow and overflow on signed integers is Undefined Behavior
Captain
#Puzzle (Beginners) What will be the output of this program?
i think all the constructors will be called so 111
Anonymous
What should use to get factorial <100
If this is some online contest, I doubt you would be required to calculate such big factorials. Most likely, it would involve an algorithm using which you can solve it without calculating such large factorials. If you must calculate them then use a library like GMP. They have a class called BigNum with infinite precision limited only by the virtual memory your OS uses
SH
Hello guys
SH
Can u help me with my coding?
SH
Its too hard for me because I'm newbie on c++
SH
Can anyone help me?
Anonymous
SH
int main () { int i,n; int * p; cout << "Enter Number : "; cin >> i; p= new (nothrow) int[i]; if (p == 0) cout << "Error: memory could not be allocated"; else { for (n=0; n<i; n++) { cout << "Enter Name: "; cin >> p[n]; } } return 0; }
SH
If I run this program it will work, I type any numbers on "Enter Number" and it will work but i can't type any letters on "Enter Name"
SH
How to solve it?
Anonymous
Use templates functions
SH
How
Pavel
Use templates functions
I wonder how templates will help here :)
SH
Please help me
SH
I can't do it😭
Anonymous
How
Use any data type bro Like char* or string
Pavel
Hey bro
How you want your program to react if you type letters?
Pavel
Anonymous
No pls
So in pointers can't we use Char or string?
Anonymous
Tell me
SH
I dont know how to use C++
SH
I'm here because im begging for help
SH
I dont know how to program 😭
Daulet
I dont know how to program 😭
You need to read names from console, and after do what?
SH
Create a code that will ask for a number then it Will ask names as many as the number Input
Pavel
Create a code that will ask for a number then it Will ask names as many as the number Input
You need first to read to ints, and later read to std::string
Void
temp.cpp: In function 'int div(int, int)': temp.cpp:18:20: error: new declaration 'int div(int, int)' int div(int x,int y) ^ In file included from temp.cpp:2:0: c:\program files\dev-cpp\mingw64\x86_64-w64-mingw32\include\stdlib.h:358:17: error: ambiguates old declaration 'div_t div(int, int)' div_t __cdecl div(int _Numerator,int _Denominator); ^
Void
Guys what does this mean
Void
#include <stdio.h> int main() { int div(int x,int y); int mul(int x,int y); int a,b,max,min; scanf("%d %d",&a,&b); max=div(a,b); min=mul(a,b); printf("%d %d",max,min); return 0; } int div(int x,int y) { int i,t; if(x>y) { t=x; x=y; y=t; } for(i=x;i<=x;i--) { if(x%i==0) { if(y%i==0) {return(i);break; } } } } int mul(int x,int y) { int i,t; if(x<y) { t=y; y=x; x=t; } for(i=x;i>=x;i++) { if(i%x==0) {if(i%y==0) { return(i);break; } } } }
Void
Here is my code
Daulet
Create a code that will ask for a number then it Will ask names as many as the number Input
#include <vector> #include <iostream> #include <string> using namespace std; int main() { size_t count; cout << "Enter Number: "; cin >> count; vector <string> names; for(int i = 0; i < count; i++) { string name; cout << "Enter name: "; cin >> name; names.push_back(name); } }
Void
Why you declared functions in main. You need declare them globally
#include <stdio.h> int main() int div(int x,int y); int mul(int x,int y); { int a,b... Like this?
Daulet
#include <stdio.h> int main() int div(int x,int y); int mul(int x,int y); { int a,b... Like this?
No. Like this: #include <stdio.h> int div(int x,int y); int mul(int x,int y); int main() { int a,b...
Anonymous
One more thing I am feeling i am very slow in logic making is there any way to improve
#ot That is a topic for discussion in the OT group. Please take it there.
Hitta
Hlo i have a ques.. A person has 100rs and 10rs is the cost price of 1 chocolate.and by returning 2 wrappers of chocolate he will get 1 extra chocolate.He took only odd no. Of chocolate and gave even no. Of chocolate to his friend and his friend will return him wrappers which he can further exchange with chocolates.He sell his friend a chocolate at5rs per choco. How to code this program in c++ plz help anyone.. 🥺🙏
SC0UNDREL
Yes