Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2. (20 points) Here are four C programs to tratushte bituary to derimal; that is, you rum *. / pb101 ? and it will print

image text in transcribed
2. (20 points) Here are four C programs to tratushte bituary to derimal; that is, you rum *. / pb101 ? and it will print ' 5 '. For each program, indicate whether it works. If it does not, shom lions to fix it by changing the ferest characters possible. Note that these programs will crabl if not given an argument; that's not considered an error per the design spec. Program A Works as is. Needs fixing \#include \#include \#include int main (int argc, char *argvD) i int val=0; // varning: assumes argv[1]! int len =strlen(argv[1]); for (int 1=0;1 int main (int arge, char *argv[) i intval=0; // warning: assumes argv[1]! int len = strlen (argv[1]); for (int i=0;i Hinclude stdiib . b Hinclude string. h > int main(int argc, char *argvD) t int val=0 : // tarming: assumes argv [1]! int len - strlen(argy [1]) - 1; for (int 1=1 en; 1>0;11} if (argv[1][1]=1) val I=1I en; 3 printf("\%d ", val); r Program D Works as is. Nerds fixing: \#include stdio h \#include \#include int main(int argc, char *argv [) t int val =0; // varning: assunes argv[1]! int len = strlen (argv[1])1; for (int i=1 en; 1>=0;1 ) \{ val +=(argv[1][i]0 ') (aen1); \} printf("/d ",val); \}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions