𝙰𝚖𝚖𝚊𝚛
Thank you, how can i know if the array (1D) is symmetric
olli
for an array of length N you should check whether array[i] == array[N - 1 - i] for all i < N We won't write the code for you, we can help you fix it tho.
𝙰𝚖𝚖𝚊𝚛
for an array of length N you should check whether array[i] == array[N - 1 - i] for all i < N We won't write the code for you, we can help you fix it tho.
#include <iostream> using namespace std; int main () { int n,i,q; cout << "please enter number of elements"; cin >> n; int A[n]; cout << "enter elements"; for (i=0;i<n;i++) cin >> A[n]; for (i=0;i<n;i++) cout << A[n] << " "; for (i=0;i<n;i++) if (A[i] == A[n-1-i]) q=1; else q=0; if (q==0) cout << "Yes"; else cout << "No"; return 0; }
𝙰𝚖𝚖𝚊𝚛
Is this code true or false? And is there another way ?
Suka
i want it to ask 12 times if that makes sense😁
A beginners' guide away from scanf() http://sekrit.de/webdocs/c/beginners-guide-away-from-scanf.html
Suka
wow, thanks a lot
you're welcome
Junaid
Can any one please justify between static and dynamic scoping or share its learning source
olli
Can any one please justify between static and dynamic scoping or share its learning source
dynamic scoping is not used in most programming languages. In the following example bar would return 2 for dynamic scoping and 1 for static scoping. int x = 1; int foo() { return x; } int bar() { int x = 2; return foo(); } When we return x from foo, our simpified stack looks like this | <omitted> | | x = 2 | | <omitted> | | x = 1 | dynamic scoping returns the most recent version of x at that time (which is x=2) where as static scoping returns x from the closest scope of the function
Junaid
#include<stdio.h> #include<stdlib.h> int a,b; void print(){ {printf("%d %d",a,b);} } int fun2() { int b=4; a=3; print(); } int fun1() { int a,c; a=0;b=1;c=2; return c; } int main() { a=fun1(); fun2(); }
𝙰𝚖𝚖𝚊𝚛
have you tried running it
Yes, it worked, but i want to know if there is another way
Артём
not able to understand why its printing b=1 instead of b=4,i know its due to static scoping but not able to understand how
because there is no variable b in local scope of print(), global var b is printed, which is 1.
Junaid
because there is no variable b in local scope of print(), global var b is printed, which is 1.
but why its printing a=3,because global value of a is 2 not 3,and as above there is no variable a in local scope of print()
Артём
but why its printing a=3,because global value of a is 2 not 3,and as above there is no variable a in local scope of print()
global var a isn't 2, it is 3. in the second line of fun2() it is getting equal to 3, then print() is just called.
Junaid
global var a isn't 2, it is 3. in the second line of fun2() it is getting equal to 3, then print() is just called.
oh i got it you means int b=4 in fun2() is local of fun2() but 'a' in fun2() is using global one
Артём
Junaid
yeah, is there any declaration of a in fun2()? No, then it is global.
thank u very much i was just stuck because of a=3,int a=3 thank you
Roshan
Does anyone know why only VS uses _getch() and strcpy_s() or sth like that?
piggyho
i believe u need malloc for dynamic array cmiiw
you do did you try compiling? it would tell you
John
Looking for a competent C++ guru to help me out please. WhatsApp 0703453175
Junaid
any html and css guy there
Anonymous
Hey, I’m new here
Anonymous
Anyone wants to interact? Plus I will help anyone with c, python, java and computer science related programs
Anonymous
You can help me too
Anonymous
Does that sound good?
Anonymous
may be
Priya
What is the output for the following c++ program #include<iostream> using namespace std; class trial {     int x:     public:     void assign(int y)     {         x=y;     }     void test(trial obj1,trial obj2)     {         obj1.x=10;         obj2.x=20;         cout<<"\n value of object1:"<<obj1.x;         cout<<"\n value of object2:"<<obj2.x;     }     void display()     {         cout<<x;     }     };     int main()     trial a1,a2,a3;     a2.assign(45);     a1.assign(54);     cout<<"\n value of first assignment:";     a2.display();     cout<<"\n Value of second assignment:";     a1.display();     a3.test(a1,a2);     cout<<"\n Value of first assignment after passing the values:";     a2.display();     cout<<"\n Value of second assignment after passing the values:";     a1.display();     return 0;     }
Roshan
What is the output for the following c++ program #include<iostream> using namespace std; class trial {     int x:     public:     void assign(int y)     {         x=y;     }     void test(trial obj1,trial obj2)     {         obj1.x=10;         obj2.x=20;         cout<<"\n value of object1:"<<obj1.x;         cout<<"\n value of object2:"<<obj2.x;     }     void display()     {         cout<<x;     }     };     int main()     trial a1,a2,a3;     a2.assign(45);     a1.assign(54);     cout<<"\n value of first assignment:";     a2.display();     cout<<"\n Value of second assignment:";     a1.display();     a3.test(a1,a2);     cout<<"\n Value of first assignment after passing the values:";     a2.display();     cout<<"\n Value of second assignment after passing the values:";     a1.display();     return 0;     }
Tremendous warnings and some errors
olli
What is the output for the following c++ program #include<iostream> using namespace std; class trial {     int x:     public:     void assign(int y)     {         x=y;     }     void test(trial obj1,trial obj2)     {         obj1.x=10;         obj2.x=20;         cout<<"\n value of object1:"<<obj1.x;         cout<<"\n value of object2:"<<obj2.x;     }     void display()     {         cout<<x;     }     };     int main()     trial a1,a2,a3;     a2.assign(45);     a1.assign(54);     cout<<"\n value of first assignment:";     a2.display();     cout<<"\n Value of second assignment:";     a1.display();     a3.test(a1,a2);     cout<<"\n Value of first assignment after passing the values:";     a2.display();     cout<<"\n Value of second assignment after passing the values:";     a1.display();     return 0;     }
none, because it doesn't even compile
Roshan
What is the output for the following c++ program #include<iostream> using namespace std; class trial {     int x:     public:     void assign(int y)     {         x=y;     }     void test(trial obj1,trial obj2)     {         obj1.x=10;         obj2.x=20;         cout<<"\n value of object1:"<<obj1.x;         cout<<"\n value of object2:"<<obj2.x;     }     void display()     {         cout<<x;     }     };     int main()     trial a1,a2,a3;     a2.assign(45);     a1.assign(54);     cout<<"\n value of first assignment:";     a2.display();     cout<<"\n Value of second assignment:";     a1.display();     a3.test(a1,a2);     cout<<"\n Value of first assignment after passing the values:";     a2.display();     cout<<"\n Value of second assignment after passing the values:";     a1.display();     return 0;     }
#include <iostream> using namespace std; class trial{     int x ;     public :     void assign(int y){         x = y; } void test(trial obj1, trial obj2){ obj1.x = 10; obj2.x = 20; cout << "\n value of object1:" << obj1.x; cout << "\n value of object2:" << obj2.x; } void display(){         cout << x; } };     int main(){     trial a1, a2, a3;     a2.assign(45);     a1.assign(54);     cout << "\n value of first assignment:";     a2.display();     cout << "\n Value of second assignment:";     a1.display();     a3.test(a1, a2);     cout << "\n Value of first assignment after passing the values:";     a2.display();     cout << "\n Value of second assignment after passing the values:";     a1.display(); }
Roshan
Compile this and find your answer
Anonymous
Master Class on Dynamic Programming Description: Dynamic programming is heavily used in computer networks, routing, graph problems, computer vision, artificial intelligence, machine learning etc. However, Dynamic Programming continues to be a perpetual enigma for all the programming students. It is a crucial topic to crack technical interview rounds at the leading bigwigs. To help you understand the various realms of Dynamic Programming, Coding Ninjas is conducting an exclusive masterclass on 12 th December from 7 PM onwards, hosted by ace faculty of Coding Ninjas Navdeep Sandhu. Here’s what you can learn during the Dynamic Programming Masterclass: ● What is Dynamic programming ● Basics of Dynamic programming ● How to practice Dynamic programming ● Examples of Dynamic programming ● Difference between greedy and Dynamic programming ● Knapsack problem using Dynamic programming ● Dynamic programming approach ● Dynamic programming algorithm ● Dynamic programming problems ● How to solve Dynamic programming problems ● Dynamic programming in DAA ● It's a technique that makes it possible to adeptly solve difficult problems, which is why it comes up in interviews and is used in applications like machine learning. Here’s your chance to upskill your dynamic programming techniques for the ongoing and upcoming interview placement rounds. Event link - https://www.codingninjas.com/events/master-class-on-dynamic-programming?utm_campaign=webinar_DP_cn2341&utm_source=campus-ambassador&utm_medium=referral&campaign=webinar_DP_cn2341&source=campus-ambassador Event Date and Time- 12 th December from 7 PM onwards It would be beneficial for all the students, as you all will be able to revise all the topics of Dynamic Programming for your coming examinations. And it will also help those as well who have any doubts in it. SO DO REGISTER TO ACE YOUR EXAMS, as the Session will be conducted by ace faculty of CODING NINJAS Navdeep Sandhu Moreover its free of cost
Roshan
Hey I've a question, how can we do function overloading in abstract and inherited class and the problem is I'm not able to access the abstract base class's function.
Junaid
Master Class on Dynamic Programming Description: Dynamic programming is heavily used in computer networks, routing, graph problems, computer vision, artificial intelligence, machine learning etc. However, Dynamic Programming continues to be a perpetual enigma for all the programming students. It is a crucial topic to crack technical interview rounds at the leading bigwigs. To help you understand the various realms of Dynamic Programming, Coding Ninjas is conducting an exclusive masterclass on 12 th December from 7 PM onwards, hosted by ace faculty of Coding Ninjas Navdeep Sandhu. Here’s what you can learn during the Dynamic Programming Masterclass: ● What is Dynamic programming ● Basics of Dynamic programming ● How to practice Dynamic programming ● Examples of Dynamic programming ● Difference between greedy and Dynamic programming ● Knapsack problem using Dynamic programming ● Dynamic programming approach ● Dynamic programming algorithm ● Dynamic programming problems ● How to solve Dynamic programming problems ● Dynamic programming in DAA ● It's a technique that makes it possible to adeptly solve difficult problems, which is why it comes up in interviews and is used in applications like machine learning. Here’s your chance to upskill your dynamic programming techniques for the ongoing and upcoming interview placement rounds. Event link - https://www.codingninjas.com/events/master-class-on-dynamic-programming?utm_campaign=webinar_DP_cn2341&utm_source=campus-ambassador&utm_medium=referral&campaign=webinar_DP_cn2341&source=campus-ambassador Event Date and Time- 12 th December from 7 PM onwards It would be beneficial for all the students, as you all will be able to revise all the topics of Dynamic Programming for your coming examinations. And it will also help those as well who have any doubts in it. SO DO REGISTER TO ACE YOUR EXAMS, as the Session will be conducted by ace faculty of CODING NINJAS Navdeep Sandhu Moreover its free of cost
provide something on static programming
Anonymous
provide something on static programming
Sure in coming days there will be more
Anonymous
Hi i have an issue with my code in C i want to print a float in integers how can i do this?
Xudoyberdi
Use %d instead of %d
Excuse me? 😁
Roshan
You wanna use conversion?
Better do you have any solution?
Junaid
Use %d instead of %d
D is replaced by f mistake
Anonymous
You wanna use conversion?
i just want mh user give a float number and then seprate the int and float but i want the float part to be integer
Anonymous
Use %d instead of %d
doesn't work
Xudoyberdi
Stuck here...
Sorry bro I've been coding for couples of months not much experience😕
Junaid
doesn't work
i think you want to seprate values after and before decimal
Roshan
yes exactly
(1) typecast the float to int and store it in a variable. (2) subtract them to get the part after dot also.
Junaid
yes exactly
bro amir i have code but now i am taking exam i will send it to you later untill i send it to you try yourself
Xudoyberdi
i just want mh user give a float number and then seprate the int and float but i want the float part to be integer
float a; int b; printf("Enter a floating-point number: "); scanf("%f", &a); b=(int)a; printf("%d", b);
Anonymous
Roshan
Some typing mistakes...
Anonymous
Oh
i have an error for int (a)
Anonymous
expected expression before int? 🤔
Xudoyberdi
i have an error for int (a)
#include <stdio.h> int main() { float a; printf("Enter a floating-point number: "); scanf("%f", &a); int b=a; printf("%d", b); return 0; }
Xudoyberdi
relief finally
Anonymous
#include <stdio.h> int main() { float a; printf("Enter a floating-point number: "); scanf("%f", &a); int b=a; printf("%d", b); return 0; }
for example my number is 254.92 i want to print 254 in one variable and print 0.92 as an integer like 92 in other variable
Xudoyberdi
Lemme think
Roshan
Lemme think
Somebody's bio said, "Calm bruh you got this act cool" 😂