WEEK:3 PROGRAMMING ASSIGNMENT 1 SOLUTION (Jan 2020-Apr2020) An Introduction to Programming through C++ NPTEL 2020

  

               An Introduction To Programming Through C++


IIT Bombay.

Week 3- Programming Assignment 1:

CLICK ON LINK FOR WEEK 4 QUIZ
CLICK HERE FOR WEEK 4 QUIZ
* 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

FOR DETAIL INFORMATION OF PROGRAM YOU CAN SEE THIS VIDEO


WRITE/COPY THESE CODE DIRECTLY IN NPTEL TERMINAL AND COMPILE AND RUN THEN SUBMIT.


#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;
}
COMMENT IF THERE IS ANY ERROR IN COMPILE AND RUN.
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.

Copyright (c) 2020 Custom Programs All Right Reserved

Pages