olli
again, you need multiple indices, a_i and b_i and c_i e.g. size_t a_i = 0; size_t b_i = 0; size_t c_i = 0; while (a_i < a_s && b_i < b_s) { // .... }
Smart Devil 😈
Hi
olli
what is this code about ?🤨
merging two sorted arrays (obv doesn't work, just the idea how to get started)
olli
so you sorted them successfully?
It's not my assignment, just wanted to provide part of the basic skeleton for someone else
Frederick
I NEED A SITE TO UNLOCK MODEM
Anonymous
Anonymous
after the loop, lst will be NULL } else { while(lst != nullptr){ lst = lst->getLink(); } lst->setLink(newnode); ^^^
I even corrected this, and in fact manually traced the segmentation error, the method isn't even being called in the second iteration
olli
I even corrected this, and in fact manually traced the segmentation error, the method isn't even being called in the second iteration
From the information given, GDB suggests otherwise Program received signal SIGSEGV, Segmentation fault. in Node::setLink (this=0x0, p=@0x7ffffff1d8: 0x7fbdc2c020) ^^^^^^^^ at codebeautify.cpp:316 316 void Node::setLink(const NodePtr& p) { link = p; } ^^^^^^^ (gdb) In all the code you shared, there is only one call to setLink. Now, surely the faulty call can happen anywhere (e.g. swap), but since we neither have the full code nor the stacktrace it's up to you to figure that one out While tail_insert was calling setLink on NULL, I don't see any more places - so, can't repro Please follow #mcve
Raru
Change this code with functions pointers and dynamic memory allocation
Anonymous
/how can i code this using c ?
Andrew
/how can i code this using c ?
"how" is to generic, focus on steps you have to take in order to solve it
Anonymous
"how" is to generic, focus on steps you have to take in order to solve it
#include<stdio.h> #include <stdlib.h> int main() { float fullBord[3] = {25555,17500,9000}; float halfBord[3] = {1500,12500,7250}; float cardDiscounts[3] = {12.5,11.5,9.5}; int roomType; char packge; int days; char cardType; float price; int selectedRoom; float discount; float total; float discountedTotal; //infinite loop for(;;) { printf("\nEnter room type :"); scanf(" %d",&roomType); // if user print -1 stop the proccess // since array starts with 0 map user entered value with array index if(roomType == 1) { selectedRoom = 0; } else if(roomType == 2) { selectedRoom = 1; } else if(roomType == 3) { selectedRoom = 2; } else { printf("Invalid Input"); break; } printf("Enter accommodation type (F/H) : "); scanf(" %s",&packge); printf("Enter number of days : "); scanf(" %d",&days); printf("Enter card type (G/S/B) : "); scanf(" %s",&cardType); //get price based on the user entered accommodation details if(packge =='F') { price = fullBord[selectedRoom]; } else { price = halfBord[selectedRoom]; } //select discount based card type if(cardType == 'G') { discount = cardDiscounts[0]; } else if(cardType == 'S') { discount = cardDiscounts[1]; } else if(cardType == 'B') { discount = cardDiscounts[2]; } else { discount = 0; } //calculate total total = price * days; //calculate disconut total discountedTotal = total - (total * discount /100); printf("\nDiscount : %.2f ",discount); printf("\nAmount(RS): %.2f ",discountedTotal); } }
Anonymous
is it correct ?
Andrew
Idk, it works on your pc?..btw you could use enums to make it more readable
Tangent Alpha
is it correct ?
does it give the correct output with relevant input?
Tangent Alpha
yes
there you go :)
Chidinma
Hello
ברני
I need help from scartch from the beginnin
Go to YouTube, look for c for beginners videos, and from there you can look for tasks and ways to code in Google
Anonymous
Can anybody explain how you create a linked list with n node?
Anonymous
It's a simple concept but I am having trouble implementing it
Alex
what do you mean with n node?
Alex
do you need regular linked list with size n?
Don Peter Joseph
https://pastebin.com/FWX5UyUH
Don Peter Joseph
i how some problem at inserting
Don Peter Joseph
enter the no of elements in array:3 enter the elements: enter element at 0:1 2 enter element at 1:3 enter element at 2:4 the unsorted list is :1 2 3 the sorted array is :1 2 3
olli
i dont know but it is making me input 2 elements in 0th position
You can change you format string to ignore leading whitespace characters by replacing "%d " with " %d" for (int i = 0; i < s; i++) { printf("\nenter element at %d:", i); scanf("%d ", &arr[i]); ^^^^
olli
got it. i never thought there was a difference.
why shouldn't there be any difference? " a" is not the same as "a "
Don Peter Joseph
why shouldn't there be any difference? " a" is not the same as "a "
i thought it is just white space before and after.how could it affect my loop.
olli
i thought it is just white space before and after.how could it affect my loop.
You could "peek" at stdin (getchar + ungetc) to see which character will be read next. Your loop tries to read (char)10 (*) which is not a digit and hence the format string does not match (*) assuming you're entering the values on a local cmd, depending on the exact interaction the result might differ
king
Any one help
VCM
Any notes on C++ language please
Anonymous
Any notes on C++ language please
learn rust it's the modern c++
VCM
learn rust it's the modern c++
Any guideline PDF on it please?
VCM
google it
👍👍
Makgato
Guys how to do back end and front end when u create app
𓂆 Noha
Can you help me please
Anonymous
Can you help me please
Try it yourself , first
Makgato
Google
Ok thanks
𓂆 Noha
Sorry🥺
@
هل في احد عربي
Anonymous
هل في احد عربي
/warn non English
@
Ok
Anonymous
Good morning
Talula
هل في احد عربي
Yes... but people don't speak Arabic here.
Oleh
Hi everyone!
Truth
Hi everyone!
hello how are ya
Oleh
hello how are ya
I'm ok, thanks)
Anonymous
Hello World!
blessings
hello members help me with this.
blessings
i have a question
Dima
i have a question
Read the rules
blessings
Read the rules
ok have read
blessings
good afternoon guys
blessings
Using decision making statement(s), Write a simple program that can be used by security personel to check if a person being scanned at the gate is a positive suspect for corona virus, the program should record person's names department and body temperature, the test condition for your program is: if the temperatures recorded is above 38, The program should alert the personel that the student is suspected to be sick and procedure is to be isolated, if not he should be let in freely with a ‘normal temperature’ alert.
blessings
i tried but it didn't work
olli
i tried but it didn't work
#mcve what have you tried?
Nils
How do I round up numbers to multiplies of 16?
Ammar
How do I round up numbers to multiplies of 16?
Try this one: #include <stdio.h> #include <stdint.h> int main() { uint32_t i = 20; uint32_t tmp = i & -16; while (tmp < i) { tmp += 16; } i = tmp; printf("%d", i); }
Nils
inline static uint64_t size_align(uint64_t num) { return ((num + sizeof(struct memchunk_free) - 1) / sizeof(struct memchunk_free)) * sizeof(struct memchunk_free); } This did the trick for now