• Embed Doc
  • Readcast
  • Collections
  • CommentGo Back
Download
 
Part A
: Answer 
all
the questions.Find the error in each of the following code segment and explain how to correct it.(note: there may be more than one error per statement):1.
scanf ("%d%d", &number, number2);
2.
if ( c<7);printf ("c is less than 7\n");
3.
if (c=>7)printf ("c is equal to or less than 7\n");
4.
scanf ("d",value);
5.
printf ( "the product of %d and %d"\n,x,y);
6.
firstNumber + secondNumber = sumOfNumbers
7.
if (number => largest)largest == number;
8.
*/ program to determine the largest of three integers*/
9.
Scanf ("%d", anInteger);
10.
printf ("remainder of % divided by % is \n",x,y,x%y);
11.
if (x=y);printf (%d is equal to %d\n",x,y);
12.
print ("the sum is %d\n," ,x+y);
13.
printf ("the value you entered is : %d\n,&value);
14.
while ( c<=5) {product *=c;++c;
15
scanf ("%.4f",&value);
16
if (gender == 1)printf ("woman\n");else;printf ("man\n");
17.
x = 1while ( x <= 10);x++;}
18.
for ( y = 0.1; y !=1.0; y +=0.1)printf ( "%f\n",y);
19.
switch (n) {case 1:printf ("the number is 1\n");case 2:printf ("the number is 2\n");break;default :printf ("the number is not 1 or 2\n");break;}
20.
 The following code should print the values 1 to 10.n = 1;while ( n<10)printf ("%d", n++);
1
 
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
of 00

Leave a Comment

You must be to leave a comment.
Submit
Characters: ...
You must be to leave a comment.
Submit
Characters: ...