0% found this document useful (0 votes)
58 views

National University of Computer and Emerging Sciences: Lab Manual Programming Fundamentals

The document is a lab manual for a programming fundamentals course that provides instructions for students to complete problems using for loops in C++. It lists the course details and instructors. The objectives are to write C++ code using for loops and the break statement. Students are instructed to name files specific to each problem number, zip their files with their student ID, and submit to Google Classroom. Five problems are provided requiring the use of for loops to output things like odd numbers and sums, multiply without operators, average squared numbers, evaluate an equation, and print factors of a number.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views

National University of Computer and Emerging Sciences: Lab Manual Programming Fundamentals

The document is a lab manual for a programming fundamentals course that provides instructions for students to complete problems using for loops in C++. It lists the course details and instructors. The objectives are to write C++ code using for loops and the break statement. Students are instructed to name files specific to each problem number, zip their files with their student ID, and submit to Google Classroom. Five problems are provided requiring the use of for loops to output things like odd numbers and sums, multiply without operators, average squared numbers, evaluate an equation, and print factors of a number.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

National University of Computer and Emerging Sciences

Lab Manual
for
Programming Fundamentals

Course Instructor Mr. Waqas Manzoor


Lab Instructor(s) Mr. Muhammad Waqas
Mr. Raja Muzammil Muneer
Section BDS-1B1, 1B2
Semester Fall 2021

Department of Computer Science


FAST-NU, Lahore, Pakistan

Page 1 of 3
Objectives
After performing this lab, students will be able to:
 Write C++ Code for the problems involving For loop (Without nesting).
 Break Statement

Instructions
 For each problem, your filename should be “q Number”.cpp. e.g For Problem 1, create
“q1.cpp”.
 Zip all files in a folder and your submission zip filename must be your rollno. e.g
“21L1234.zip”. Note your zip file shall contain all the .cpp files for the problems you solved.
 Submit the zip folder on Google classroom.
 Plagiarism is strictly prohibited.
 Good Luck.

Problems
Write C++ Code of the following Problems using For Loop.

Problem#1
Write a program that prompts the user to enter a number and prints odd number from 1 to that
number and also display their sum.
Input Output

10 1,3,5,7,9
Sum:23

Problem#2
Write a program to multiply two non-negative numbers without using multiplication operator
using For loop.

Problem#3
Write a program that prompts the user to enter a number n and prints average of n squared
natural number.
Input Output

5 1,4,9,16,25
Avg=11

Page 2 of 3
Problem#4
Write a program that takes an input and returns the answer for following equation.
(1 + 2 + ... + n)2 – (12+ 22 + ... + n2)
For Example
Enter a number: 5
(1 + 2 + ... + 5)2 – (12+ 22 + ... + 52) =225-55=170
Input Output

6 441-36=405

Problem#5
Write a program that prompts the user to enter a number and print its factors. 
Input Output

Input a Number: 16 Factors: 1,2,4,8,16

Page 3 of 3

You might also like