Part B:
Answer any
3
of the
6
questions.1.Write a program that ask the user to enter two numbers, obtains the twonumbers from the user and prints the sum, product, and different of the twonumbers.2.What, if anything, print when each of the following statements is performed?If nothing prints, then answer "nothing.". Assume
x=2
and
y=3.
a)
printf ("%d%d",&x,&y);
b)
printf ("%d", x +x);
c)
printf ( " \n");
d)
/*printf ("x+y = %d",x+y);*/
3.What does the following code printf?
printf ( "*\n**\n***\n****\n*****\n");
4.What is wrong with the following
while
repetition statement (assume
z
hasvalue 1000), which is supposed to calculate the sum of the integers from 100down to 1;
while ( z >=0)sum +=z;
5.Write a single pseudocode statement that indicates each of the following:a)Display the message "
enter two numbers
". b)Assign the sum of variables
x,y
and
z
to variable
p
.c)The following condition is to be tested in an
if...else
selectionstatement: The current value of variable
m
is greater than twice thecurrent value of variable
v
.6.Write
for
statement that print the following sequences of values:a)1,2,3,4,5,6,7 b)3,8,13,18,23c)20,14,8,2,-4,-10d)19,27,35,43,512
Leave a Comment