Ameemo
do you know what a queue is? and what the operation enqueue and dequeue do? Sometimes it is helpful to draw it on a piece of paper :)
I did !! by using circular arrays and apply the enqueue and depueue that was given in the question but the problem is i couldn't submit my drawing because it is a website that only allows text answer so from drawing the circular arrays I found the answer thanks
Anonymous
Nice! Well done :)
B121065_Swoyam Siddharth Nayak
#include<iostream> #include<limits.h> using namespace std; int main(){ int n, max; max=INT_MIN; int origin[n]; for(int i=0;i<n;i++){ cin>>origin[i]; if(origin[i]>max){ max=origin[i]; } } int frequency[max+1]={0}; for(int i=0;i<n;i++){ frequency[origin[i]]++; } int temp=0; int cummulative_frequency[max+1]={0}; for(int i=0;i<(max+1);i++){ cummulative_frequency[i]=temp+frequency[i]; temp=cummulative_frequency[i]; } int sorted[n]; for(int i=0;i<n;i++){ int m=cummulative_frequency[origin[i]]-1; sorted[m]=origin[i]; } for(int i=0;i<n;i++){ cout<<sorted[i]<<" "; } return 0; } This is my program for count sort, where is the error, am getting no output
B121065_Swoyam Siddharth Nayak
Solved
B121065_Swoyam Siddharth Nayak
Count sort
Pitreedollar
Hello buddies
Pitreedollar
How do we test and ensure the function positive_or_negative() gives the correct output when given a case of 0.
Pavel
How do we test and ensure the function positive_or_negative() gives the correct output when given a case of 0.
You can return a enum value: positive, negative or zero, the name of the function states that it doesn't return a bool anyway (otherwise it would be named isPositive or isNegative). Or if in your case zero should be positive or negative in order to work properly just document it (place a comment before the function describing the case with zero).
ninja
this can't be your entire program?
ninja
what's the error
ninja
sry my English not good ... what is "go it"?
Anonymous
Anonymous
do it
Anonymous
[anyword] it
ninja
Anonymous
wide_t is data type?
Anonymous
int64_t is a macros too
Anonymous
type is autoselect by platform
Anonymous
Okay
Mar!o
int64_t is a macros too
int64_t is no macro it's a type alias
™barynium†⋆。˚🇧🇷
Thanks
Sachin
#include<stdio.h> int main( ) { int n[3][3] = { 2, 4, 3, 6, 8, 5, 3, 5, 1 } ; int i, *ptr ; ptr = n ; for ( i = 0 ; i <= 8 ; i++ ) printf ( "\n%d", *( ptr +i) ) ; } where is this ptr pointing ?
Sachin
where is this ptr pointing ?
Hanz
i think its n
Hanz
idk, im new
Ravi
True, its pointing to the starting address of matrix n that is first element
Ravi
But maybe array declaration should be like this, #include<stdio.h> int main( ) { int n[3][3] = { {2, 4, 3}, {6, 8, 5}, {3, 5, 1} } ;
Anonymous
Hi guys there is any library or macro in C++ which will map GUI domain of simulation softwares and generate reports and graphs at run time based on programme
Anonymous
?
Anonymous
Exercise: The code below does not compile, because the grades variable is missing. One of the grades is missing. Can you define it so the grade average will be 85? #include <stdio.h> int main() { /* TODO: define the grades variable here */ int average; grades[0] = 80; /* TODO: define the missing grade so that the average will sum to 85. */ grades[2] = 90; average = (grades[0] + grades[1] + grades[2]) / 3; printf("The average of the 3 grades is: %d", average); return 0; } Answer: #include <stdio.h> int main() { /* TODO: define the grades variable here */ int grades[3]; int average; grades[0] = 80; /* TODO: define the missing grade so that the average will sum to 85. */ grades[1] = 85; grades[2] = 90; average = (grades[0] + grades[1] + grades[2]) / 3; printf("The average of the 3 grades is: %d", average); return 0; } I have a doubt, what's int grades[3]; means? also we can get the exact same answer by plugin int grades[5];.can somebody explain this?
Anonymous
can u simply explain what's int grade[3] means ?
Ravi
can u simply explain what's int grade[3] means ?
that means 3 * sizeof(int) memory will be allocated to the array grade and you can access 0th 1st and 2nd element of that
Ravi
grade[5] means the size of 5 will be allocated to grade array, but here, our requirement is only upto 3 so, 2*sizeof(int) memory will be wasted for this particular program
Anonymous
can u simply explain what's int grade[3] means ?
Basically means u have built a cabinet with 3 drawers...
m
what is this error in qt 5.6.2 android »»»»The process tried to write to a nonexistent pipe
m
this error occured when build with ant
Luffy
can anyone suggest me a good resource or a course for learning STL
Luffy
i am currently learning it from cplusplus.com
Hanz
Interactive learning 👆
Anonymous
i am currently learning it from cplusplus.com
STL in c++ is similar to collectors in java! U can follow any standard C++ reference book
R
What is the output? main() { register int x = 5; int *p; p=&x; x++; print(*p); } A. Error B. 5 C. 6 D. Garbage value
R
What is the output of the code given below static int data=5; void main() { int sum=0; do { sum=sum+data; } while(0< data--); print(sum); } A. 5 B. 15 C. 14 D. Error
Anonymous
5
Why 5? I think it's 6.
R
workbook
Anonymous
workbook
Then run the code in your IDE...
Anonymous
in village no internet
Then how are you here messaging?
Anonymous
Why 5? I think it's 6.
Its Post increment operator, and X is not called after increment. Directly pointer is referenced in next line so i think it is 5
Anonymous
in village no internet
IDE doesnt require internet
Anonymous
120kbps speed lol
More than enough for executing in online if you don't have an offline one already...
Anonymous
More than enough for executing in online if you don't have an offline one already...
Or you can use bots like rextester , don't know if it works for longer codes tho.
Anonymous
120kbps speed lol
You can try compiler explorer. Its lightweight and great.
Sachin
#include <stdio.h> struct student_info { char name[27]; int roll_no; int submarks; }; void enter(struct student_info s1) { printf("\nEnter the details of Student \n"); printf("Name:"); scanf(" %[^\n]s",s1.name) ; printf("Roll Number:"); scanf("%d",&s1.roll_no) ; printf("Marks in subject : "); scanf("%d",&s1.submarks) ; } void display(struct student_info s2) { printf("\n\nName: %s", s2.name) ; printf("\nRoll Number: %d", s2.roll_no) ; printf("\nSubmarks: %d", s2.submarks) ; } int main() { struct student_info student; enter(struct student_info student); display(struct student_info student); } is me ky error hai?
Sachin
what is the errror?
Anonymous
That too require internet
If you don't have offline compiler, you can try it.
Sachin
#include <stdio.h> struct student_info { char name[27]; int roll_no; int submarks; }; void enter(struct student_info *s1) { printf("\nEnter the details of Student \n"); printf("Name:"); scanf(" %[^\n]s",s1->name) ; printf("Roll Number:"); scanf("%d",&s1->roll_no) ; printf("Marks in subject : "); scanf("%d",&s1->submarks) ; } void display(struct student_info s2) { printf("\n\nName: %s", s2.name) ; printf("\nRoll Number: %d", s2.roll_no) ; printf("\nSubmarks: %d", s2.submarks) ; } int main() { struct student_info student; enter(&student); display( student); }
Sachin
can you tell me why enter is call by address and display is call by value
Sachin
?
Anonymous
can you tell me why enter is call by address and display is call by value
The function "enter" should be called by pointer. So that it can modify the variable "student" rather than its copy. The function "display" can be called by pointer or value. Both cases you will get same output.
Sachin
dislpay is call by value hence s2 variable will copy the content of student variable and then print them ?
Sachin
is m right