Anonymous
yes.for each item how much they have been sold out
You just need to maintain a separate running counter for each individual items which you initialize to 0 and then when an item is ordered you add them to the specific counter of the item. You dont reset it to 0 for the next customer. You go on adding to this counter and display it all together at the end.
Ideally instead of maintaining separate counters, you can create classes for each item and let them do the hard work. Would make your code look better and also make it easy to make any changes in future.
Alieya MIN
classes? can be more detail? not understand little bit..
Anonymous
tao
Alieya MIN
Anonymous
Alieya MIN
ouhh okay thanks
tao
Anonymous
Let me studing in this. Thx a lot, having a good day!
You need to understand what tensors are. I guess you are already familiar with python and so must have used np.arrays from numpy. Tensors are the C/C++ equivalent of that. There are many ways you can create them. Look at the cppflow wrapper and see what methods are available. If not convenient, you can use the underlying Tensorflow API directly.
Code WHIZ
What is difference with size of object and size of class
Anonymous
Anonymous
Anonymous
Can you show me the output?
Anonymous
I tried the border cases on my local system as well
Anonymous
Anonymous
Anonymous
yes pls
you want to test any specific inputs
Anonymous
Anonymous
The samples ones, given in the question itself
Anonymous
Okay so it works :/ Will check it up again
Anyway, thanks a lot for entertaining my questions!
Anonymous
Anonymous
Anonymous
sure, but who are frowned upon and why?
sharing screenshots. People used to post pictures of the screen instead of taking a screenshot. To curb the menace, attaching files is now not allowed for anyone.
Anonymous
Code WHIZ
Why is that so because memory is allocated after object is created so for class there must be no memory.
And another question why does static member memory is counted for each object its only one for whole class
Code WHIZ
Code WHIZ
Is their any case when size of class and size object wont be same .
And i find a website saying classes dont have any size.
Anonymous
Code WHIZ
A simple class for eg. Class test {int a;}; containing various member variables.
Anonymous
No a class definition defined using class keyword.
Code WHIZ
VENUJAN
#include <stdio.h>
int main(){
int PhyMark = 65,MathMark = 72,ChemMark = 51;
int Total_3 = PhyMark + MathMark + ChemMark;
int Total_2 = PhyMark + MathMark;
if (PhyMark >= 51) and (MathMark >= 65) and (ChemMark >= 50){
if (Total_3 >= 190 ) or (Total_2 >= 137){
printf("This candidate is eligible for admission") ;
}
else{
printf("This candidate is not eligible for admission");
}
}
}
}
VENUJAN
Neeraj
Neeraj
VENUJAN
VENUJAN
#include <stdio.h>
int main(){
int PhyMark = 65,MathMark = 72,ChemMark = 51;
int Total_3 = PhyMark + MathMark + ChemMark;
int Total_2 = PhyMark + MathMark;
if (PhyMark >= 51) && (MathMark >= 65) && (ChemMark >= 50)
{
if (Total_3 >= 190 ) || (Total_2 >= 137)
{
printf("This candidate is eligible for admission") ;
}
else
{
printf("This candidate is not eligible for admission");
}
}
return 0;
}
Anonymous
VENUJAN
SR27
VENUJAN
whats wrong?
VENUJAN
#include <stdio.h>
int main(){
int PhyMark = 65,MathMark = 72,ChemMark = 51;
int Total_3 = PhyMark + MathMark + ChemMark;
int Total_2 = PhyMark + MathMark;
if (PhyMark >= 51)
{
if (MathMark >= 65)
{
if (ChemMark >= 50)
{
if (Total_3 >= 190 )
{
printf("This candidate is eligible for admission");
else if (Total_2 >= 137)
{
printf("This candidate is eligible for admission");
}
}
}
}
}
else
{
printf("This candidate is not eligible for admission");
}
return 0;
}
Anonymous
i mean by seeing constrains how can i get an idea that code should have time complexity of ....
If suppose say you have a linear complexity algorithm, and the size of inputs is 0 to 10000, then you know your algorithm will take 10 micro seconds approx on a computer that can execute 10^9 instructions per second. If the input size is 10^9, then for the same algorithm your time limit will be 1s or more which would give you a TLE error on most competitive programming sites(I guess you are a competitive programmer). Then you know that there must be a sub linear possibly logarithmic complexity algorithm and so on.
OnePunchMan
const int a = 3;
const int *ptr_to_a = &a;
int *ptr;
ptr = (int*)ptr_to_a;
cout<<(*ptr_to_a)<<" "<<ptr_to_a<<endl;;
cout<<(a)<<" "<<&a<<endl;;
cout<<*ptr<<" "<<ptr<<endl;
// changing here.
(*ptr) = 5;
cout<<(*ptr_to_a)<<" "<<ptr_to_a<<endl;;
cout<<(a)<<" "<<&a<<endl;;
cout<<*ptr<<" "<<ptr<<endl;
Output is
3 0x7ffe87e48554
3 0x7ffe87e48554
3 0x7ffe87e48554
5 0x7ffe87e48554
3 0x7ffe87e48554
5 0x7ffe87e48554
Can anyone explain why its giving output 3 while at same location im getting value 5.
Anonymous
OnePunchMan
Haziq
Hello,im new and i need a recommendation where to start learning C language
Any recommendation like books,website or video?
Sabuhi
Haziq
Raveesha
#include <stdio.h>
#include <string.h>
#define SIZE 5
#define SIZE2 20
struct customer{
int account;
char name[SIZE2];
char type;
float amount;
}customer[SIZE];
int main ( void )
{
int indexNo , test1 = 0 , test2 = 0;
float deposit = 0 , withdrawl = 0 , max , min;
char maxName[SIZE2] , minName[SIZE2];
// max = -1;
// min = 100000000;
for( indexNo = 0; indexNo < SIZE; indexNo++ )
{
printf ( "Enter your account number : " );
scanf ( "%d" , &customer[indexNo].account );
printf ( "Enter your name : " );
scanf ( "%s" , customer[indexNo].name );
printf ( "Enter your account type : " );
scanf ( "%*c%c" , &customer[indexNo].type );
printf ( "Enter your amount : " );
scanf ( "%f" , &customer[indexNo].amount );
if ( ( customer[indexNo].type == 'D' ) || ( customer[indexNo].type == 'd' ))
{
if ( test1 = 0 )
{
max = customer[indexNo].amount;
}
deposit += customer[indexNo].amount;
if ( max <= customer[indexNo].amount )
{
max = customer[indexNo].amount;
strcpy ( maxName , customer[indexNo].name );
}
test1 = 2;
}
else if ( ( customer[indexNo].type == 'W' ) || ( customer[indexNo].type == 'w' ))
{
if ( test2 = 0 )
{
min = customer[indexNo].amount;
}
withdrawl += customer[indexNo].amount;
if ( min >= customer[indexNo].amount )
{
min = customer[indexNo].amount;
strcpy ( minName , customer[indexNo].name );
}
test2 = 2;
}
printf ( "\n" );
}
printf ( "Total deposit amount : %.2f\n" , deposit );
printf ( "Total withdrawl amount : %.2f\n" , withdrawl );
printf ( "Name of the customer with the maximum deposit amount : %s\n" , maxName );
printf ( "Name of the customer with the minimum withdrawl amount : %s\n" , minName );
return 0;
}
Raveesha
theres error on withdrawl minimum amount can anyone check it?
Anonymous
guys help me
Anonymous
i dont know what do
Anonymous
Hello, i need help, why does my program isn't working
I show you my source code
Anonymous
#include <cstdio>
int main() {
int search (int left, int right) {
int mid = left;
int res = 0;
while (mid <= right) {
if (mid % 11 == 0) {
res++;
mid++;
}
else if (mid % 12 == 0) {
mid++;
else {
if (mid % 4 == 0) {
res++;
}
mid++;
}
}
return res;
}
}
Anonymous
With input (1, 100)
Please help me 🥲
@𝑺𝒐𝒃𝒌𝒂
Anonymous
Anonymous
I am learning pointers and pointer variable can access data and manipulate data through deference operator * , if that is the case how secure is data in pointer environment! Any one can access data with no security!
Anonymous
Code WHIZ
Oh true!
you will learn oop there is a concept called encapsulation there you will get to know in detail.
AJAY
Explain with an example the passing of a structure to a function by reference.
AJAY
Anonymous
Neeraj
Anonymous
Sandeep
In cpp...
The length function on a string is not the same as strlen on a char pointer...somebody explain this