Comments on: Find error in the C++ code https://demo.ritambhara.in/find-error-in-the-c-code/ Coding / System Design Interviews Wed, 15 Feb 2023 09:02:13 +0000 hourly 1 https://wordpress.org/?v=6.8.1 By: Crusher https://demo.ritambhara.in/find-error-in-the-c-code/#comment-7155 Wed, 15 Feb 2023 09:02:13 +0000 http://www.ritambhara.in/?p=443#comment-7155 # include
Using namespace std;
main()
{
int a,b;
cin>>a>>b;
if(a=b)
cout<<”a is equal to b”;
cout<<”endl”;
if else (a!=b)
Cout<<”a is not equal to b”<<endl;
}

]]>
By: Abhi https://demo.ritambhara.in/find-error-in-the-c-code/#comment-7087 Sun, 29 Jan 2023 13:29:49 +0000 http://www.ritambhara.in/?p=443#comment-7087 #include
using namespace std;
int main()
{
cout <> num;
copy= num;
while (num>0)
{
r= num%10;
rev= rev*10+r;
num= num/10;
}
if(copy==rev)
cout<<"the number is palindrome"
else
cout<<"the number is not palindrome"
return 0;
}

]]>
By: BlackHat https://demo.ritambhara.in/find-error-in-the-c-code/#comment-7042 Tue, 27 Dec 2022 10:18:00 +0000 http://www.ritambhara.in/?p=443#comment-7042 #include
#include
using namespace std;

int main() {
int number;
for (int i = 1; i <= 6; i++) {
cout << "Value of variable i is: " << i << endl;
}
return 0;
}

]]>
By: syed kamran shah https://demo.ritambhara.in/find-error-in-the-c-code/#comment-7033 Tue, 13 Dec 2022 17:34:56 +0000 http://www.ritambhara.in/?p=443#comment-7033 #include<iostream
Using namespace Std;
int main(){
int number;
for (int i=0;i<=6;i++)
{
cout<<"Value of the variable is :"<<number;
return 0;
}

]]>
By: sudhanshu https://demo.ritambhara.in/find-error-in-the-c-code/#comment-6924 Tue, 18 Oct 2022 15:02:44 +0000 http://www.ritambhara.in/?p=443#comment-6924 variable i type i,e int

]]>
By: hemant gacha https://demo.ritambhara.in/find-error-in-the-c-code/#comment-6902 Sun, 09 Oct 2022 05:59:21 +0000 http://www.ritambhara.in/?p=443#comment-6902 find errors :
#include
void main()
{ int public=10;
cout<public;
}

]]>
By: jnv Abhiram https://demo.ritambhara.in/find-error-in-the-c-code/#comment-6837 Mon, 05 Sep 2022 07:17:50 +0000 http://www.ritambhara.in/?p=443#comment-6837 find error in this program plz
Arduino code:

#define Relay 13
#define buzzer A0
static const int sensorPin = 10; // sensor input pin
int SensorStatePrevious = LOW; // previousstate of the sensor

unsigned long minSensorDuration = 3000; // Time we wait before the sensor active as long
unsigned long minSensorDuration2 = 6000;
unsigned long SensorLongMillis; // Time in ms when the sensor was active
bool SensorStateLongTime = false; // True if it is a long active

const int intervalSensor = 50; // Time between two readings sensor state
unsigned long previousSensorMillis; // Timestamp of the latest reading

unsigned long SensorOutDuration; // Time the sensor is active in ms

//// GENERAL ////

unsigned long currentMillis; // Variabele to store the number of milleseconds since the Arduino has started

void setup() {
Serial.begin(9600); // Initialise the serial monitor

pinMode(sensorPin, INPUT); // set sensorPin as input
Serial.println(“Press button”);
pinMode(Relay,OUTPUT);
pinMode(buzzer,OUTPUT);
}

// Function for reading the sensor state
void readSensorState() {

// If the difference in time between the previous reading is larger than intervalsensor
if(currentMillis – previousSensorMillis > intervalSensor) {

// Read the digital value of the sensor (LOW/HIGH)
int SensorState = digitalRead(sensorPin);

// If the button has been active AND
// If the sensor wasn’t activated before AND
// IF there was not already a measurement running to determine how long the sensor has been activated
if (SensorState == LOW && SensorStatePrevious == HIGH && !SensorStateLongTime) {
SensorLongMillis = currentMillis;
SensorStatePrevious = LOW;

Serial.println(“Button pressed”);
}

// Calculate how long the sensor has been activated
SensorOutDuration = currentMillis – SensorLongMillis;

// If the button is active AND
// If there is no measurement running to determine how long the sensor is active AND
// If the time the sensor has been activated is larger or equal to the time needed for a long active
if (SensorState == LOW && !SensorStateLongTime && SensorOutDuration >= minSensorDuration) {
SensorStateLongTime = true;
digitalWrite(Relay,HIGH);
Serial.println(“Button long pressed”);
}
if (SensorState == LOW && SensorStateLongTime && SensorOutDuration >= minSensorDuration2) {
SensorStateLongTime = true;
digitalWrite(buzzer,HIGH);
delay(1000);
Serial.println(“Button long pressed”);
}

// If the sensor is released AND
// If the sensor was activated before
if (SensorState == HIGH && SensorStatePrevious == LOW) {
SensorStatePrevious = HIGH;
SensorStateLongTime = false;
digitalWrite(Relay,LOW);
digitalWrite(buzzer,LOW);
Serial.println(“Button released”);

}

// store the current timestamp in previousSensorMillis
previousSensorMillis = currentMillis;

}

}

void loop() {

currentMillis = millis(); // store the current time
readSensorState(); // read the sensor state

}

]]>
By: Jishnu https://demo.ritambhara.in/find-error-in-the-c-code/#comment-6135 Wed, 24 Nov 2021 14:21:37 +0000 http://www.ritambhara.in/?p=443#comment-6135 #include
#include
class over
{
public:
void area(int);
void volume(int);
void area(int,int);
void volume(int,int,int);
};
void over::area(int a)
{
Int ar;
ar=a*a;
cout<<ar;
}
void over::volume(int a)
{
Int vol;
vol=a*a*a;
cout<<vol;
}
void over::area(int l,int b)
{
Int ar;
ar=l*b;
cout<<ar;
}
void over::volume(int l,int b,int h)
{
Int vol;
vol=l*b*h;
cout<<vol;
}
void main()
{
over f;
int a,l,b,h;
clrscr();
cout<>a;
cout<>l>>b>>h;
cout<<endl<<"area of square" ;
f.area(a);
cout<<endl<<"volume of square";
f.volume(a);
cout<<endl<<"area of rectangle";
f.area(l,b);
cout<<endl<<"volume of rectangle";
f.volume(l,b,h);
getch();
}

]]>
By: muhammad zubair https://demo.ritambhara.in/find-error-in-the-c-code/#comment-5669 Mon, 24 May 2021 11:05:53 +0000 http://www.ritambhara.in/?p=443#comment-5669 find error in this program
#include
#include
Using namespace Std;
int main();
{
int number;
for(i=1; i<=6, i++)
{
cout<<"Value of variable i is: "<<number<<endl;
getch();
}

]]>