Draw a flowchart that takes 10 integers from a user and


Question 1

Numbers perfectly divisible by 2 are known even numbers and numbers which are not divisible by 2 are called odd numbers.

(a) Draw a flowchart that takes 10 integers from a user and checks whether that the numbers are even or odd and displays the result.

(b) Write a program that performs the above task.

Question 2

Write a function that returns the largest of five floating-point numbers. Assume the function receives five floating-point numbers from the caller function.

Question 3

(a) Discuss the differences between counter control repetition and sentinel control repetition.

(b) Describe the technique to generate a different sequence of random numbers each time the program runs.

Question 4

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

(a) for ( x = .000001; x = .0001;x+= .000001 ) wind( "%.7fin", x );

(b) The following code should output the odd integers from 999 to I:

for(x=999;x>=1;x-2 )
printf( "%chi", x );

(c) The following code should output the even integers from 2 to 100: counter = 2;

Do {
if( counter % 2 = )
printf( "%u1n", counter );
counter -I- 2;
} While ( counter < 100 );

(d) The following code should sum the integers from 100 to 150 (assume total is initialized to 0):

for ( x = 100; x <= 150; -I-1-x );
total += x;

Question 5

(a) What will be output of following c code? Explain your answer.

#include int main()

{
int x=9,i;
for(i=0;iprintf(" End");
}
return 0;
}

(b) What will be output of following c code? Explain your answer.

#include int main()

(

int i=1;

for(i=0;i=-1;i=1) { printf("%d ",i);

if(i!=l) break;
}
return 0;

Solution Preview :

Prepared by a verified Expert
C/C++ Programming: Draw a flowchart that takes 10 integers from a user and
Reference No:- TGS02734393

Now Priced at $50 (50% Discount)

Recommended (91%)

Rated (4.3/5)