Deidara
https://cs50.harvard.edu/x/2020/
I'll look into it sometime soon🤔
klimi
as you wish
Xudoyberdi
David is awesome
Anonymous
Thanks ^^
Mohannad
Write one C++ program to do the following tasks: a) Read the grades of 10 students from the keyboard. Store the grades in a one-dimensional array called “grade” of type integer. b) Find the average of the grades c) Find and print the maximum grade d) Add to each students grades the following Bonus value: 100-maximum e) Print from the monitor the students new grades
Xudoyberdi
Thanks ^^
😁😁
Anonymous
Could anyone tell me how to separate real number 4.41 example I need to print 4 separately 41 seperately.
Anonymous
An ugly way would be sth like: int a { (int) 4.41}; int b {(int) ((4.41 - a)* 100)}; Im sure the are better ways tho.
Anonymous
also reinterprert_cast is prefered over c style casts
Anonymous
felt too lazy to type it out
Roshan
Could anyone tell me how to separate real number 4.41 example I need to print 4 separately 41 seperately.
Static_cast<int>(4.41) will give you 4 Then store it somewhere Subtract 4 from it
Anonymous
static cast to int from double works? 🤔
Anonymous
could be im honestly not sure 😅
Anonymous
but i have in my head that the compiler would complain about information loss
Anonymous
Okay, mb ^^
olli
also reinterprert_cast is prefered over c style casts
C style cast can be either static_cast or reinterpret_cast [expr.cast]. Please stop suggesting to use reinterpret_cast if one is unsure what it does. In this case it's UB and should not be done. In general, if you wonder whether or not to use reinterpret_cast you probably should not. When you actually need to use it you will know. This is UB and probably not what you want It prints 171798692 (on Linux x64 - GCC 10) #include <cstdio> int main() { double X = 4.41; int Y = *reinterpret_cast<int*>(&X); std::printf("%d\n", Y); } For c-styled casts, the first one is basically a static_cast, the second one a reinterpret_cast #include <cstdio> int main() { double X = 4.41; { // static_cast int Y = (int)X; std::printf("%d\n", Y); // 4 } { // reinterpret_cast int Y = *(int*)&X; std::printf("%d\n", Y); // 171798692 } }
Igor🇺🇦
Could anyone tell me how to separate real number 4.41 example I need to print 4 separately 41 seperately.
Use trunk(val) and val - trunk(val) https://en.cppreference.com/w/cpp/numeric/math/trunc
Anonymous
ha
mov $22, %rax
Guys, do you know of any enviroment to develop efi executables in C/C++?
Anonymous
## Rules #pinned * You are not entitled to an answer, getting angry about not answered questions will get you warned. * Not checking your problem in google (or any other search engine) first will get you a warn. * Asking to solve an assignment/test/whatever without trying it first yourself will get you a warn or will get you BANNED. We won’t write a code for you, but we can push you forward and suggest something. * Before posting a long code snippet think twice and read the Resources section below. * No “best book” or “best youtube channel” requests, use /get cbook and /get cppbookguide chat commands. * No “best ide” requests, use /get ide chat command to see the suggestions. * Asking for something that is in the pinned message right after joining WILL GET YOU BANNED. * C/C++ discussion preffered (assembly also allowed), asking about other languages (or groups for other languages) right after joining will get you BANNED. * Reverse enginnering, hacking and related topics are allowed, but asking to hack facebook, instagram, etc. is NOT allowed. Also if you ask "how to become a hacker" and obviously have zero knowledge on anything related to that you may get warned or banned. * Legitimate requests for help on code and programming questions are welcome. A request is considered legitimate if it describes your problem, what you've done so far and what went wrong. Requests such as "write my program" or "do my homework" are never considered legitimate. Asking not legitimate questions will result in a warn or ban. See https://stackoverflow.com/help/mcve on how to write good questions. * Asking for book recommendations is ok, but "pls give pdf book" is not allowed, find books by yourself. Posting illegally copied books (or links to those books) is also not allowed and will get you BANNED. * Only English language is allowed, if you speak shitty English or don't understand anything in English YOU WILL BE BANNED. * A little bit of programming related memes, jokes, shitposting are allowed. * NSFW content (porn, nudity, etc.) is not allowed. * Spamming/advertising (job posts are also ads, so ask an admin before posting) will grant you a warning or an immediate ban if you do it right after joining. * Religion, politics and ideological topics are forbidden. * Long code snippets must be posted via a snippet website(links below), posting pictures of code and posting long snippets in the group is not allowed. * If you encounter a problem, while using dev C++ or turbo C/C++, you will not be helped, use another more modern IDE. * Don't post compiled executables, that is obviously a security risk. * Personal messages without asking beforehand are not allowed. * If you want to post a link or some article in this chat you will need an admin approval first ## Resources C/C++ group India: http://t.me/c_cpp_india About asking good questions: * [English](http://www.catb.org/esr/faqs/smart-questions.html) * [Translations](http://www.catb.org/esr/faqs/smart-questions.html#translations) For posting long code snippets: * [GitHub Gist](https://gist.github.com) * [Ubuntu Paste](https://paste.ubuntu.com/) * [Pastebin](https://pastebin.com) ## Reports If you notice any forbidden content, please use the /report command while responding to the offending post to report it to the admins.
Yep ,I will follow all these
Coffee
/get cbook
Anonymous
#include <iostream> #include <stdio.h> #include <stdlib.h> #pragma disable (4996) int main () { FILE * fb1; FILE * fb2; int car; int i; int vett1 [4]; = {a, b, c, d} int vett2 [4]; = {d, c, b, a} for (i = 0; i <4; i ++) { printf ("insert the character% d: \ n", i + 1); scanf ("% c", auto); vett1 [i] = car; } printf ("the characters contained in the vector are:"); for (i = 0; i <4; i ++) { printf ("the character% d is:% d", i + 1, vett1 [i]); } fb1 = fopen ("filecar.dat", "wb"); if (fb1! = NULL) { fwrite (vett1, sizeof (int), 4, fb1); } other { printf ("Error !!"); fclose (fb1); } fb2 = fopen ("filecar.dat", "rb"); if (fb2! = NULL) { fread (vett2, sizeof (int), 4, fb2); for (i = 0; i> 4; i ++) { printf ("the character% d is:% d", i + 1, vett2 [i]); } } other { printf ("Error !!"); } fclose (fb1); printf ("\ n \ n"); }
Anonymous
tells me there is an error
Prince Of Persia
How struct in C work (in assembly code)?
HaiNahi
Why do you put semicolon in middle of declaring an array
olli
How struct in C work (in assembly code)?
the members of a struct are layed out in a consecutive memory region.
Prince Of Persia
how they are in a block of memory?
Prince Of Persia
(in assembly)
olli
how they are in a block of memory?
I'm not really sure what exactly you want to know. If you have a simple structure like this struct Foo { int x; char y[4]; }; and then a function which creates an object void foo() { Foo F { 1, "hi!" }; } your compiler might choose to allocate space on the stack and write the members onto it. E.g. foo(): push rbp mov rbp, rsp # Write 1to F.x mov DWORD PTR [rbp-8], 1 # strcpy "Hi!\0" into F.y mov DWORD PTR [rbp-4], 2189672 pop rbp ret
olli
I want to program in assembly like what C and do by hand
why? apart from learning there is no good reason to do so. but otherwise I'd recommend writing C code and looking at the generated assembly code, e.g. at godbolt.org
Prince Of Persia
I can send disassembled of it
olli
I have done objdump in Linux and it's no help
I'd recommend taking a look at simple examples, e.g. how a struct is passed to or returned from a function. Once you get the basic concept you can take a look at more complex dissambled code.
olli
How about also GCC with -S flag?
That works as well, the thing I like about godbolt is the fact that is maps your code to assembly which I would expect to be way more helpful if you're getting started at reading asm
Anonymous
Hey greetings
Anonymous
Anyone can help me?
Anonymous
Dont ask to ask, just ask :) possibly sb is able to help and will respond
Anonymous
1. Read the lines of the txt file in 3 vectors, the float vector of X, Y and Z. 2. With the data you just read is a wave in the time domain and, knowing the duration of the collection, make the Fast Fourier Transform (FFT) 3 axes, passing the signal to the frequency domain. How can i make this in C++?
Asad
Who wants to do a code review? I have written simple Vector DS implementation in C language. Would love to hear "constructive criticism" )
RC
Anyone know good apps to code C for cell phones?
HaiNahi
Anyone know good apps to code C for cell phones?
Yeah cxx droid for sdl and termux for other command line stuff
RC
Thank you all
beluga_hz
Hi everyone
Yedi
https://ibb.co/xGSzFwV
Yedi
I wrote the codes like in my teacher's work, but the lines I circled in my work don't look like my teacher's, why?
Roshan
The array is not initialized
Yedi
yes
Yedi
F11
Dark
Is it something related to programming? Use paint
yes programming, please tell me how to attach pgm to c++ and change rows to coulmns
Manav
yes programming, please tell me how to attach pgm to c++ and change rows to coulmns
https://docs.opencv.org/master/d3/df2/tutorial_py_basic_ops.html
Anonymous
i have a doubt in my code ,i code in online compiler but it is showing error
Anonymous
is there anyone to correct my coide
Tagansat
👍🏻
Anonymous
ok i am sending
Anonymous
/how will i send my code here?????
Nameful
/how will i send my code here?????
upload it to some pastebin
Anonymous
can i tell u the question of code ???/
Anonymous
write a program in c language ,if a student scores 40% total and atleast 30% marks in each subject then he is pass or he fails ,no of subjects is 3 phy,chem,math
Anonymous
i have code it in online compiler but it is showing error
Anonymous
@ swastik pass marks is 30% in individual subjects