I am new to using C language and also to programing and would like some help on the following problem.
Write a function to take integer input from user: If user input 1 then the program prints ONE and if user input 2 then program print TWO. If user input is neither 1 nor 2 then program prints: DEFAULT VALUE.
The program should ask user whether he want to repeat the programe again. If student enters ‘y’ then program is repeated and if student enters ‘n’ then program is terminated.
Note:
Use while selection statement to decide the repetition of program and use switch multiple selection statement to print ONE or TWO or DEFAULT VALUE based on the user input.
im having problem in repeating the whole thing. can anyone help me in this case. the source cde ive writen is as follows:
Code:#include<stdio.h> int main() { int a; char b; char y; char n; char counter; y=3; printf("Enter Number \n"); scanf("%d",&a); switch (a) { case 1: printf("\n You Entered one \n"); break; case 2: printf("\n You Entered Two \n"); break; default: printf("default"); } printf("do u want to repeat?\n"); scanf("%d",&counter); while (counter=y) { printf("Enter Number \n"); scanf("%d",&a); switch (a) { case 1: printf("\n You Entered one \n"); break; case 2: printf("\n You Entered Two \n"); break; default: printf("default"); } } }