Michel
𝕷𝖔𝖗𝖊𝖓𝖟𝖔
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/
%Nikita
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
Artur
Hi guys, I am looking for some advice here cause I really don't know how to move: I am asked to fill a possibily very huge matrix with 0s and 1s. The problem is, the more this matrix grows, the more memory those 1s and 0s will occupy. So the first thing I said was "fine, I shall use unsigned shorts in order to represent 0s and 1s, as a whole int seems unnecessary"; then I thought "what about actually creating a binary number, which takes only 1 bit in memory?"... this way, I would optimize the memory occupation of the matrix, but I don't know how to do that. Do you have any suggestions? Sadly, I do not have any code, because other than using a bit mask I haven't come up with anything useful (note, I just started C programming, therefore I am no real expert, but feel free to give me, if you are willing to, as much complex code as you want, I'll try to figure it out by myself later on)... thanks!
Boost library has dynamics bitset have a look at it
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?
100$ website
Null
100$ website
\Device\NUL
Null
\Device\NUL
Wat
Yes, x32 ABI has 32 bit memory address but using x64 calling convention
\Device\NUL
x32 is different tho with i386
Null
Null
\Device\NUL
Null
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
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
\Device\NUL
#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;
}
Are you using *nix system ?
If you're using linux, just install POSIX developer manual page than run man time.h
Or you could just search man time.h using your favorite search engine
Anonymous
Is there anyway to download an only in-app downloadable video?
David
J
Unless you installed windows in it and running a Windows env
S__R
#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;
}
why you using int on average
\Device\NUL
David
David
It doesn’t concern the times
aishu
What will happen if the variable is accessed without initialisation
\Device\NUL
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
λalo.alo
λalo.alo
\Device\NUL
\Device\NUL
> The problem is that n is always set to 49 or 48
I don't understand this
\Device\NUL
λalo.alo
since media here is not allowed
\Device\NUL
> str[i] - 0
The -0 is useless
λ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
\Device\NUL
That's it, u subract it using 0. And that is useless
λalo.alo
λalo.alo
just either 49 or 48
λalo.alo
λalo.alo
λalo.alo
\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
λalo.alo
Anonymous
Pls I need help on an assignment C language