0% found this document useful (0 votes)
29 views2 pages

CSEB113/ Lab 7: College of Engineering Principles of C Programming

The document contains 3 questions about C programming concepts. Question 1 asks the student to write a program to sum 10 integer numbers entered by the user using a repetition control structure. Question 2 provides a C code sample to reverse an integer and asks the student to complete a trace table showing the output. Question 3 provides another C code sample using a for loop and continue statement, asking the student to complete a trace table showing the calculation and output of the sum.

Uploaded by

Keith Tay
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views2 pages

CSEB113/ Lab 7: College of Engineering Principles of C Programming

The document contains 3 questions about C programming concepts. Question 1 asks the student to write a program to sum 10 integer numbers entered by the user using a repetition control structure. Question 2 provides a C code sample to reverse an integer and asks the student to complete a trace table showing the output. Question 3 provides another C code sample using a for loop and continue statement, asking the student to complete a trace table showing the calculation and output of the sum.

Uploaded by

Keith Tay
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

CSEB113/ Lab 7

COLLEGE OF ENGINEERING

PRINCIPLES OF C PROGRAMMING

Question 1

Write a complete C program to sum all 10 integer numbers enter by the user. The integer
number can be a positive or negatif number. Apply a repetition control structure technique
in your answer.

Question 2

Study the following C code:

#include <stdio.h>
int main() {
int n, rev = 0, remainder;
printf("Enter an integer: ");
scanf("%d", &n);
while (n != 0) {
remainder = n % 10;
rev = rev * 10 + remainder;
n /= 10;
}
printf("List of Numbers = %d", rev);
return 0;
}

What is output will be displayed for the above C program? Complete the following table
to trace the answer.

iteration n n != 0 reminder rev n/=10 printf()


1
2
3
:
:
n
CSEB113/ Lab 7

Question 3

Study the following C code:

#include <stdio.h>
int main ()
{
int a,sum = 0;
for (a = 0; a < 10; a++)
{
if ( a % 2 == 0 )
continue;
sum = sum + a;
}
printf("sum = %d",sum);
return 0;
}

What is output will be displayed for the above C program? Complete the following table
to trace the answer.

Iteration a a < 10 a%2=0 sum=sum a++ printf(sum)


+a
1
2
3
:
:
n

--End of Questions--

You might also like