Tuesday, May 13, 2014

Simulation: Comparison between Classical Computer and Quantum Computer using C

This is a program which gives you an idea about what a Quantum Computer is and how is it different from a Classical Computer. It can be compiled using CC or GCC compilers.

#include<stdio.h>
#include<stdlib.h>
#include<curses.h>
#include<time.h> 
void classic();
void quantum();
void delay_sec( int seconds );
int main() {
int c;
while(1) {
printf("\n\n1. Classical\n2. Quantum\n3. Exit\n(Please do not enter non-integer here)\nEnter the case: ");
scanf("%d",&c);
switch (c) {
case 1: {
classic();
break;
}
case 2: {
quantum();
break;
}
case 3: {
exit(0);
}
default: {
printf("Wrong Case!\nTry again");
break;
}
}
}
}
void delay_sec( int seconds ) {
    clock_t endwait;
    endwait = clock () + seconds * CLOCKS_PER_SEC;
    while (clock() < endwait) {}
}
void classic() {
system("clear");
printf("ONLY ONE SCHEMA AT A TIME\n");
printf("Classical\n");
printf("Data1 -> \nData2 -> \nData3 -> \nData4 -> \nData5 -> \nData6 -> \nData7 ->\n");
delay_sec(1);
system("clear");
printf("ONLY ONE SCHEMA AT A TIME\n");
printf("Classical\nData1 -> Schema1\nData2 -> \nData3 -> \nData4 -> \nData5 -> \nData6 -> \nData7 ->\n");
delay_sec(1);
system("clear");
printf("ONLY ONE SCHEMA AT A TIME\n");
printf("Classical\nData1 -> Schema1\nData2 -> Schema2\nData3 -> \nData4 -> \nData5 -> \nData6 -> \nData7 ->\n");
delay_sec(1);
system("clear");
printf("ONLY ONE SCHEMA AT A TIME\n");
printf("Classical\nData1 -> Schema1\nData2 -> Schema2\nData3 -> Schema3");
printf("\nData4 -> \nData5 -> \nData6 -> \nData7 ->\n");
delay_sec(1);
system("clear");
printf("ONLY ONE SCHEMA AT A TIME\n");
printf("Classical\nData1 -> Schema1\nData2 -> Schema2\nData3 -> Schema3");
printf("\nData4 -> Schema4\nData5 -> \nData6 -> \nData7 ->\n");
delay_sec(1);
system("clear");
printf("ONLY ONE SCHEMA AT A TIME\n");
printf("Classical\nData1 -> Schema1\nData2 -> Schema2\nData3 -> Schema3");
printf("\nData4 -> Schema4\nData5 -> Schema5\nData6 -> \nData7 ->\n");
delay_sec(1);
system("clear");
printf("ONLY ONE SCHEMA AT A TIME\n");
printf("Classical\nData1 -> Schema1\nData2 -> Schema2\nData3 -> Schema3");
printf("\nData4 -> Schema4\nData5 -> Schema5\nData6 -> Schema6\nData7 ->\n");
delay_sec(1);
system("clear");
printf("ONLY ONE SCHEMA AT A TIME\n");
printf("Classical\nData1 -> Schema1\nData2 -> Schema2\nData3 -> Schema3");
printf("\nData4 -> Schema4\nData5 -> Schema5\nData6 -> Schema6\nData7 -> Schema7\n");
delay_sec(1);
printf("\nTOTAL TIME TAKEN = 7 Units (1 Unit per schema)");
}
void quantum() {
system("clear");
printf("MULTIPLE OR EVERY POSSIBLE SCHEMA AT THE SAME TIME\n");
printf("Quantum\n");
printf("Data1 -> Schema1\nData2 -> Schema2\nData3 -> Schema3");
printf("\nData4 -> Schema4\nData5 -> Schema5\nData6 -> Schema6\nData7 -> Schema7\n");
printf("\nTOTAL TIME TAKEN = 1 Units (1 Unit per schema)");
}

No comments:

Post a Comment

UA-39217154-2