Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Find the error in each of the following. (Note: There may be more than one error.) a) For (x = 100, x >= 1, ++x)

Find the error in each of the following. (Note: There may be more than one error.)

a) For (x = 100, x >= 1, ++x) { printf("%d ", x); }

b) The following code should print whether a given integer is odd or even: switch (value % 2) { case 0: puts("Even integer"); case 1: puts("Odd integer"); }

c) The following code should input an integer and a character and print them. Assume the user types as input 100 A. scanf("%d", &intVal); charVal = getchar(); printf("Integer: %d Character: %c ", intVal, charVal);

d) for (x = .000001; x == .0001; x += .000001) { printf("%.7f ", x); }

e) The following code should output the odd integers from 999 to 1: for (x = 999; x >= 1; x += 2) { printf("%d ", x); }

f) The following code should output the even integers from 2 to 100: counter = 2; Do { if (counter % 2 == 0) { printf("%u ", counter); } counter += 2; } While (counter < 100);

g) The following code should sum the integers from 100 to 150 (assume total is initialized to 0): for (x = 100; x <= 150; ++x); { total += x; }

Written in "C" please.

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_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Structured Search For Big Data From Keywords To Key-objects

Authors: Mikhail Gilula

1st Edition

012804652X, 9780128046524

More Books

Students also viewed these Databases questions