workshop01 - printf(" 2. Option...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
PFC - Workshop 1 Question 1: using printf() in stdio.h Write a C program that prints on the screen the sentence: Now is the time to learn C Question 2: Write a menu driven program that displays the following options: You can run the QUES2.EXE file to see how the program should work. . Sample menu: #include <stdio.h> #include <stdlib.h> #include <conio.h> int main() { int choice; while(1) { clrscr(); printf(" Choose one of the following options:\n"); printf(" 1. Option 1\n");
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: printf(&quot; 2. Option 2\n&quot;); printf(&quot; 3. Option 3\n&quot;); printf(&quot; 0. Exit\n&quot;); printf(&quot; Your selection (0 -&gt; 3): &quot;); scanf(&quot;%d&quot;,&amp;choice); if(choice==0) { printf(&quot;Good bye, have a nice day!\n&quot;); break; } switch(choice) { case 1: printf(&quot;Option 1 selected\n&quot;); break; case 2: printf(&quot;Option 2 selected\n&quot;); break; case 3: printf(&quot;Option 3 selected\n&quot;); break; default: printf(&quot;**Invalid choice. Try again.**\n&quot;); } printf(&quot;Press any key to continue. ..\n&quot;); getch(); } return(0); }...
View Full Document

Page1 / 2

workshop01 - printf(&amp;amp;quot; 2. Option...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online