Access over 20 million homework & study documents
search

7D (C Programming) 17 10 Prove or disprove the following claim E

Content type

User Generated

Rating

Showing Page:
1/3
7D (C Programming) 17. 10 Prove or disprove the following
claim: \"Every arbitrary CIf statement can be re- written
equivalently via switch statements\". 18. 10 How many
elements does float array z[] below have? If every element
consumes 8 bytes, how many bytes are set aside in
memory for array z[]? float z[ 15 4 2
Solution
Ans...
17.
The prove of if statement equally write in switch statement
as follows :
Switch statement ::
#include<stdio.h>
int main()
{
char myinput;
printf(\"Which option will you choose:\ \");
printf(\"a) Program 1 \ \");
printf(\"b) Program 2 \ \");
scanf(\"%c\", &myinput);
switch (myinput)

Sign up to view the full document!

lock_open Sign Up
Showing Page:
2/3
{
case \'a\':
printf(\"Run program 1\ \");
break;
case \'b\':
{
printf(\"Run program 2\ \");
printf(\"Please Wait\ \");
break;
}
default:
printf(\"Invalid choice\ \");
break;
}
return 0;
}
Same in If Statement ::
#include<stdio.h>
int main()
{
char myinput;
printf(\"Which option will you choose:\ \");
printf(\"a) Program 1 \ \");
printf(\"b) Program 2 \ \");
scanf(\"%c\", &myinput);

Sign up to view the full document!

lock_open Sign Up
Showing Page:
3/3

Sign up to view the full document!

lock_open Sign Up

Unformatted Attachment Preview

7D (C Programming) 17. 10 Prove or disprove the following claim: \"Every arbitrary CIf statement can be re - written equivalently via switch statements \". 18. 10 How many elements does float array z[] below have? If every element consumes 8 bytes, how many bytes are set aside in memory for array z[]? float z[ 15 4 2 Solution Ans... 17. The prove of if statement equally write in switch statement as follows : Switch statement :: #include int main() { char myinput; printf(\"Which option will you choose:\ \"); printf(\"a) Program 1 \ \"); printf(\"b) Program 2 \ \"); scanf(\"%c\", &myinput); switch (myinput) { case \'a\': printf(\"Run program 1\ \"); break; case \'b\': { printf(\"Run program 2\ \"); printf(\"Please Wait\ \"); break; } default: printf(\"Invalid choice\ \"); break; } return 0; } Same in If Statement :: #include int main() { char myinput; printf(\"Which o ...
Purchase document to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Anonymous
Awesome! Perfect study aid.

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4