An Introduction To Programming Through C++
IIT Bombay.
Week 3- Programming Assignment 1:
* Write a program which prints the sum of the cubes of the digits of
a number.
Sample Test Cases:
Input Output
Test Case 1 120 9
Test Case 2 123405 225
Test Case 3 0 0
#include<iostream>
int mul(int a)
{
a=a*a*a;
return a;
}
int main()
{
int arr,sum=0,p;
cin>>arr;
do
{
p=arr%10;
arr=arr/10;
sum=sum+mul(p);
}while(arr!=0);
cout<<sum;
return 0;
}
WEEK :3 PROGRAMMING ASSIGNMENT 2 SOLUTION
CLICK ON BELOW LINK.
<<CLICK HERE FOR PROGRAMMING ASSIGNMENT 2 WEEK 3>>
FOLLOW OUR WEBSITE FROM THE BUTTON PROVIDED TO THE BOTTOM OF PAGE TO GET SOON ANSWERS OF PROGRAMS.
Disclaimer: Here you can find all nptel assignment solutions related to CS stream.These may help you for your assignment.The answers are only for verification.You cannot copy these directly from the post(code of conduct of NPTEL).These is not 100% correct solutions.
No comments:
Post a Comment
If you have any problems related to solutions or any concept please let me know.