Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions C++/Program-16/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Program for right angled patterns
24 changes: 24 additions & 0 deletions C++/Program-16/rightangle.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <iostream>
using namespace std;

int main()
{

int i, space, rows, k=1;

cout<<"Enter the number of rows: ";
cin>>rows;

for(i=1; i<=rows; i++) {
for(space=i; space<rows; space++) {
cout<<"\t";
}
for(j=1; j<=i; j++) {
cout<<k<<"\t";
k++;
}
cout<<"\n";
}

return 0;
}
1 change: 1 addition & 0 deletions C++/Program-17/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# This program is to print random texts with colour
46 changes: 46 additions & 0 deletions C++/Program-17/randomcolorscreen.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#include <stdio.h>
#include <conio.h>
#include <dos.h>
#include <stdlib.h>

int main()
{

int color;
int bcolor;
int x,y;
int d;

//init random to return random value each time
randomize();
//clears the screen
clrscr();

//infinite loop until key is not pressed
while(!kbhit())
{
//gerenate randon text and background color
color =rand()%16;
bcolor=rand()%16;

//define text color
textcolor(color);
//define background color
textbackground(bcolor);
//check if both colors are same, continue the loop
if(color==bcolor)
continue;

//generate random X and Y Co-ordinates
x = rand()%75;
y = rand()%20;
//define position to print the text
gotoxy(x,y);
//print the text
cprintf("IncludeHelp");
//delay
delay(100);
}

return 0;
}
1 change: 1 addition & 0 deletions C++/Program-18/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Program to get weekday with given day.
36 changes: 36 additions & 0 deletions C++/Program-18/getWeekday.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include<iostream>
using namespace std;

//function to get date and return weekday number [0-6]
int getWeekDay(int yy, int mm, int dd)
{
//formula to get weekday number
int rst =
dd
+ ((153 * (mm + 12 * ((14 - mm) / 12) - 3) + 2) / 5)
+ (365 * (yy + 4800 - ((14 - mm) / 12)))
+ ((yy + 4800 - ((14 - mm) / 12)) / 4)
- ((yy + 4800 - ((14 - mm) / 12)) / 100)
+ ((yy + 4800 - ((14 - mm) / 12)) / 400)
- 32045;

return (rst+1)%7 ;
}

//main program/code
int main()
{
//declaring array of weekdays`
const char *Names[] = {"Sunday","Monday", "Tuesday","Wednesday", "Thursday", "Friday", "Saturday"};
int day = 0;
int y,m,d;
cin>>y;
cin>>m;
cin>>d;
//calling function, storing weekday number in day
day= getWeekDay(y,m,d);
//printing the weekday from given array
cout<<"Day : "<<Names[day]<<endl;

return 0;
}
69 changes: 69 additions & 0 deletions Python/Program-22/Plot_function
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import turtle # import the turtle module to draw the graph with

# set up the screen
wn = turtle.Screen()

# set up the turtle
graph = turtle.Turtle()
graph.hideturtle() # hide the turtle so the graph looks nice
graph.speed(0) # speed up the turtle

# draw the axes
# x axis
graph.forward(250)
graph.penup()
graph.goto(250,5)
graph.write('x',font=('Cambria',12,'italic'))
graph.goto(0,0)
graph.pendown()
graph.backward(250)
graph.forward(250)

# y axis
graph.left(90)
graph.forward(250)
graph.penup()
graph.goto(5,250)
graph.write('y',font=('Cambria',12,'italic'))
graph.goto(0,0)
graph.pendown()
graph.backward(250)
graph.forward(250)

def f(x):
'''f(x) -> float
generic function to be graphed'''
return x**2

def decrease_to_fit(zoom):
'''decrease_to_fit(zoom) -> tup
decreases x to fit the graph'''
minX = -250/zoom
maxX = 250/zoom
# fit for negative x
while abs(f(minX)) > 250/zoom:
minX += 0.5/zoom
# fit for positive x
while f(maxX) > 250/zoom:
maxX -= 0.5/zoom
# return tuple of min and max
return (minX,maxX)

def graph_function(t,zoom=10):
'''graph_function(t,zoom) -> none
draws the graph of a function using turtle t
and is zoomed in to zoom'''
t.pensize(2)
# go to the start without drawing a ling
x,maxX = decrease_to_fit(zoom)
t.penup()
t.goto(x*zoom,f(x)*zoom)
t.pendown()
# draw the graph
while x <= maxX:
x += 0.01
t.goto(x*zoom,f(x)*zoom)

graph_function(graph,100)

wn.mainloop()
1 change: 1 addition & 0 deletions Python/Program-22/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# This program Plots graph for any function.