Skip to content

Instantly share code, notes, and snippets.

View dbc2201's full-sized avatar
💻
I may be slow to respond.

Divyansh Bhardwaj dbc2201

💻
I may be slow to respond.
View GitHub Profile
@dbc2201
dbc2201 / largest_prime_factor.c
Created December 6, 2018 09:25
A program in C to find out the largest prime factor of a number
#include <stdio.h>
#include<math.h>
long long m(long long n)
{
long long max=-1;
while(n%2==0)
{
max=2;
n/=2;
@dbc2201
dbc2201 / year.c
Last active December 4, 2018 14:30
A program in C to find out the day on a particular date.
/*
* Filename : year.c
* Author : Aryan Garg, B. Tech 1st Year, GLAU
* Modifier : Divyansh Bhardwaj, Technical Trainer, GLAU
* Aim : To find the day of the week on a given date.
* */
#include<stdio.h>
int main()
{
int year = 0, date = 0, month = 0, last_two_digits = 0, temp_m = 0, temp_l = 0,
@dbc2201
dbc2201 / swap.c
Created November 29, 2018 11:23
Swap two variables using pointers. Call By Reference
#include <stdio.h>
void swap(int *a1, int *b1);
int main()
{
int a = 4, b = 5;
printf("a = %d b = %d\n", a, b);
swap(&a, &b);
printf("a = %d b = %d\n", a, b);
@dbc2201
dbc2201 / challenge_morse.md
Last active February 17, 2021 16:56
Morse Code Coding Challenge

🔥 Coding Challenge 🔥

You know Morse Code, right? No? Too bad! Google It!

You were supposed to message your significant other during my class. But alas! I will catch your mobile phones if you take them out during the class. So, how do you do that? Simple! On a piece of paper. But wait a minute, you don't want the message to be seen or read by any other students. So, you decide to encode it in Morse Code. Why? Because.

So, write a program in Java for yourself, so that you enter a message and the program converts that message into Morse Code Equivalent. Create a function for the same.

Example

@dbc2201
dbc2201 / array_subtraction.c
Created November 28, 2018 18:37
Matrices Subtraction
#include<stdio.h>
void main()
{
int arr1[2][3]={{7,7,7},{8,8,8}};
int arr2[2][3]={{5,5,5},{5,5,5}};
int i,j;
printf("the first matrix is:)\n");
for(i=0;i<2;i++)
{
for(j=0;j<3;j++)
@dbc2201
dbc2201 / basix2.c
Created November 28, 2018 11:30
working of if-else-if ladder
#include<stdio.h>
int main()
{
int a, b = 5, c = 12;
printf("Enter an integer value:\n");
scanf("%d", &a);
if ( a > 10 )
{
#include<stdio.h>
int main()
{
int a, b = 5, c = 12;
printf("Enter an integer value:\n");
scanf("%d", &a);
if (a > 10)
{
printf("%d is greater than 10.\n", a);
@dbc2201
dbc2201 / arraybasix.c
Created November 28, 2018 09:33
basic array code
#include<stdio.h>
int main()
{
// declaring an integer array of size 10
int array1[10];
// declaring an float array of size 10
float array2[10];
// declaring an double array of size 10
@dbc2201
dbc2201 / variable_length_string.c
Created November 28, 2018 07:24
The length of the character array remains the same. It is an array afterall! The problem here is with the input buffer. It might take characters more than specified at the definition of array but then, your program is likely to misbehave. We need to check for this sort of errors while writing our code. Hence we use #define to define constants fo…
#include <stdio.h>
int main()
{
char a[] = "hello";
printf("%s", a);
for( int i = 0 ; i < 4 ; i++ )
{
scanf("%s", a);
printf("%s", a); // this will help you better understand the working
@dbc2201
dbc2201 / match.py
Created November 26, 2018 19:06
to match parenthesis
def match(str1):
str1 = str1.replace(" ", "") ## Omitting all the blank characters from the string
index1 = str1.index("(") ## Checking if we have the string starts with opening bracket
if index1 == 0:
diff = str1.count("(") - str1.count(")") ## Checking the difference in bracket count
if diff == 0:
print("True")
else:
print("False")
else: