Im just beginning to learn c++ and this is about the second day. Just wondering what you guys think and ways of improvement, efficiency and such.
Thanks guys!
/*
Super Simple Calculator
- Created By FTProtocol
*/
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <windows.h>
#define nl '\n'
int x,y,choice;
int ans=0;
char loop;
float div1;
int main()
{
printf(" Welcome to SCC - V2.0");
Sleep(1500);
printf("\n - Created by FTProtocol");
Sleep(5000);
system("cls");
printf(" Would you like to continue? (y/n): ");
scanf("%s",&loop);
if (loop =='y' || loop =='Y')
{
system("cls");
printf("\n Please enter two numbers");
printf("\n -----------------------");
printf("\n\n Please enter the first number: ");
scanf("%i",&x);
printf("\n Please enter the second number: ");
scanf("%i",&y);
system("cls");
printf("\n Select an operation.");
printf("\n\n 1. Addition");
printf("\n 2. Subtraction");
printf("\n 3. Multiplication");
printf("\n 4. Division");
printf("\n\n Please make your choice: ");
scanf("%i",&choice);
switch(choice)
{
case 1 :
printf(" Answer: %i %c %c",(ans=x+y),nl,nl);
printf(" Answer: %i %c %c",(ans=x+y),nl,nl);
printf(" Answer: %i %c %c",(ans=x+y),nl,nl);
case 2 :
printf(" Answer: %i %c %c",(ans=x-y),nl,nl);
case 3 :
printf(" Answer: %i %c %c",(ans=x*y),nl,nl);
case 4 :
printf(" Answer: %i %c %c",(div1=x/y),nl,nl);
default :
printf("\n Illegal operation selected");
}
Sleep(1000);
printf(" Thanks for using SSC - Program will now restart!%c%c",nl,nl);
Sleep(3000);
system("cls");
}
else{
printf("\n Good-Bye :O %c%c",nl,nl);
system("PAUSE");
return 0;}
main();
return 0;
}