PROBLEM SOLVING THROUGH PROGRAMMING IN C.
By Prof. ANUPAM BASU
WEEK 8:PROGRAM 1:
Write a C Program to find HCF of 4 given numbers using recursive function.
Sample Test Cases
Input Output
Test Case 1
100
30
50
70
The HCF is 10
Test Case 2
49
56
147
21
The HCF is 7
WEEK 8:PROGRAM 1:
Write a C Program to find HCF of 4 given numbers using recursive function.
Sample Test Cases
Input Output
Test Case 1
100
30
50
70
The HCF is 10
Test Case 2
49
56
147
21
The HCF is 7
int HCF(int a,int b) { if(a%b==0) { return b; } else { return(HCF(b,a%b)); } }
WEEK 8:PROGRAM 2:
Write a C Program to find power of a given number using recursion. The number and the power to be calculated is taken from test case
Sample Test Cases
Input Output
Test Case 1
5
2
5^2 is 25
Test Case 2
10
4
10^4 is 10000
Input Output
Test Case 1
5
2
5^2 is 25
Test Case 2
10
4
10^4 is 10000
long power (int num, int pow)
{
if (pow)
{
return (num * power(num, pow - 1));
}
return 1;
}
CLICK ON BELOW LINK.
<<CLICK HERE FOR WEEK 8 :PROGRAM -03>>
<<CLICK HERE FOR WEEK 8 :PROGRAM-04>> 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.