Posts

Showing posts from July, 2024

21CS62

 Program 1:Date and Time Step 1:Terminal django-admin startproject myproject  cd myproject py manage.py startapp myapp Step 2:settings.py Open the settings.py file inside the myproject directory.  Find the INSTALLED_APPS list and add your app's name ('myapp') to the list.  INSTALLED_APPS = [      ...      'myapp',  ]  Step 3:views.py Open the views.py file inside your myapp directory and  define a view. from django.http import HttpResponse  from datetime import datetime, timedelta    def datetime_with_offsets(request):      now = datetime.now()      offset_hours = 4            four_hours_ahead = now + timedelta(hours=offset_hours)      four_hours_before = now - timedelta(hours=offset_hours)        html = f"<html><body><h1>Current Date and Time with Offs...

21CSL66

Program 1:Bresenham's Line Algorithm #include <GL/glut.h> #include <stdio.h> int x1, y1, x2, y2; void draw_pixel(int x, int y) {     glColor3f(1.0, 0.0, 0.0);     glBegin(GL_POINTS);     glVertex2i(x, y);     glEnd(); } void bresenhams_line_draw(int x1, int y1, int x2, int y2) {     int dx = x2 - x1;     int dy = y2 - y1;     int x = x1;     int y = y1;     int p = 2 * dy - dx;  // Corrected calculation of p     int twoDy = 2 * dy;     int twoDyMinusDx = 2 * (dy - dx);     draw_pixel(x, y);     while (x < x2)     {         x++;         if (p < 0)             p += twoDy;         else         {             y++;             p += twoDyMinusDx;      ...