Windows – Add Space to C: Drive, though D: exists

email me

The problem is this…you want to add unallocated space to your C: drive, but you also have a D: drive you want to keep; this means the unallocated space is at the end of the disk tracker, and the extend option isn’t available to C: drive. According to Microsoft, you must delete other volumes, and then use the adjoining unallocated space to extend C: drive. Yikes. No.

C: D: drives and the unallocated space

C: drive with the grayed out Extend Volume option

 

Solution 

The answer is simple, don’t delete existing volumes—use a third party app to help you rearrange existing space.

First, download EaseUS Partition Master: https://www.easeus.com/partition-master/extend-c-drive-windows-10.html  mirror

Next, use the app to make sure you have unallocated space. Shrink a volume, if necessary.

And then select DISK 0 and the relative partition on the tracker (may be a recovery partition or data partition). Move drive letter partition(s) to the end. You’ll notice a shift in unallocated space. This is what you want.

 

Finally, apply changes by clicking the Execute Operation button.

 

Reboot computer, partition changes will be applied, and once back at the desktop, check disk management. BAM! You have successfully extended your C: drive, without having to delete volumes.

C++ Determine Prime Numbers in Array

email me

#include "stdafx.h"
#include <iostream>
#include <string>
#include <stdio.h>
#include <vector>
#include <algorithm>    // std::min_element, std::max_element

using namespace std;

int primeReturn(int arr[], int n)
{
int max_val = *max_element(arr, arr + n);

vector<bool> prime(max_val + 1, true);

prime[0] = false;
prime[1] = false;
for (int p = 2; p * p <= max_val; p++) {

if (prime[p] == true) {
for (int i = p * 2; i <= max_val; i += p)
prime[i] = false;
}
}

// Find primes
int primes;
string x;

for (int i = 0; i < n; i++)
if (prime[arr[i]])
x = x + std::to_string(arr[i]);
primes = std::stoi(x);
return primes;
}

int main(void)
{
// the array
int arr[] = { 9,8,5,3,2,4 };

// determine size of array
int n = sizeof(arr) / sizeof(arr[0]);

cout << "Find primes in: 985324";

// output primes
cout << "\nPrimes: " << primeReturn(arr, n);

//system("pause"); // for visual studio
getchar();
}


Output

C++ Convert Celsius to Fahrenheit

email me

#include "stdafx.h"
#include<iostream>

using namespace std;

int main(void)
{
float Fahrenheit, Celsius;

cout << "Enter temperature in Celsius: "; cin >> Celsius;
Fahrenheit = (Celsius * 9.0) / 5.0 + 32;

cout << "The temperature in Celsius: " << Celsius << endl;
cout << "The temperature in Fahrenheit: " << Fahrenheit << endl;

getchar();
getchar();
}


Output

Python – User Input and Basic Logic

print("Welcome to Contoso!")
a = input("What is your name? ")
b = input("How can we help you, " + a +'? ')
print("We can help you with that.")
c = input("Would you like to see more information? yes or no ")
no = ("Come again!")
yes = ("Detailed software packages go here.")
if c=='yes' :
print(yes)
d = input ("Are you satisfied with our Customer Service? yes or no ")
if d=='yes':
print('Thanks for your patronage. Come again!')
else:
e = input('What can we help you with? ')
f = input("Press any key to continue...")
# add more logic here


Output

 

Notes

Online Interpreter/Compiler

Python, Latest Version

C# – Getter Setter Example

email me

Getters and Setters are the accessors for the public property Name. You would use them to get/set the value of that property in an instance of Genre. That is an Auto-Implemented Property. It’s basically a shorthand way of creating properties for a class in C#, without having to define private variables for them.

using System;

class Program
{
// entry point
static void Main()
{
AccessClass accessClass = new AccessClass
{
// comment-uncomment to test get set
// our declared values
//Number1 = 9, // setter value
//Number2 = 99 // setter value
};

Console.WriteLine("Output: {0}", accessClass.Number1); // getter
Console.WriteLine("Output: {0}", accessClass.Number2); // getter
Console.ReadKey();
}
}

public class AccessClass
{
// our default values
public int _number1 { get; set; } = 100; // our default value, aka Backing store
public int _number2 { get; set; } = 200; // our default value, aka Backing store

public int Number1
{
get
{
return _number1;
}
set
{
_number1 = value;
}
}

public int Number2
{
get
{
return _number2;
}
set
{
_number2 = value;
}
}
}

 

Output


 

Notes

