workshop01 - printf" 2 Option 2\n" printf" 3...

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 Document Right 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(" 2. Option 2\n"); printf(" 3. Option 3\n"); printf(" 0. Exit\n"); printf(" Your selection (0 -> 3): "); scanf("%d",&choice); if(choice==0) { printf("Good bye, have a nice day!\n"); break; } switch(choice) { case 1: printf("Option 1 selected\n"); break; case 2: printf("Option 2 selected\n"); break; case 3: printf("Option 3 selected\n"); break; default: printf("**Invalid choice. Try again.**\n"); } printf("Press any key to continue. ..\n"); getch(); } return(0); }...
View Full Document

{[ snackBarMessage ]}

Page1 / 2

workshop01 - printf" 2 Option 2\n" printf" 3...

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