ABOUT THE COURSE :

Problem Solving Through Programming In C Week 5 Solutions

Disclaimer: The answers to these questions are provided for educational and informational purposes only. This website does not claim any surety of 100% correct answers. So, this website urges you to complete your assignment yourself.

This course is aimed at enabling the students to
    1. Formulate simple algorithms for arithmetic and logical problems 
    2. Translate the algorithms to programs (in C language) 
    3. Test and execute the programs and correct syntax and logical errors
    4. Implement conditional branching, iteration and recursion
    5. Decompose a problem into functions and synthesize a complete program using divide and conquer approach
    6. Use arrays, pointers and structures to formulate algorithms and programs
    7. Apply programming to solve matrix addition and multiplication problems and searching and sorting problems
    8. Apply programming to solve simple numerical method problems, namely rot finding of function, differentiation of function and simple integration

Summary
Course Type Elective
Duration 12 weeks
Category Computer Science and Engineering
Start Date 22 Jan 2024
End Date 12 Apr 2024
Exam Registration Ends 16 Feb 2024
Exam Date 21 Apr 2024 IST

Assignment Solutions :
Programming Assignment :

Week-05: Program-01 :

Write a C program to check whether a given number (N) is a perfect number or not? [Perfect Number - A perfect number is a positive integer number which is equals to the sum of its proper positive divisors.
For example 6 is a perfect number because its proper divisors are 1, 2, 3 and it’s sum is equals to 6.]

int i, sum=0;
    for(i=1; i<N;i++)
    {
        if(N%i==0)
            sum+=i;
    }
 
    if(sum==N)
        printf("\n%d is a perfect number.",N);
    else
        printf("\n%d is not a perfect number.",N);
}

Week-05: Program-02 :

Write a C program to count total number of digits of an Integer number (N).

int temp, count; 
count=0;
    temp=N;
    while(temp>0)
    {
        count++;
        temp/=10;
    }
     printf("The number %d contains %d digits.",N,count);
}

Week-05 Program-03 :

Write a C program to check whether the given number(N) can be expressed as Power of Two (2) or not.
For example 8 can be expressed as 2^3

int temp, flag;
    temp=N;
    flag=0;
   
    while(temp!=1)
    {
        if(temp%2!=0){
            flag=1;
            break;
        }
        temp=temp/2;
    }
  
    if(flag==0)
        printf("%d is a number that can be expressed as power of 2.",N);
    else
        printf("%d cannot be expressed as power of 2.",N);
}

Week-05 Program-04 :

Write a C program to find sum of following series where the value of N is taken as input 1+ 1/2 + 1/3 + 1/4 + 1/5 + .. 1/N

int i;
for(i=1;i<=N;i++)
sum = sum + ((float)1/(float)i);
printf("Sum of the series is: %.2f\n",sum);
}

CRITERIA TO GET A CERTIFICATE :
  1. Average assignment score = 25% of average of best 8 assignments out of the total 12 assignments given in the course.
  2. Exam score = 75% of the proctored certification exam score out of 100
  3. Final score = Average assignment score + Exam score
YOU WILL BE ELIGIBLE FOR A CERTIFICATE ONLY IF AVERAGE ASSIGNMENT SCORE >=10/25 AND EXAM SCORE >= 30/75. If one of the 2 criteria is not met,you will not get the certificate even if the Final score >= 40/100.

Join With Us On :