National University of Modern Languages (NUML)
Faisalabad Campus
Department of Computer Science
Course Code CSPF-141
Course Title Programming Fundamentals
Assignment 1
Due Date 07-Mar-2025
Instructions:
Every student needs to submit a word file against this assignment with proper name
format (e.g., Assignment#1_PF_UserNameLastDigits)
If found plagiarism, straight zero will be marked against assignment.
Submit Assignment on Due Date. No Late Submission will be Tolerated.
[Question # 1] [CLO1] [UNDERSTANDING] [C2] [PLO2] [5 X 2=
10]
Rephrase the following C++ codes to make it error free and Also Illustrate the output
afterwards:
C++ Program to Find Cube of a Number
$include <iostream>
using namespace sdt;
int Main()
{
int n ; cube;
// Asking for input
cout << “Enter a number:”
cin >> num;
// Finding cube
cube = n * n;
// Displaying result
cout < "Cube of " < n < " is: " < cube < endl;
return 100;
}
Error Free C++ Code
Output of the Above C++ Code
C++ Program to Compute Quotient and Remainder
#include “iostream”
using namespace sdt;
int main()
{
int divisor, dividend, quotient, remainder;
coutput << "Enter dividend: ";
cinput >> dividend;
coutput << "Enter divisor: ";
cinput >> dividend;
quotient = dividend % divisor;
remainder = dividend / divisor;
coutput << Quotient = << q << endl;
coutput << Remainder = << r;
return 1;
}
Error Free C++ Code
Output of the Above C++ Code