NPTEL Programming in C++ Week1 Programming Assignment Solutions 2021 | Swayam

 



Week-1


W1_Programming-Qs1

ANS-


#include<iostream>

#include<algorithm>

#include<cctype>

#include<string.h>

using namespace std;

 bool compare(char c1,char c2){

    return tolower(c1)>tolower(c2);  //Line-1

}

-----------------------------------------------------------------------------------

W1_Programming-Qs2

ANS-

void  (*fun_ptr[ch])(int , int) = {andop,orop,xorop};  //Line-1

void  caller(int ch, int a, int b)  

{

      If(ch<=2)

              (*fun_ptr[ch])(a,b);        //Line-2

}

 =-----------------------------------------------------------------------------------------------------------------------

W1_Programming-Qs3

ANS-

Int compare(char *s1, char *s2, int n){

             return strncmp(s1,s2,n);   //Line-1

}


No comments:

Powered by Blogger.