Talula
Have you experienced FPGA programming
FPGA is good for playing around with but using it is bit of an overkill in most applications, unless you want to make one board that does almost everything.
Anonymous
Can someone assist me with codes for Date validation and include leap years
#include <stdio.h> void main() { int d,m,y; int daysinmonth[12]={31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int legit = 0; printf("Enter the date - DD/MM/YYYY :: "); scanf("%i/%i/%i",&d,&m,&y); // leap year checking, if ok add 29 days to february if(y % 400 == 0 || (y % 100 != 0 && y % 4 == 0)) daysinmonth[1]=29; // days in month checking if (m<13) { if( d <= daysinmonth[m-1] ) legit=1; } if (legit==1) printf("It is a valid date!\n"); else printf("It's not valid date!"); }
Anonymous
Welcome
Alfon
Evening, can you help me with the logic? if the value of A = 0 then B = 0 if the value of A = 1 then B = 0 if the next value A = 2 then B = 2 if the next value is A = 3, then B = 0 and B at index A = 3 B = 3 basically take the max value in the array, can anyone help?
Alfon
example : https://prnt.sc/26bpek4
Alfon
try to explain it
please help, example array A = [1,2,3,4, 0, 1, 2] array B = [0,0,0,4, 0, 0, 2]
Anonymous
what we have to with it?
TL
What would be the best way to store the heights of six people? 1.an array of six floats 2. a structure containing six floats 3. six floating point variables
Anonymous
a structure?
TL
1
thanks , but what it mean by six floating point variable ?
TL
a structure?
ya, option 2 is wrong
\Device\NUL
thanks , but what it mean by six floating point variable ?
ex. p1 = 60.0 p2 = 50.0 p3 = 40.0 ..., p6 = 10.0
TL
ex. p1 = 60.0 p2 = 50.0 p3 = 40.0 ..., p6 = 10.0
i still dont understand it . can show me full example please .
TL
Here, i edited it
thanks , understood now
ㅤㅤㅤ
Whats wrong with my code. question - codeforces problem 339A #include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); str a[100]; int n[50]; int i =0; while(a[i]!='\0'){ cin>>a[i]; } for(int i=0,j;i<100,j<50;i+2,j++){ n[j]=stoi(a[i]); } sort(n,n.size); for(int i = 0;i<50;i++){ cout<<n[i]; while(i<49){ cout<<"+"; } } return 0; }
\Device\NUL
also, a array is uninitialized
ㅤㅤㅤ
\Device\NUL
string
Any mesage from the compiler ?
\Device\NUL
It should be enough to solve the problem
ㅤㅤㅤ
Any mesage from the compiler ?
Demo.cpp: In function 'int main()': Demo.cpp:8:2: error: 'str' was not declared in this scope; did you mean 'std'? 8 | str a[100]; | ^ | std Demo.cpp:11:8: error: 'a' was not declared in this scope 11 | while(a[i]!='\0'){ | ^ Demo.cpp:15:13: error: 'a' was not declared in this scope 15 | n[j]=stoi(a[i]); | ^ Demo.cpp:17:11: error: request for member 'size' in 'n', which is of non-class type 'int [50]' 17 | sort(n,n.size); | ^~
klimi
and are you using some c/c++ web framework or from scratch?
MᏫᎻᎯᎷᎷᎬᎠ
.
klimi
so you are coding a c/c++ web server that would serve simple html project?
klimi
or are you just using some CGI?
Pavel
So is it related in any way to C/C++?
mito
struct node { int data; struct node *next; } struct node *head; I have already alocated memory to head node. head = malloc(sizeof(struct node)); And created a bunch of other nodes linked to it by struct node *temp; for (int i=0; i < no_of_nodes - 1; i++) { struct node *n = malloc(sizeof(struct node)); temp -> next = n; printf("Enter Node %d data : ", i+1); scanf("%d", &(n -> data)); temp = n; } temp -> next = NULL; Then my printNodes function void printNodes(struct node *n) { //printf("%d", n -> data); while(n != NULL) { if (n -> next != NULL) printf("%d%s", n -> data, " -> "); else printf("%d%s", n -> data, " -> NULL\n"); n = n->next; } } The output will look like : 6 -> 7 -> 8 -> 9 -> 3 -> NULL Now, i'm trying to insert a node at head node, i.e it becomes the head node and the original head becomes the second node. printf("Enter the head position (obviously 0) : "); scanf("%d", &pos); insertNode(head, pos); printNodes(head); The insertNode function : void insertNode (struct node *head, int pos) { struct node *n; n = malloc(sizeof(struct node)); printf("Enter the Node data : "); scanf("%d", &(n -> data)); if (pos == 0) { printf("Pos was 0, so HEAD\n"); n -> next = head; head = n; printNodes(head); } } Ok, so the problem is that, the printNodes(head) actually prints the as intended.. but the printNodes(head); after insertNodes(head, pos) doesn't print the updated Linked List, why is the head not being updated ? Where did I do wrong ?
mito
Output: Enter the Head position (obviosuly 0 : 0 Enter the Node data : 34 Pos was 0, so HEAD 34 -> 6 -> 7 -> 8 -> 9 -> 3 -> NULL [from printNodes(head) inside inserNodes(head, pos)] 6 -> 7 -> 8 -> 9 -> 3 -> NULL [from printNodes(head) after insertNodes(head, pos)]
mito
If full code is needed, here you go.
Anonymous
Output: Enter the Head position (obviosuly 0 : 0 Enter the Node data : 34 Pos was 0, so HEAD 34 -> 6 -> 7 -> 8 -> 9 -> 3 -> NULL [from printNodes(head) inside inserNodes(head, pos)] 6 -> 7 -> 8 -> 9 -> 3 -> NULL [from printNodes(head) after insertNodes(head, pos)]
The head pointer is being passed by value to insertNode function. Any changes to the head pointer inside insertNodes will not be reflected in main. If you want the changes to head pointer inside insertNode to be reflected inside main, you must pass a pointer to head pointer (i.e. a Node** pointer) to insertNode function.
Anonymous
so, it should be insertNodes(*head, pos); ?
The prototype for insertNode should be void insertNode(struct node **n, int pos); and the call would be like insertNodes(&head, pos);
TL
typedef struct person { char name[MAXLEN]; float height; int age; } person; person p[100]; float *f = &(p[5].height); float matrix[3][6]; Q1. Suppose the array of people starts at memory location 0x4000. What is the value of f? 1) 0x4000 2) 0x4000 + 4*(MAXLEN + 8) + MAXLEN 3) 0x4000 + 4*(MAXLEN + 8) + MAXLEN + 4 4) 0x4000 + 5*(MAXLEN + 8) + MAXLEN 5) 0x4000 + 5*(MAXLEN + 8) + MAXLEN + 4 Q2.Suppose matrix starts at location 100 in memory. All answers are expressed in decimal, not hexadecimal, in this problem. What address contains matrix[2][1]?
TL
is there any online compiler can run this code and get the answer? cause i cant visualise 😭
Krishnaa
Hello
Krishnaa
Why my visual studio says "undefined reference to 'WinMajn@16' " when I try to run my C++ code????
Anonymous
what is code about?
klimi
Oh I see I thought its the same question
klimi
Oh damn, its written in multiple messages :(
Eng.Iman
Good evening
Eng.Iman
I am studying C++ And i joined the group to learn more about programming with c++
Eng.Iman
that's noice
I feel i am lost My professor told me that i am thinking mathematly, it's more simple than that
Jessy
Anyone interested in pair programming in dsa or web dev
Web development. I'm a CE student.
Anonymous
typedef struct person { char name[MAXLEN]; float height; int age; } person; person p[100]; float *f = &(p[5].height); float matrix[3][6]; Q1. Suppose the array of people starts at memory location 0x4000. What is the value of f? 1) 0x4000 2) 0x4000 + 4*(MAXLEN + 8) + MAXLEN 3) 0x4000 + 4*(MAXLEN + 8) + MAXLEN + 4 4) 0x4000 + 5*(MAXLEN + 8) + MAXLEN 5) 0x4000 + 5*(MAXLEN + 8) + MAXLEN + 4 Q2.Suppose matrix starts at location 100 in memory. All answers are expressed in decimal, not hexadecimal, in this problem. What address contains matrix[2][1]?
basically here you have to work with a array with pointers and second thing you didn't defined MAXLEN and the p[100] array values to access them and here In fist Question you have to find values of f at the starting location of array (and array in c++ is a list or set of homogenous data ) which will be &p[0] and then apply further address to pointer f and show values of f and In second Question you have a matrix filled with all the decimal number (but here you just initialized the matrix and not giving values to him ) and they just want the address of matrix[2][1]. So for this you have to point it(matrix[2][1]) with pointer f and show the address and I hope you got the idea
Muhnnad2
Hi can someone one guide me to learn this language? I'm already searched in YouTube but I lost its to big huge world 🌎 😢 I'm just love programming
Anonymous
Hi can someone one guide me to learn this language? I'm already searched in YouTube but I lost its to big huge world 🌎 😢 I'm just love programming
find books from here and do believe in yourself that you can do this and you will get it https://stackoverflow.com/questions/562303/the-definitive-c-book-guide-and-list
Muhnnad2
Or first just theory?right?
Anonymous
download msys2 for g++/gcc compiler if you are in windows
Anonymous
and download visual studio code
Muhnnad2
Okay 👌
Anonymous
set up vscode C++ with extensions and you ready to go with C/ C++
Felix
how would you solve this kind of problem Given a string, reduce it in such a way that all of its substrings are distinct. to do so, you may delete any characters at any index, what is the minimum number of deletions needed ? note: a substring is a contiguous group of 1 or more characters within a string example s = "abab" substrings s are {'a', 'b', 'a', 'b', 'ab', 'ba', 'ab', 'aba', 'bab', 'abab'}, by deleting one "a" and one "b", the string becomes "ab" or "ba" and all of its substrings are distinct. this required 2 deletions Function description create a function create a function getMinDeletions with following parameter(s) string s: the given string rteurns int: the minimum number of deletions required
Maeza
Hello, I'm currently teaching myself how to code in C. May someone please explain malloc for me, I somehow get lost can't really grasp the concept around it. Please 🙏
Muyi
thk u guys
🎶
Constraints 1 <= N <= 10^5 N-1 <= M <= N-1 1 <= col <= 10^5 1 <= A[i]j] <=N 0 <= State[i] <= 1 Sample Input Sample Output Explanation 1 1 only one node with value equal to 1. so we only need to reverse this node 2 1 and the answer is 1 All nodes already