WEEK: 8 PROGRAM 3 AND PROGRAM 4 NPTEL Problem Solving through Programming in C (Jan 27) 2020 solutions




PROBLEM SOLVING THROUGH PROGRAMMING IN C.

By Prof. ANUPAM BASU


WEEK 8:PROGRAM 3:

Write a C Program to print Binary Equivalent of an Integer using Recursion
Sample Test Cases
Input Output
Test Case 1
10
The binary equivalent of 10 is 1010
Test Case 2
257

The binary equivalent of 257 is 100000001
 int binary_conversion(int num)
{
    if (num == 0)
    {
        return 0;
    }
    else
    {
        return (num % 2) + 10 * binary_conversion(num / 2);
    }
}

WEEK 8:PROGRAM 4:

Write a C Program to reverse a given word using function. e.g. INDIA should be printed as  AIDNI

Sample Test Cases
Input Output
Test Case 1
computer
The string after reversing is: retupmoc
Test Case 2
NPTEL

The string after reversing is: LETPN

int a=strlen(str1);

reverse(str1,0,a);
return 0;
}


   void reverse(char str1[], int index, int size)
{
  char str2[20];int y=0;
     for(int i=size-1;i>=0;i--)
     {
       str2[y]=str1[i];
       y++;
     }
    str2[y]='\0';
        printf("The string after reversing is: %s\n",str2); 
    
}
Week-8 :Program-05
CLICK ON BELOW LINK.
<<CLICK HERE FOR  WEEK 8 :PROGRAM -05>>

<<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.

Copyright (c) 2020 Custom Programs All Right Reserved

Pages