Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Use C program by using Visual Studio: a) Write a program that asks for intege

ID: 3799219 • Letter: 1

Question

1. Use C program by using Visual Studio:

a) Write a program that asks for integer and then prints all the intgers from (and including) that value up to (and including) a value larger by 10. (That is, if the input is 5, the output runs from 5 to 15.) Be sure to separate each output value by a space or tab or newline. " Use Whileloop"

b) Write a switch statment that checks nextChoice. If 0, print "Rock". If 1, print "Paper". If 2, print "Scissors". For any other value, print "Unknown". End with newline. Do not get input from the user; nextChoice is assigned in main().

c) Write a switch statment that checks origLetter. If 'a' or 'A', print "Alpha". If 'b' or 'B', print "Beta". For any other charachter, print "Unknown". End with newline

Explanation / Answer

For question number 2)

#include<stdio.h>

void main()
{
   int ch=1;
  
   switch(ch)
   {
       case 1:
           printf("Rock");
           //break;
       case 2:
           printf(" Paper");
           //break;
       case 3:
           printf(" Scissors");
           break;
       default:
           printf(" Unknown ");
   }
}

3)

#include<stdio.h>

void main()
{
   int ch,c;
   printf("Enter ch");
   scanf("%d",&ch);
  
  
   switch(ch)
   {
       case 1:
       printf("Enter a character");
   scanf("%d",&c);
           if(c=='a'||c=='A')
           printf("Alpha");
           break;
       case 2:
       printf("Enter a character");
   scanf("%d",&c);
           if(c=='b'||c=='B')
           printf("Beta");
           break;
       case 3:
       printf("Enter a character");
   scanf("%d",&c);
   if(c=='b'||c=='B')
           printf("Beta");
           break;
       default:
           printf(" Unknown ");
   }
}