This covers Selective structure - switch statement
First, code for the header file stdafx.h:
Name the main file anyhow you like.
And the code for the main file below:
Check the video on how this works on YouTube here:
http://youtu.be/z7sYQqHp51A
First, code for the header file stdafx.h:
// stdafx.h : include file for standard system include files, // or project specific include files that are used frequently, but // are changed infrequently // #pragma once #include#include using namespace std; // TODO: reference additional headers your program requires here
Name the main file anyhow you like.
And the code for the main file below:
// swtcase.cpp : Defines the entry point for the console application. // #include "stdafx.h" void main () { int number; cout<<"Enter a number:"; cin>>number; switch (number) { case 1: cout<<"number you entered was 1."; system("pause"); break; case 2: cout<<"number you entered was 2."; system("pause"); break; default: cout<<"you did not enter 1 or 2."; system("pause"); } }
Check the video on how this works on YouTube here:
http://youtu.be/z7sYQqHp51A
Comments
Post a Comment