Using Properties (C# Programming Guide)

C++ Show Growing Letter Count ABCDEF

email me
#include "stdafx.h"
#include <iostream>

using namespace std;

int main()
{
int beginLetter = 65;

int letterCount = 6;

for (int i = 1; i <= letterCount; i++)
{
for (int j = 1; j <= i; j++)
{
cout << char(beginLetter);
beginLetter++;
}
cout << endl;
beginLetter = 65;
}
cin.get();
return 0;
}

Output

Notes

#include "stdafx.h"
#include <iostream>

using namespace std;

int main()
{
int beginLetter = 65;
int n;
cout << "Enter height: " << endl;
cin >> n;

for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= i; j++)
{
cout << char(beginLetter);
beginLetter++;
}
cout << endl;
beginLetter = 65;
}
cin.get();
cin.get();
return 0;
}

Fortran – Subroutines and Iteration

email me

I used the registered version of the Simply Fortran compiler, here: simplyfortran-3.0.msi, simplyfortran-2.35.msi; also, try the online Fortran compiler.

PROGRAM MAIN

! inhibit older feature
IMPLICIT NONE
    
    ! declare numbers    
    INTEGER N, X
    
    ! declare sub    
    EXTERNAL SUB1
    
    ! declare global variable
    COMMON /GLOBALS/ N
    
    ! set initial value
    X = 0
    
    ! input how many interations
    PRINT *, 'Enter number of interations: '
    READ (*,*) N
    
    ! goto sub1
    CALL SUB1(X,SUB1)
    
    ! end program
    END

    ! our sub
    SUBROUTINE SUB1(X,LOOP)
        INTEGER N, X
        EXTERNAL LOOP
        COMMON /GLOBALS/ N
    
        IF(X .LT. N)THEN
            X = X + 1
            PRINT *, 'x = ', X
            CALL LOOP(X,LOOP)
        END IF
        ! end if
    
    ! end sub
    END

 

Output

 

Notes

Learn more, Fortran language

https://pinetools.com/syntax-highlighter

 

Types of Variables

Integer: It can hold only integer values.

Real: It stores the floating point numbers.

Complex: It is used for storing complex numbers.

Logical: It stores logical Boolean values.

Character: It stores characters or strings.

Fortran – Perform Sum of Given Numbers

email me

I used the registered version of the Simply Fortran compiler, here: simplyfortran-3.0.msi, simplyfortran-2.35.msi; also, try the online Fortran compiler.

PROGRAM Sum

! inhibit older feature
IMPLICIT NONE

	! declare numbers
    REAL X,Y,Z
	
	! input X
    PRINT *,"Enter first number: "
    READ *, X
	
	! input Y
    PRINT *,"Enter second number: "
    READ *, Y
    
	! perform calculation
	Z = X + Y
	
	! output sum
    PRINT *,"Sum of X + Y = ", Z
	
	READ(*,*)
	
END PROGRAM Sum

 

Output

 

Notes

Learn more, Fortran language

https://pinetools.com/syntax-highlighter

 

Types of Variables

Integer: It can hold only integer values.

Real: It stores the floating point numbers.

Complex: It is used for storing complex numbers.

Logical: It stores logical Boolean values.

Character: It stores characters or strings.

C++ Show Growing and Shrinking Number Set

email me
#include "stdafx.h"
#include <iostream>

using namespace std;

int main()
{
int a, length;
printf("Enter length: ");
cin >> length;
a = length / 2;

for (int b = 1; b <= a; b++)
{
for (int c = 1; c <= b; c++)
{
cout << c;
}

cout << endl;
} for (int e = a-1; e >= 1; e--)
{

for (int d = 1; d <= e; d++)
{
cout << d;
}

cout << endl;
}

cin.get();
cin.get();
}


Output

C++ Return Binary from 1-256

email me

#include "stdafx.h"
#include <iostream>

using namespace std;

int binary(int x) {
int arr[99], mod, quo, i = 1, ctr = 0, sum = 0;
do {
mod = x % 2;
arr[ctr] = mod;
quo = x / 2;
x = quo;

arr[ctr] *= i;
sum += arr[ctr];
ctr++;
i *= 10;
} while (x != 0);
return sum;
}

int main() {
int arr[256], index = 0;
for (int i = 1; i <= 256; i++) {
arr[index] = binary(i);
index++;
}
for (index = 0; index < 256; index++) {
// output
cout << index+1 << ": " << arr[index] << endl;
}

cin.get();
return 0;
}

Output