Anonymous
I hope I helped him become more modern/
Anonymous
What is worse is because this rule exists it means it happens often :/
Anonymous
How long do you think it takes to unlearn bad practises and write "good" C++ code?
Anonymous
Just a rough estimate
olli
I don't know, I think it's an ongoing process, since C++ keeps evolving as well. Just try to stay up to date and try to use the language as it is designed to be used.
Anonymous
gotcha, thanks!
Anonymous
Can anyone help me to write program to convert binary to decimal using array (Can use recursion also)
Anonymous
Write a C program to convert a binary number to decimal with the help of the function int toDecimal (char bits[], int length) where bits is the character array to represent bits of binary numbers and length is the number of bits in the binary number.
Anonymous
Anonymous
How can i scan any binary number instead of 100 in char bstr[]= "100";
Magician
Google ascii
Anonymous
Also, strlen returns a size_t, so it might be better to use a size_t and not an int.
Anonymous
(Of course then the for loop would have to use size_t counters)
Anonymous
#include <stdio.h> void main() { int i,j,m,n,o,p; printf("Enter the no. of row and column of 1st matrix"); scanf("%d%d",&m,&n); printf("Enter the no. of row and column of 2nd matrix"); scanf("%d%d'",&o,&p); if(m==o && n==p) { int a[m][n]; printf("Enter the first matrix"); for(i=0;i<m;i++) { for(j=0;j<n;j++) { scanf("%d",&a[i][j]); } } int b[m][n]; printf("Enter the second matrix"); for(i=0;i<m;i++) { for(j=0;j<n;j++) { scanf("%d",&b[i][j]); } } int sum[m][n]; for(i=0;i<m;i++) { for(j=0;j<n;j++) { sum[i][j]=a[i][j]+b[i][j]; printf("%d\t",sum[i][j]); } printf("\n"); } } }
Anonymous
How can i add function for this program
Anonymous
Function is add(a[],b[],int m,int n)
Anonymous
What do you have trouble with? Function syntax? Something else?
Anonymous
What do you have trouble with? Function syntax? Something else?
Nop I have to add function for my assignment
Anonymous
I tried but got some errors
Anonymous
Anonymous
I also dont know what i did
Anonymous
Well, as you can read the rules, we won't do the assignment for you. You can provide us tour code and we can help you fix it though.
Anonymous
This is code
Anonymous
Well, as you can read the rules, we won't do the assignment for you. You can provide us tour code and we can help you fix it though.
#include <stdio.h> int main() { int i,j,m,n,o,p; printf("Enter the no. of row and column of 1st matrix"); scanf("%d,%d",&m,&n); printf("Enter the no. of row and column of 2nd matrix"); scanf("%d,%d'",&o,&p); if(m==o && n==p) { int a[m][n]; printf("Enter the elements of first matrix\n"); for(i=0;i<m;i++) { for(j=0;j<n;j++) { scanf("%d",&a[i][j]); } } int b[m][n]; printf("Enter the second matrix\n"); for(i=0;i<m;i++) { for(j=0;j<n;j++) { scanf("%d",&b[i][j]); } } int mat[i][j]=add(a[i][j],b[i][j],m,n); printf("%d",sum[i][j]); } int add(int a[][],b[][],int m,int n) { int k,l; int sum[m][n]; for(k=0;k<m;k++) { for(l=0;l<n;l++) { sum[k][l]=a[k][l]+b[k][l]; } printf("\n"); } return sum; }
Anonymous
I am beginner so dont know much
Anonymous
Please post code into a snippet website like ideone.com or wandbox.org
MᏫᎻᎯᎷᎷᎬᎠ
Pattern matching
MᏫᎻᎯᎷᎷᎬᎠ
It's a fucking incredibly
MᏫᎻᎯᎷᎷᎬᎠ
C++ is great
MᏫᎻᎯᎷᎷᎬᎠ
U drunk?
Forbidden
MᏫᎻᎯᎷᎷᎬᎠ
U drunk?
Pattern matching
MᏫᎻᎯᎷᎷᎬᎠ
It's in Rust
Ибраги́м
MᏫᎻᎯᎷᎷᎬᎠ
But I didn't get what reflections are!!
Ибраги́м
Ибраги́м
MᏫᎻᎯᎷᎷᎬᎠ
So
Yeah, That's great
Ибраги́м
How old is Rust?
MᏫᎻᎯᎷᎷᎬᎠ
How old is Rust?
4 years since the first stable release
Anonymous
Rust is pretty new.
Anonymous
Conpared to C++'s age it's a baby.
MᏫᎻᎯᎷᎷᎬᎠ
With that Rust can kiss C++ ass
MᏫᎻᎯᎷᎷᎬᎠ
Good baaa
Anonymous
I wonder whether Rust will even be close to as influential as C++ was/is.
MᏫᎻᎯᎷᎷᎬᎠ
Shaun the sheep
Francisco
I wonder whether Rust will even be close to as influential as C++ was/is.
Will have to wait until big projects come up. Meanwhile, everything is just speculation
Anonymous
All are humans here??
Ибраги́м
4 years since the first stable release
PatMatPres] Yuriy Solodkyy, Gabriel Dos Reis, and Bjarne Stroustrup. “Pattern Matching for C++” presentation at Urbana-Champaign 2014.
Anonymous
All are humans here??
No, there are some bots.
Anonymous
Any one pls help me To write program for to find even and odd number
Anonymous
If(n%2==0)
Anonymous
What this statement says
Pavel
What this statement says
https://www.cprogramming.com/tutorial/modulus.html
Anonymous
Anonymous
Anonymous
Help me to solve this error please
Vladimir
Split statement on line 8 to 2. char *temp; temp = malloc(sizeof(char) * 2);
Anonymous
Split statement on line 8 to 2. char *temp; temp = malloc(sizeof(char) * 2);
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <string.h> int main() { char c[1000]; char* temp = (char*)malloc(sizeof(char) * 2); int i = 0, sum = 0, j = 0; printf("Enter the binary number:"); scanf("%s", c); int len = strlen(c); for (i = (len - 1); i >= 0; i++) { temp[0] = c[j]; sum = sum + (atoi(temp) * pow(2, i)); j++; } printf("The decimal number is:%d", sum); }
Anonymous
Output dont come but program runs
Vladimir
You have an error btw
Vladimir
Add temp[1] = 0; somewhere before atoi
Anonymous
Add temp[1] = 0; somewhere before atoi
Inside for loop or outside
Vladimir
No matter
ॐकार
Inside for loop or outside
Hello .. There is simple bug :O Just in loop Don't increment i decrement it i--
ॐकार
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <string.h> int main() { char c[1000]; char* temp= (char*)malloc(sizeof(char) * 2); int i = 0, sum = 0, j = 0; printf("Enter the binary number:"); scanf("%s", c); int len = strlen(c); for (i = (len - 1); i >= 0; i--) { temp[0] = c[j]; sum = sum + (atoi(temp) * pow(2, i)); j++; } printf("The decimal number is:%d", sum); }
Anonymous
Check this once
ॐकार
Increment j++ Decrement i--
Anonymous
Thnks guys
Anonymous
Need to add function insame code now
Anonymous
Function having argument char bits[]and int length
MᏫᎻᎯᎷᎷᎬᎠ
I hear a lot about reflections in the upcoming versions of C++