Toxic
Can i get a C expert i need some help
Mr
Which rule ?
Pinned Rule, Rule #2
Назар
Can somebody help me to fix mistake in C#? System.NullReferenceException: 'Object reference not set to an instance of an object.'
UnO1
can someone check on this? c++
UnO1
#include<iostream> using namespace std; int main() { int num; { cout <<"ENTER NUMBER"; cin >>num; } if (num<=1); { cout <<"INVALID"; } else if (num==2num==3) { cout <<"PRIME"; } else if(num%2==0num%3==0) { cout <<"COMPOSITE"; } else { cout <<"PRIME"; } return 0; }
Mr
it was given in the example
It prevents the program from executing
Mr
Remove those brace and it will work fine
Mr
#include<iostream> using namespace std; int main() { int num; cout <<"ENTER NUMBER"; cin >>num; if (num<=1) { cout <<"INVALID"; } else if (num==2 || num==3) { cout <<"PRIME"; } else if(num%2==0 || num%3==0) { cout <<"COMPOSITE"; } else { cout <<"PRIME"; } return 0; }
YZ
Can anybody help me with this? I’m quite new to C I had a program which compiled fine in codeblocks and all the outputs I got corresponded to my inputs correctly but when I tried dumping the same code into all the other online c compilers some of the outputs become wrong with the exact same inputs
YZ
#paste
Syed
How to create easy logic whether a number is Prime or not?
Thadeu
How to create easy logic whether a number is Prime or not?
easy is basically dividing by any number that under its half has no divider except 1. It is not much optimized although. Your problem is more with the equation than with the logic. There are a lot of math functions with different approach. The problem is how you can narrow the process with big numbers (there is still a prize for who discover an exactly way to do it)
不要惹胖虎
Ladies and gentlemen, how does the physical layer uniquely identify the data circuit between two adjacent systems? ? ?
Anonymous
Ladies and gentlemen, how does the physical layer uniquely identify the data circuit between two adjacent systems? ? ?
How is this related to C++? And the answer to your question is "it doesn't". The physical circuit from your system is most likely to a hub or a switch. In olden days hubs used to broadcast the message to all devices on the LAN. Nowadays hubs and switches are intelligent in that they build a ARP table which tells which port a system with a specific MAC address is connected to.
Anonymous
I have a question maybe too noob, are programming languages made by other languages? Pls🙏
DaviChan
I have a question maybe too noob, are programming languages made by other languages? Pls🙏
Yes, ofc. For example the clang compiler is written in C++, the Python interpreter (most implementations) in C. The GNU C compiler is also written in C, the first C compiler was written in assembler
DaviChan
There are no "noob" questions. Some things are not really talked about. So its fine to ask!
DaviChan
The language "design" is just an abstract/concrete/theoretical description of the language? (Cant describe it but if you take a look at the C++20 standard that can be bought online, you will see what i mean) This standard is then given to the compiler programmers who are then responsible for implementing the described features
DaviChan
But would have to look that up again
DaviChan
For javascript there is the ECMA standard that gets implemented by browser developers
DaviChan
For example chrome has the V8 virtual javascript machine, that is also the backend for node.js
DaviChan
I think it was written in C, not sure.
DaviChan
Javascript is a bit of a mess, because there are competing standards to ECMA-script. But that is the one implemented by chrome, firefox and so on
DaviChan
Nothing. ECMA is one standard for javascript.
Anonymous
Wikipedia say v8 writed by assembly, cpp, ecma and js🤷‍♂
DaviChan
Uhhm like in javascript its like this: at the beginninge each browser had its own "dialect", so there are now standards where browser developers agree on standards that each one needs to support. One and the most common standard is ECMA
Anonymous
Js engine is the same js compiler?
DaviChan
Almost. Js was interpreted and now is most pftenly ahead of time compiled, to meet the performance needs for modern websites. So it is kinda the same.
DaviChan
Sorry, just in time compiled
DaviChan
Wikipedia say v8 writed by assembly, cpp, ecma and js🤷‍♂
Like you said here ✌😂 You might have a look at the V8 source code on github... might be overwealming (i never looked at it), but after staring long enough, you might be able to understand the inner workings better?
Anonymous
Everything is c😊
DaviChan
There are some books on language/compiler design also. I can link some later. A classic one is: the red dragon book ^^
DaviChan
Not my favourite, but its a classic
Anonymous
Not my favourite, but its a classic
I should go for hello world first😊
DaviChan
I think it overcomplicates some things. If you take a look at the llvm-project, that is a well designed modern compiler toolchain ^^
DaviChan
i believe you're talking about the dragon book
Yes! But there was also one with a blue dragon on it, thats why i specified
DaviChan
I should go for hello world first😊
Yes sure, sorry... too much information ^^.
Anonymous
Yes sure, sorry... too much information ^^.
It was good, thanks for your time😊🙏
DaviChan
Everything is c😊
Except if you dont have a c compiler :p (pokemon games where still written in assembler and sometimes machine code directly for some specific optimizations)
Anonymous
C's father
DaviChan
Except if you don't have an assembler and you imeplement stuff in hardware.
Yeah, but an assember is rather easy to write. I would do that! If you have to write things directly in machine code, you will get insane ^^. But yes, true, you can also program physically with hardware gatters. But im a programmer, not a machinist or hardware developer or sth. So i will stay away from that :p
DaviChan
All you really need is transistors. Everything else can be build up from that 😂 and has been
DaviChan
Luckily that has been done already ^^
Leonardo
Python in fake C...change my mind
『TY』ϻʳησ𝐁Ⓞ𝕕Ƴ 657
hello
DaviChan
I mean the syntax is very different 🤔
『TY』ϻʳησ𝐁Ⓞ𝕕Ƴ 657
#include <stdio.h> void main() { int arr[100]; int i,n; printf("\n\nEnter Size:"); scanf("%d",&n); for(i=1; i<=n; i++) { printf("Enter element %d : ",i); scanf("%d", &arr[i]); } printf("["); for(i=1; i<=n; i++) { printf("%d,", arr[i]); } printf("]");
『TY』ϻʳησ𝐁Ⓞ𝕕Ƴ 657
i cannot remove the last comma🤔
『TY』ϻʳησ𝐁Ⓞ𝕕Ƴ 657
Enter Size:3 Enter element 1 : 1 Enter element 2 : 1 Enter element 3 : 1 [1,1,1,]
Leonardo
In what sense?
In sense that behind python code there is c code
DaviChan
Yes you can ^^ replace "%d," with i<n?"%d,":"%d"
Leonardo
for this reason python is less fast than c
DaviChan
Thats why it is a scripting language
『TY』ϻʳησ𝐁Ⓞ𝕕Ƴ 657
the comma exceed on last 1,1,1,
DaviChan
for this reason python is less fast than c
Like it does not try to "fake" C at all, the syntax is clearly different. It is just another abscraction layer to make using C easier. C is just an abstraction layer to make using asm easier, asm is just an abstraction/translation layer to make using machine code easier.