Michel
1) C; 2) Yes, only 1s and 0s; 3) No, given a certain dimension (it's a squared matrix) it remains the same through the runtime
Is there any reason to use C and not C++? I can think of some ways in C++ buy don't know in C
𝕷𝖔𝖗𝖊𝖓𝖟𝖔
Yes that's a software for the computer architecture class, and we are studying C at the moment
Michel
🤔 I don't know if there is a struct like a bitmask of arbitrary size in C, if there is my first idea was to have a bitmask of size N*N and use the index [i * N + j] where i would be the row and j the index.
Michel
I'm C++ you could override de () operator to pass (i,j) and hide the one dimensional array inside a class
𝕷𝖔𝖗𝖊𝖓𝖟𝖔
Mmm thanks, as I said I've been in C programming for very little time, so I'll check your suggestion out, but might take a while
𝕷𝖔𝖗𝖊𝖓𝖟𝖔
thank you by the way
DUTRUNPRINTS
/get cbook/
Danya🔥
Yes, but physically it is not wrong. Integer value is same size as integer pointer, and integer pointer is a memory cell too. We can use it as a common integer value, or store addresses in integer type.
> Integer value is same size as integer pointer Lol, wtf 1. It is not correct to compare these 2. It is a wrong statement to make. Try compiling for x64, for example, this static assert static_assert(sizeof(int*) == sizeof(int)); And guess what? You get a compile erorr
Danya🔥
Well yes, you are right. I told about my platform
Ok, sorry, I just cut the statement off from the dialogue But my advice is not to depend on any platform specific stuff when programming in C++ or C — this will make code cleaner and safer
%Nikita
Ok, sorry, I just cut the statement off from the dialogue But my advice is not to depend on any platform specific stuff when programming in C++ or C — this will make code cleaner and safer
Thanks you for advice! But sometimes there is an easy way to do something with unsafe type punning for example. Otherwise solution can be to large :/ But I still try to make my code cross-platform :)
Artur
dynamic*
Ahmed
Guys
Ahmed
Is is ok if i sent a n assignment I’m stuck with it?
Ahmed
I’m done with 80%
100$ website
string phrase= "giraffe bigboss"; char pharse[ ] [ 10 ]= {"giraffe bigboss"}; does the space between giraffe and bigboss counts? how it is behind the scenes k mean 'g','i','r','a'....... can someone explain writing a code?
\Device\NUL
Wat
Yes, x32 ABI has 32 bit memory address but using x64 calling convention
\Device\NUL
x32 is different tho with i386
\Device\NUL
1. Wtf 2. How does it relate to my message?
> Integer value is same size as integer pointer
Null
> Integer value is same size as integer pointer
So? C++ standard doesn't guarantee that
\Device\NUL
So? C++ standard doesn't guarantee that
Ow, maybe it's only avaiable on linux
Null
Ow, maybe it's only avaiable on linux
https://t.me/programminginc/441653
David
Hello
David
#include<stdio.h> #include<math.h>   int main(){     int count = 0;     double sum = 0;       double mag, angle, Xvalue;       while (count < 2){         printf("Enter vector %d (mag, angle):", count+1);         scanf("%lf %lf", &mag, &angle);           Xvalue = mag * sin(angle * (M_PI / 180));         sum = sum + Xvalue;           count++;     }         printf("sum is %lf", Xvalue);     return 0; }
David
so basicly i am trying to print the sum of the x values in the loop but it is giving me the xvalue of the last one
David
can anyone be of help?
Caio
On the last printf you're using the xValue instead of 'sum'
David
oh dams
David
it really hiding in plain site
David
wow thanks bug fixed
David
#include <stdio.h> #include <stdlib.h> #include <time.h>   int main(){ int count = 1; int totalCorrect = 0; int totalWrong = 0;   while (count < 6){ int number1; int number2;   //sets the initial point (seed) for generating random numbers srand(time(NULL));   // random number between 0 and 9 inclusive number1 = rand() % 10; number2 = rand() % 10; int userAnswer; int subtraction; subtraction = number1 - number2; printf("\nwhat is %d - %d = ", number1, number2); scanf("%d", &userAnswer); count++;   if (userAnswer == subtraction){ printf("You are correct\n"); totalCorrect++; } if (userAnswer != subtraction){ printf("You are wrong\n"); printf("%d - %d should be %d\n", number1, number2, subtraction); totalWrong++; } } int average = (total /count) * 100; printf("\nCorrect count is %d\n", total); printf("count is %d\n", count); printf("Test time %ld seconds\n", time(NULL)); printf("Your average for this test is %d percent\n", average); // current time in seconds since January 01, 1970 printf("\nCurrent Time: %ld seconds\n", time(NULL));   return 0; }
David
so basically i am trying to print the number of seconds the user took to complete the subtraction test, but its giving a very long values
Robert
you should make a subtraction here. From beginning to the end. That is time cost
David
that why i posted this here, i am quite confused using the time function
Anonymous
Is there anyway to download an only in-app downloadable video?
J
I am using MacBook
It's a *nix system
J
Unless you installed windows in it and running a Windows env
\Device\NUL
why you using int on average
It should be size_t ?
David
why you using int on average
That’s for another reason
David
It doesn’t concern the times
aishu
What will happen if the variable is accessed without initialisation
Khaerul
Undefined Behaviour
UB sticker where?, :v
klimi
klimi
λalo.alo: Hello, I'm having problems initializing elements in an int array. As you can see in gist.github.com/aloxyz/d70c9e1b0629d920635d57ad1c13a40c , make_numbers is supposed set each number.digits to the corresponding str element given in as an argument to make_number. The problem is that n is always set to 49 or 48. I hope you can help me with this, thanks for your time
\Device\NUL
> The problem is that n is always set to 49 or 48 I don't understand this
λalo.alo
> The problem is that n is always set to 49 or 48 I don't understand this
i can send you a screenshot of gdb in DMs if you wish, it's hard to explain
λalo.alo
since media here is not allowed
λalo.alo
n is struct right ?
n is a number struct, yes
\Device\NUL
> str[i] - 0 The -0 is useless
\Device\NUL
n is a number struct, yes
So where's the problem ?
λalo.alo
the problem is that instead of initializing n to {1,0,1,0} it's initialized to {49, 48, 49, 48}
\Device\NUL
That's it, u subract it using 0. And that is useless
λalo.alo
just either 49 or 48
\Device\NUL
just either 49 or 48
I have told u it's ascii char use - 48
\Device\NUL
didn't change
'0' in ASCII table is 48 '1' in ASCII table is 49
\Device\NUL
So you should subtract it with 48
S__R
It should be size_t ?
float or double make sense
Anonymous
Pls I need help on an assignment C language