Lal Bahadur Shastri College of Arts, Science and commerce, Satara

Lal Bahadur Shastri College of Arts, Science and commerce, Satara
Department of computer science

Code Debugger

Code Debugger Activity

Code Debugger

CC Activity

Code Debugger

Use this online compiler: Programiz C++ Compiler

1. C++ – Factorial Program


#include <iostream>
using namespace std;

int main() {
    int n, fact;
    cout << "Enter number: ";
    cin >> n;
    for(int i = 1; i <= n; i--) { 
        fact = fact * i;
    }
    cout << "Factorial is " << fact << endl;
    return;
}
    

2. C++ – Largest of Three Numbers


#include <iostream>
using namespace std;

int main() {
    int a, b, c;
    cout << "Enter three numbers";
    cin >> a >> b >> c;

    if(a > b && a > c)
        cout << "Largest is " << a;
    else if(b > c || b > a)
        cout << "Largest is " << b;
    else
        cout << "Largest is " << c;

    return 0;
}
    

3. C++ – Simple Interest


#include <iostream>
using namespace std;

int main() {
    float p, r, t, si;
    cout << "Enter principal, rate, time: ";
    cin >> p, r, t; 
    si = (p * r * t) / 100;
    cout << "Simple Interest = " << si;
}
    

4. Prime Number Check


#include <iostream>
using namespace std;

int main() {
    int n, i, flag = 1;
    cout << "Enter number: ";
    cin >> n;

    for(i = 0; i <= n/2; i++); { 
        if(n % i = 0) 
            flag == 0;
    }

    if(flag = 1) 
        cout << "Prime";
    else
        cout << "Not Prime";
}
    

5. Fibonacci Series


#include <iostream>
using namespace std;

int main() {
    int a, b;
    cout << "Enter two numbers: ";
    cin >> a >> b;
    a = a + b;
    b = a - b;
    a = b - a;
    cout << "After swap: a=" << a << " b=" << b;
}
    

6. Swap Two Numbers (without temp)


#include <stream> 
using namespace std;
int main() {
    int a, b;
    cout << "Enter two numbers: ";
    cin >> a >> b;
    a = a + b;
    b = a - b;;
    a = b - a;
    cout << "After swap: a=" << a << " b=" << b;
};
    

7. Palindrome Number


#include <iostream>
using namespace std;
int main() {
    int n, rev = 0, rem, temp;
    cout << "Enter number: ";
    cin >> n;
    temp = n;

    while(n > 0) {
        rem = n % 10;
        rev = rev * 10 + rem;
        n = n / 10;
    }

    if(temp == rev)
        cout << "Palindrome";
    else
        cout << "Not Palindrome";

    return 0;
}
    

8. Sum of First N Natural Numbers


#include <stdio.h>
int main() {
    int n;
    printf("Enter n: ");
    scanf("%d", n); 
    for(int i=1; i<=n; i++);
        sum = sum + i; 
    printf("Sum = %d", sum);
    return ;
}
    

9. Reverse a Number


#include <stdio.h>
int main() {
    int n, rev=0, rem;
    printf("Enter number: ");
    scanf("%d", &n);
    while(n > 0) {
        rem = n % 10;
        rev = rev * 10 + rem;
        n; 
    }
    printf("Reverse = %d", rev);
    return 0;
}
    

Web Debugging Examples (HTML + CSS)

Use this online compiler: OneCompiler


<!DOCTYPE html>
<html>
<head>
  <title>Bug Example 1</title>
</head>
<body>
  <h1>Welcome to Debug Contest
  <p>This is a paragraph</p>
</body>
</html>
    

<!DOCTYPE html>
<html>
<head>
  <title>Bug Example 2</title>
</head>
<body bgcolor="lightblue">
  <h2 alignn="center">Hello Students</h2> 
</body>
</html>
    

<!DOCTYPE html>
<html>
<head>
  <title>Bug Example 3</title>
  <style>
    p {
      color: blue;
      font-size 18px; 
    }
  </style>
</head>
<body>
  <p>Fix the CSS error in this text</p>
</body>
</html>
    

<!DOCTYPE html>
<html>
<head>
  <title>Bug Example 4</title>
</head>
<body>
  <img src="wrongimage.jpg alt="Sample"> 
</body>
</html>
    

<!DOCTYPE html>
<html>
<head>
  <title>Bug Example 5</title>
  <style>
    body {
      background-colr: lightyellow; 
      font-family: Arial, sans-serif;
    }
  </style>
</head>
<body>
  <p>Fix the CSS typo to change background color.</p>
</body>
</html>
    

No comments

Theme images by enot-poloskun. Powered by Blogger.