Class recording: Here
February 13th, 2022
[Scroll to the bottom of this page to discuss stuff].
- Read the attached presentation to learn about number system base conversions and working of bitwise operators before coming in for the next class.
-
Write a program (WAP) to input a number
n
from the user and print the firstn
terms of the Fibonacci series using recursive function. -
WAP to input a number
n
and find the sum of firstn
natural numbers using a recursive function. -
WAP to input a number
n
and find the sum of firstn
even numbers using a recursive function. -
WAP to input a number
n
and find the sum of the digits of the numbern
using a recursive function. -
WAP to input a number
n
and a numberp
and find the value ofn
raised to the powerp
using a recursive function. -
WAP to take appropriate values (
a
andd
) as input and find the sum of an Arithmetic Progression (AP) using recursion. -
Given a function defined as:
f(1) = 3 f(n) = 2 * f(n - 1) - 1
WAP to input an integer
n
and display the sum of firstn
terms of the above series using recursion.
Give the output of the following code:
#include <stdio.h>
void print_count()
{
static int count1 = 1;
int count2 = 1;
printf( "Count1 = %d, Count2 = %d\n", count1++, count2++);
}
int main()
{
print_count();
print_count();
print_count();
return 0;
}
Click to reveal answer...
Output:
Count1 = 1, Count2 = 1
Count1 = 2, Count2 = 1
Count1 = 3, Count2 = 1
-
Create CodeForces account if you haven't done so already and solve the following problems:
- https://codeforces.com/problemset/problem/546/A
- https://codeforces.com/problemset/problem/996/A
- https://codeforces.com/problemset/problem/379/A
- https://codeforces.com/problemset/problem/492/A
- https://codeforces.com/problemset/problem/4/A
- https://codeforces.com/problemset/problem/50/A
- https://codeforces.com/problemset/problem/617/A
- https://codeforces.com/problemset/problem/268/A
- https://codeforces.com/problemset/problem/1370/A
- https://codeforces.com/problemset/problem/520/B
-
Create HackerRank account if you haven't done so already and solve the following problems:
{% include disqus.html %}