Thursday, September 12, 2024

Heart in C/C++ Programming

C/C++ Graphicl Heart

This code will make a graphical Heart in C programming which will move around your screen and will change it's colors, It's a Great Program Try Now!

code:

 #include <graphics.h>

#include <math.h>

#include <conio.h> // For kbhit

#include <dos.h>   // For delay


double hearta(double k) {

    return 15 * pow(sin(k), 3);

}


double heartb(double k) {

    // Invert the y-coordinates to flip the heart

    return -(12 * cos(k) - 5 * cos(2 * k) - 2 * cos(3 * k) - cos(4 * k));

}


void drawHeart(int xOffset, int yOffset, int color) {

    setcolor(color);

    for (int i = 0; i < 1000; i++) {

        double x = hearta(i / 100.0) * 20 + xOffset;

        double y = heartb(i / 100.0) * 20 + yOffset;

        putpixel(x, y, color);

    }

}


int main() {

    int gd = DETECT, gm;

    initgraph(&gd, &gm, "C:\\Turboc3\\BGI");


    int xOffset = 200, yOffset = 200;

    int color = RED;

    int direction = 1;


    while (!kbhit()) { // Check for key press

        cleardevice();

        drawHeart(xOffset, yOffset, color);


        xOffset += direction;

        if (xOffset > getmaxx() - 100 || xOffset < 100) {

            direction = -direction;

            color = (color % 15) + 1; // Change color

        }


        delay(50); // Delay for 50 milliseconds

    }


    closegraph();

    return 0;

}


Digit Cheaking System in C/C++

 

 C/C++ Digit Cheaking System

This code can cheak how much digit number you have typed if your number is 3 digit than this code will reply Yes else this code will tell How Many digit Number you have typed.

code:

#include <stdio.h>
int main() {
    printf("Type Here to Enter Something... :");
    int num;
    int count = 0;
    scanf("%d",&num);
    printf("\n");
    if(num > 99 && num < 1000){
     printf("Yes it is 3 digit number \3 \4 \2 \1 \5 ");
    }
    if(num < 99 || num > 999){
     printf("\nNo it's not a 3 digit Number\n");
     }
     if(num > 1){
     printf("\n");
     }
     else{
     printf("\nError You Have Entered Wrong Input!\n");
     }
      if (num < 0) {
        num = -num;
    }
    if (num == 0) {
        count = 1;
    } else {
        while (num != 0) {
            num /= 10;
            count++;
        }
    }
      printf("Number of digits: %d\n", count);
    printf("\n");

    return 0;
}

Wednesday, September 11, 2024

C/C++ Automatic Password Generator

 C/C++ Automatic Password Generator

This code can generate a unique password as your desired lengeth. Example if you want 12 letters unique set of password than this code can make it for you!

code:

#include <stdio.h>
#include <stdlib.h>
#include <time.h> // ASR

void generate_password(int length) {
    char characters[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*(){}?<>,';:/\\";
    char password[100]; // Fixed size array to avoid dynamic allocation issues in Turbo C++
    int i;
    srand(time(0));
    for (i = 0; i < length; i++) {
        int randomIndex = rand() % (sizeof(characters) - 1);
        password[i] = characters[randomIndex];
    }
    password[length] = '\0';

    printf("Generated Password: %s\n", password);
}

int main() {
    int length;
    printf("Enter the length of the password: ");
    scanf("%d", &length);
    if (length > 99) {
        printf("Length too long! Please enter a length less than 100.\n");
        return 1;
    }
    generate_password(length);
    return 0;

// By Adeshjeet Singh
}






Heart in C/C++ Programming

C/C++ Graphicl Heart This code will make a graphical Heart in C programming which will move around your screen and will change it's colo...