Wednesday, October 14, 2020

NPTEL INTRODUCTION TO PROGRAMMING IN C WEEK 4 ANSWERS (JUL-DEC 2020)

 Question 1:

#include<stdio.h>


int main()

{

int arr1[100], arr2[100];

int n1,n2;

int check = 1;

int i;

  int k;

scanf("%d",&n1);

for( i = 0; i < n1; i++)

scanf("%d",&arr1[i]);


scanf("%d",&n2);

for( i = 0; i < n2; i++ )

scanf("%d",&arr2[i]);


for(i = 0; i < n1; i++)//sorting arr1.

{

for(int j = i; j < n1; j++)

{

if(arr1[j]>arr1[i])

{

int temp = arr1[i];

arr1[i] = arr1[j];

arr1[j] = temp;

}

}

}


for (int k = 0; k < n1; k++)//comparing arr1 and arr2.

{

check = 1;

for(i = 0; i < n2; i++)

{

if(arr1[k] == arr2[i])

{

check = 0;

break;

}

}

if(check == 1)

{

printf("%d",arr1[k] );

break;

}


}

if(check == 0)

printf("0");

return 0;


Question 2:

#include<stdio.h>


int main()

{

int arr[100];

int n1,n2;

int counter = 0;

int i;

scanf("%d",&n1);

for( i = 0; i < n1; i++)

scanf("%d",&arr[i]);



for(i = 0; i < n1; i++)

{

for(int j = i; j < n1; j++)

{

if(arr[j]>arr[i])

{

int temp = arr[i];

arr[i] = arr[j];

arr[j] = temp;

}

}

}


for( i = 0; i < n1; i++)

{

if(arr[i] != arr[i+1])

counter++;

}

printf("%d",counter );


return 0;


}

Question 3:

#include <stdio.h>

#include <stdlib.h>

#include <string.h>



char* replaceWord(const char* s, const char* oldW,

                  const char* newW)

{

    char* result;

    int i, cnt = 0;

    int newWlen = strlen(newW);

    int oldWlen = strlen(oldW);



    for (i = 0; s[i] != '\0'; i++) {

        if (strstr(&s[i], oldW) == &s[i]) {

            cnt++;



            i += oldWlen - 1;

        }

    }



    result = (char*)malloc(i + cnt * (newWlen - oldWlen) + 1);


    i = 0;

    while (*s) {


        if (strstr(s, oldW) == s) {

            strcpy(&result[i], newW);

            i += newWlen;

            s += oldWlen;

        }

        else

            result[i++] = *s++;

    }


    result[i] = '\0';

    return result;

}



int main()

{

    char str[100];

    char c[2];

    char d[10];


    char* result = NULL;


    scanf("%s",str);

    scanf("%s",c);

    scanf("%s",d);


    result = replaceWord(str, c, d);

    printf("%s", result);


    free(result);

    return 0;

}


Tuesday, October 13, 2020

NPTEL PROGRAMMING IN C++ ASSIGNMENT WEEK 4 ANSWERS 2020(JUL-DEC)

 Question 1 :

#include <iostream>

using namespace std;


class B;             // LINE-1


class A {

    int a_ = 0;

public:

    A(int x) : a_(x) { }

    int addB(B&);

    int subtractB(B&);

};


class B {

    int b_ = 5;

public:

    friend class A;         // LINE-2

};


Question 2:

Complex operator *(const Complex &c) { // LINE-1

        int x, y;

        x = re*(c.re) - im*(c.im);            // LINE-2

        y = im*(c.re) + (c.im)*re;            // LINE-3

        Complex t1(x, y);

        return t1;

    }


Question 3:

        if(data == m1.data) m.data = 1;    // LINE-1

            return m;

    }

};


void fun(myClass m) { // LINE-2


Question 4:

#include <iostream>

using namespace std;


class myClass {

    int data;

    static myClass *t;        // LINE-1 Complete the declaration

    myClass(int x) : data(x) { }

public:

    static myClass *create(int x) {    // LINE-2 Mention return type of the function

        if (!t)

            t = new myClass(x);       // LINE-3 Allocate memory towards object t

            return t;

    }



Saturday, October 10, 2020

NPTEL PROGRAMMING IN JAVA WEEK 4 ANSWERS (JUL-DEC 2020)

 

QUESTION 1:


import java.io.*;
import java.util.*;
import static java.lang.System.*;

QUESTION 2:


// Create an object of Calendar class. 
java.util.Calendar current ;

// Use getInstance() method to initialize the Calendar object.
current = java.util.Calendar.getInstance();

// Initialize the int variable year with the current year
year = current.get(current.YEAR);

QUESTION 3:


interface ExtraLarge{
String extra = "This is extra-large";
void display();
}

class Large {
    public void Print() {
        System.out.println("This is large");
    }
}

class Medium extends Large {
    public void Print() {
       super.Print();  
        System.out.println("This is medium");
    }
}
class Small extends Medium {
    public void Print() {
        super.Print();  
        System.out.println("This is small");
    }
  }


class Question43 implements ExtraLarge{
    public static void main(String[] args) {
        Small s = new Small();
        s.Print();
  Question43 q = new Question43();
  q.display();
    }
  public void display(){
    System.out.println(extra);
  }
}


QUESTION 4:


// Call show() of First interface.
First.super.show();
// Call show() of Second interface.
Second.super.show();

QUESTION 5:


// Interface ShapeX is created
interface ShapeX {
 public String base = "This is Shape1";
 public void display1();
}

// Interface ShapeY is created which extends ShapeX
interface ShapeY extends ShapeX {
 public String base = "This is Shape2";
 public void display2();
}

// Class ShapeG is created which implements ShapeY
class ShapeG implements ShapeY {
 public String base = "This is Shape3";
 //Overriding method in ShapeX interface
 public void display1() {
  System.out.println("Circle: " + ShapeX.base);
 }
 // Override method in ShapeY interface
  public void display2(){
  System.out.println("Circle: " + ShapeY.base);}
}

Tuesday, October 6, 2020

NPTEL PROGRAMMING IN C++ ASSIGNMENT WEEK 3 ANSWERS 2020(JUL-DEC) || CODE LINK IN THE COMMENTS

 Question 1:

 triangle(int b, int h) : _base(&b), _height(&h) { } // Line-1


    // LINE-1: Complete Constructor definition


    ~triangle() {

        _base = 0; // Line-2

        _height = 0;// LINE-2: Complete destructor to delete both data pointers


    }

    double area();

};


double triangle::area() {  // LINE-3: Complete function header

Question 2:

 mutable int _sem;        // LINE-1

public:

    Student(int roll, string name, int sem)

        : _roll(roll), _name(name), _sem(sem) { }


    void promote() const { // LINE-2

        _sem++;

    }


    void display() const{ // LINE-3

Question 3:

#include <iostream>

#include <string>

using namespace std;


class Complex {

    const int _r, _i;


public:

    Complex() : _r(0), _i(0){ }                       // LINE-1


    Complex(int r) : _r(r),_i(0) { }                  // LINE-2


    Complex(int r, int i) : _r(r), _i(i) { }           //          


Question 4 :

integer objA;  // LINE-1: Invoke Default Constructor


    integer objB(val);  // LINE-2: Invoke Parameterized Constructor


    integer objC = objB;  // LINE-3: Invoke Copy Constructor

Monday, October 5, 2020

NPTEL PROGRAMMING IN JAVA WEEK 3 ANSWERS (JUL-DEC 2020)


QUESTION 1:

if (n<=1) 
            return (1-n); 
        return fib(n - 1) + fib(n - 2); 

QUESTION 2:

class Point{
   double x,y;
  
   public double distance(Point p1, Point p2)
                {
                  
                  double root=(p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y);
                  root=Math.sqrt(root);
                  System.out.print(root);
                  return root;
                }
}

QUESTION 3:


//Create a derived class constructor which can call the one parametrized constructor of the base class
double height;
Test1(double l, double h){
  super(l);
  this.length=l;
  this.height=h;
}

//Create a derived class constructor which can call the two parametrized constructor of the base class
Test1(double l, double b, double h){
  super(l,b);
  this.length=l;
  this.breadth=b;
  this.height=h;
}
  
  

//Override the method calculate() in the derived class to find the volume of a shape instead of finding the area of a shape

double calculate(){
  
  return length*breadth*height;}

QUESTION 4:


QuestionScope a= new QuestionScope();
System.out.println(a.sum(n1,n2));
System.out.print(QuestionScope.multiply(n1,n2));

QUESTION 5:


static void swap(Question obj)
        {
          int temp;
          temp=obj.e1;
          obj.e1=obj.e2;
          obj.e2=temp;
        }

Wednesday, September 30, 2020

NPTEL INTRODUCTION TO PROGRAMMING IN C WEEK 3 ANSWERS (JUL-DEC 2020)

 Question 1:

#include<stdio.h>


int find_odd(int k)

{

  int num;

  int counter = 0;

  int check = 0;

  

  while(num != -1)

  {

    scanf("%d",&num);

    if(num%2!=0)

    {

      counter++;

      if(counter == k)

      {

        printf("%d",num);

        check = 1;

      }

    }

    

       

  }

   if((counter != k) && (check == 0))

      printf("-1");


  return 0;

}



int main()

{

  int k;

  scanf("%d",&k);

  find_odd(k);

  return 0;

}

Question 2:

#include<stdio.h>


int main()

{

  float num1,num2;

  float m_avg;

  

  scanf("%f",&num1);

  

  while(num1 != -1)

  {

    num2 = num1;

    scanf("%f",&num1);

      if(num1!=-1)

        { m_avg = (num1+num2)/2;

    printf("%0.1f ",m_avg);

        }

    

  }

  return 0;

}

    

Question 3:


#include<stdio.h>


int main()

{

  int n;

  scanf("%d",&n);

  int fac = 1;

  

  for(int i = 1; i<n; i++)

  {

    fac = fac*i; 

    if(fac <= n)

     {

        printf("%d ",fac);

      }

    else 

      break;

  }

  return 0;

  

}


Thursday, September 24, 2020

NPTEL PROGRAMMING IN JAVA WEEK 2 ANSWERS (JUL-DEC 2020)

 Question 1:

// Create an object of class Student


// Call 'print()' method of class Student 


// Create an object of class School


// Call 'print()' method of class School


Student obj = new Student();


obj.print();


School obj_1 = new School();


obj_1.print();


 Question 2:

// Create an object of class Printer


// Call 'print()' methods for desired output


Printer obj = new Printer();


obj.print("Hi! I am class STUDENT");


obj.print();


 Question 3:

// Define a method named 'studentMethod()' in class Question


// Call the method named 'print()' in class Question


void studentMethod(){

  

  Question23 obj = new Question23();

  print(obj);

}



 Question 4:

class Answer{

Answer(){

System.out.println("You got nothing.");

}

Answer(int marks, String type){

      this();

System.out.print("You got "+marks+" for an "+type);

}

}


 Question 5:

//Declare variable with name 'nptel', 'space' and 'java' and proper datatype.


//Initialize the variables with proper input


String nptel = "NPTEL", space = " ", java = "JAVA";


Wednesday, September 23, 2020

NPTEL INTRODUCTION TO PROGRAMMING IN C WEEK 2 ANSWERS (JUL-DEC 2020)

Question 1:

#include<stdio.h>

int main()
{
  int arr[50][50];
  int n;
  int upper = 1, lower = 1;
  scanf("%d",&n);
  
  for(int i=0; i<n; i++)
  {
    for(int j=0; j<n; j++)
      scanf("%d",&arr[i][j]);
  }
  
  for(int i=0; i<n; i++)
  {
    for(int j=0; j<n; j++)
    {
      if(i>j&&arr[i][j]!=0)
      {
        upper = 0;
      }
      
      else if(j>i&&arr[i][j]!=0)
      {
        lower = 0;
      }
     } 
  }
  
 if(upper == 1 && lower == 0)
   printf("1");
 else if(upper == 0 && lower == 1)
   printf("-1");
 else if (upper == 1 && lower == 1)
   printf("2");
 else 
   printf("0");
  
  return 0;
}


Question 2:


#include<stdio.h>

int main()
{
  int n;
  int arr[100];
  int i=0;
  
  
  while(n!=-1)
  {
    scanf("%d",&n);
    arr[i]=n;
    i++;
  }
  
  for(int j=0; j<i; j++)
    for(int k=j; k<i; k++)
    if(arr[j]<arr[k])
  {
    int temp;
    temp = arr[j];
    arr[j] = arr[k];
    arr[k] = temp;
  }
  
  int distinct=0;
  
  for(int j=0; j<i-1; j++)
  {
    if(arr[j]!=arr[j+1])
      distinct++;
  }
  
  if(distinct>=3)
    printf("1");
  else 
    printf("0");
}


Question 3:


#include<stdio.h>

int main()
{
  int n;
  int arr[100];
  int i=0;
  
  
  while(n!=-1)
  {
    scanf("%d",&n);
    arr[i]=n;
    i++;
  }
  
  for(int j=0; j<i; j++)
    for(int k=j; k<i; k++)
    if(arr[j]<arr[k])
  {
    int temp;
    temp = arr[j];
    arr[j] = arr[k];
    arr[k] = temp;
  }
  
  int distinct=0;
  
  for(int j=0; j<i-1; j++)
  {
    if(arr[j]!=arr[j+1]&&arr[j+1]!=-1)
    {
      distinct=arr[j+1];
      printf("%d",distinct);
      break;
    }
  }
  
  if(distinct==0)
    printf("0");
    
}

NPTEL PROGRAMMING IN C++ ASSIGNMENT WEEK 2 ANSWERS 2020(JUL-DEC)

 Question 1:

Complex operator*(Complex &p1, Complex &p2) { // LINE-1
    struct Complex p3 = { 0, 0 };
    p3.x = (p1.x)*(p2.x) - (p1.y)*(p2.y); // LINE-2
    p3.y = (p1.x)*(p2.y) + (p1.y)*(p2.x); // LINE-3
    return p3;
}


Question 2:

#include <iostream>
#include <string>
using namespace std;
void print(string a, string b = "Anyone") { // LINE-1


Question 3:

#include <iostream>
using namespace std;
int Double(int a) { // LINE-1
    return a*2;   // LINE-2
}


Qu
estion 4:

int main() {
    int *p;
    int arr[10];
  p =  arr;// LINE-1
    
    process(p);
    
        
    return 0;
}


Monday, September 14, 2020

Programming in Java WEEK 1 NPTEL(JULY - DEC 2020) ASSIGNMNET SOL.

Question 1: 

 
if(radius>0)
       {
perimeter = 2*Math.PI*radius;
    area = (Math.PI)*radius*radius;
          System.out.println(perimeter);
          System.out.print(area);
       }

else 
      System.out.print("please enter non zero positive number");


Question 2:


//Use if...else ladder to find the largest among 3 numbers and store the largest number in a variable called result.

if(x>y)
        {
          if(x>z)
            System.out.print(x);
          else 
            System.out.print(z);
        }

else 
        {
          if(y>z)
            System.out.print(y);
          else
            System.out.print(z);
        }

Question 3:


//Use for or while loop do the operation

  for(int i = 0, j = 0; i<n; i++, j=j+2)
      {
        if(j%3==0)
          sum = sum + j;
      }
  System.out.print(sum);
        

Question 4:


//Use while loop check the number is Armstrong or not.
//store the output(1 or 0) in result variable.
int sum = 0;
int n1 = n;
int counter = 0;
int[] arr = new int[100];

while(n>0)
        {
          int rem = n%10;
          arr[counter] = rem;
          n = n/10;
          counter++;
        }

for(int i=0; i<counter; i++)
        {
          int l = 1;
          for(int j=1; j<=counter; j++)
          {
            l=l*arr[i];
          }
          sum = sum + l;
        }
            

if(sum == n1)
          result = 1;
else 
          result = 0;

System.out.print(result);

          

Question 5:


//Initialize maximum element as first element of the array.  
   //Traverse array elements to get the current max.
   //Store the highest mark in the variable result.
   //Store average mark in avgMarks.
int largest;
int sum = 0;
float avg;
for(i=0;i<arr.length;i++)
  {
        for(int j = i; j<arr.length; j++)
                  if(arr[i]<arr[j])
                {
                  int temp = arr[i];
                  arr[i] = arr[j];
                  arr[j] = temp;
                }
    } 

largest = arr[0];

for(i=0;i<arr.length;i++)
  {
        sum = sum + arr[i];
  } 
avg = sum/arr.length;
System.out.println(largest);
System.out.print(avg);

Programming in C++ WEEK 1 NPTEL(JULY-DEC 2020) ASSIGNMNET SOL.

 Question 1 :

stack<char> s;    // LINE-1    



    for (int i = 0; i < strlen(str); i++)


        s.push(str[i]);    // LINE-2


Question 2 :

bool StrCmp(string s1, string s2) {


    if (s1.length()>s2.length() || s1.length()<s2.length())    // LINE-1

    

        return 1;    // LINE-2

    else

        return 0;    // LINE-3

}


Question 3 :

typedef void (*Fun_Ptr)(int,int); // LINE-1


Fun_Ptr fp = &add; // LINE-2

Sunday, September 13, 2020

Introduction to Programming in C week 1 NPTEL(JULY - DEC 2020) assignmnet solution

 Question 1 :

#include<stdio.h>


void  main()

{

  int arr[4];

  for(int i=0; i<3; i++)

    scanf("%d",&arr[i]);    //To take input.

  

  int sum = arr[0] + arr[1];

  

  if(sum>arr[2]) //if statement to check wether third number is smaller than the sum of

    printf("1"); //first two.

  else 

    printf("0");

}



Question 2 :

#include<stdio.h>


void main()

{

  int m,n;

  scanf("%d",&m);

  scanf("%d",&n);

  

  int rem = m%n;  //% is used to find the remainder.

  

  if(rem==1)

    printf("1");

  else 

    printf("0");

  

}


Question 3:

#include<stdio.h>


void main()

{

  float arr[4];

  

  for(int i=0; i<3; i++)

    scanf("%f",&arr[i]);

  

  //To check wether the triplet is strictly increasing or decreasing or none.

  

  if(arr[0]>arr[1]&&arr[1]>arr[2])

    printf("1");

  else if(arr[2]>arr[1]&&arr[1]>arr[0])

    printf("1");

  else

    printf("0");

}

  

Saturday, August 1, 2020

GTA San Andreas 2.00 Full Apk + Data for Android 2020

Five years ago, Carl Johnson escaped from the pressures of life in Los Santos, San Andreas, a city tearing itself apart with gang trouble, drugs and corruption. Where filmstars and millionaires do their best to avoid the dealers and gangbangers.


Now, it’s the early 90’s. Carl’s got to go home. His mother has been murdered, his family has fallen apart and his childhood friends are all heading towards disaster.
On his return to the neighborhood, a couple of corrupt cops frame him for homicide. CJ is forced on a journey that takes him across the entire state of San Andreas, to save his family and to take control of the streets.
Rockstar Games brings its biggest release to mobile yet with a vast open-world covering the state of San Andreas and its three major cities – Los Santos, San Fierro and Las Venturas – with enhanced visual fidelity and over 70 hours of gameplay.
Grand Theft Auto: San Andreas features:
  • Remastered, high-resolution graphics built specifically for mobile including lighting enhancements, an enriched color palette and improved character models.
  • Cloud save support for playing across all your mobile devices for Rockstar Social Club Members.
  • Dual analog stick controls for full camera and movement control.
  • Three different control schemes and customizable controls with contextual options to display buttons only when you need them.
  • Compatible with the MoGa Wireless Game Controllers and select Bluetooth and USB gamepads.
  • Integrated with Immersion tactile effects.
  • Tailor your visual experience with adjustable graphic settings.
Languages Supported: English, French, Italian, German, Spanish, Russian and Japanese.
For optimal performance, we recommend re-booting your device after downloading and closing other applications when playing Grand Theft Auto: San Andreas.
For information about supported devices and compatibility, please see:
http://support.rockstargames.com/hc/en-us/sections/200251868-San-Andreas-Mobile-Support
Mobile Version developed by War Drum Studios
www.wardrumstudios.com

Download link :

                           Download APK file


                         Download DATA file

Tuesday, July 28, 2020

Solving your first problem in C++ on CodeChef

Problem Name : Life, the Universe, and Everything

How to solve this question?


In this question they telling us to take the input of a number and display that number, repeat this proedure till we encounter number 42. After that we need to stop.

Solution :


#include <iostream>
using namespace std;

int main() {
// your code goes here
int number;
cin>>number;
while(number!=42)
{
    cout<<number<<endl;
    cin>>number;
}
return 0;
}




Sunday, July 26, 2020

Introduction to Programming in C week 0 assignment(jul-dec 2020)

Hello everyone! solution of Introduction to Programming in C week 0 assignment are given below.

Question 1 : 


#include<stdio.h>

int main()
{
  printf("Hello C");
  return 0;
}

Question 2 :


#include<stdio.h>

int main()
{
  int a,b;
  scanf("%d%d",&a,&b);
  int avg = (a+b)/2;
  printf("%d",avg);
  return 0;
}



Tuesday, April 7, 2020

PROGRAMMING IN JAVA WEEK 10

QUESTION 1:

import java.*;
import java.sql.*;

QUESTION 2:

// Open a connection and check connection status
conn = DriverManager.getConnection(DB_URL);
if(conn.isClosed())
  System.out.print("false");
else
  System.out.print("true");

QUESTION 3:

import java.sql.*;
import java.util.Scanner;
import java.lang.*;

public class Question103 {
    public static void main(String args[]) {
        try {
              Connection conn = null;
              Statement stmt = null;
              String DB_URL = "jdbc:sqlite:/tempfs/db";
              System.setProperty("org.sqlite.tmpdir", "/tempfs");
            conn = DriverManager.getConnection(DB_URL);
              conn.close();
              System.out.print(conn.isClosed());
        }
       catch(Exception e){ System.out.println(e);}
    }
}


QUESTION 4:

// The statement containing SQL command to create table "players"
String sql = "CREATE TABLE PLAYERS "+
  "(UID INT, "+
  "First_Name VARCHAR(45), "+
  "Last_Name VARCHAR(45), "+
  "Age INT, "+
  " PRIMARY KEY(UID))";

// Execute the statement containing SQL command below this comment
stmt.executeUpdate(sql);


QUESTION 5:

// Write the SQL command to rename a table
String str = "alter table PLAYERS rename to SPORTS";

// Execute the SQL command
stmt.executeUpdate(str);


Monday, March 23, 2020

WEEK 8

QUESTION 1:


// Declare a user-defined exception
class NegativeValException : public exception {     // LINE-1
public:
    virtual const char* what() const throw() {
        return "Negative value";
    }
};

// Declare a user-defined exception
class ZeroValException : public exception {         // LINE-2
public:
    virtual const char* what() const throw() {
        return "Zero";
    }
};

int main() {
    int i;
    cin >> i;
   
    try {
        if (i < 0)
            // Throw the exception object
            throw NegativeValException();                               // LINE-3

        else if (i == 0)
            // Throw the exception object
            throw ZeroValException();                               // LINE-4

QUESTION 2:


template <class T, int n>                    // LINE-1
class container {
    T arr[n];                // LINE-2

    int i;
public:
    container() : i(-1) { }

    void operator=(char data) {// LINE-3

QUESTION 3:


template <class T, int n>  // LINE-1

void mysequence<T,n>::setVal(int i, T value) {  // LINE-2

    items[i] = value;
}

template <class T, int n>   // LINE-3

T mysequence<T,n>::getVal(int i) {  // LINE-4

    return items[i];
}

Wednesday, March 18, 2020

WEEK 7 ASSIGNMENT SOLUTION

GUYS I KNOW I WAS SUPER INCONSISTENT AND LATE IN UPLOADING THE SOLUTIONS BUT I WAS HAVING A BUSY TIME IN PAST FEW WEEKS(COLLEGE WORK ) , I AM NOT GIVING ANY EXCUSES BUT JUST LETTING YOU ALL GUYS KNOW WHAT WAS THE REASON DUE TO WHICH I AM UPLOADING VIDEOS SO LATE. AND THANKS FOR WATCHING MY STUFF. 

QUESTION 1:

import java.util.*;
public class Question1{
        public static void main (String[] args){

//Write the appropriate code to read the 3 integer values and find their sum.
 int a,b=0,sum=0;
          Scanner i = new Scanner(System.in);
          for(a=0; a<3; a++)
          {
            b=i.nextInt();
            sum=sum+b;
          }

QUESTION 2:


try{InputStreamReader r=new InputStreamReader(System.in); 
   BufferedReader br=new BufferedReader(r); 
   String number=br.readLine(); 
   int x = Integer.parseInt(number);
   System.out.print(x*x);
   }
catch(Exception e){
  System.out.print("Please enter valid data");
}

QUESTION 3:


// Complete the code to get specific indexed byte value and its corresponding char value.
String str=new String(barr,n,1);
System.out.println(barr[n]);
System.out.print(str);
}

QUESTION 4:


//Write your code here to count the number of vowels in the string "s1"
for(int i=0;i<s1.length();i++){
  char s=s1.charAt(i);
  if(s=='a'||s=='A'||s=='e'||s=='E'||s=='i'||s=='I'||s=='o'||s=='O'||s=='u'|| s=='U')
  {
    c=c+1;
  }
}

QUESTION 5:


//Replace the char in string "s1" with the char 'a' at index "n"  and print the modified string
byte[] barr=s1.getBytes();
byte b1=(byte) c;
barr[n]=b1;
System.out.print(new String(barr));
}

Monday, March 16, 2020

WEEK 7 ASSIGNMENT SOLUTION

QUESTION 1:


Container& operator =(int val) {      // LINE-1

        this->arr[++i] = val;
        return *this;
    }

    operator int()  {      // LINE-2

        return arr[i--];
    }
};


QUESTION 2:


    virtual void print(int i)=0;          // LINE-1
};

class derived1 : public base{ // LINE-2
public:
    void print(int i) { cout << i * 1 << " "; }
};

class derived2 : public base { // LINE-3
public:
    void print(int i) { cout << i * 2 << " "; }
};

class derived3 : public base{ // LINE-4

QUESTION 3:


void updateSem(int new_sem) const{             // LINE-1

        student* ptr=const_cast<student*> (this);
      ptr->sem = new_sem;             // LINE-2
    }

    void show() const { 


QUESTION 4:


class derived1 : virtual public base {    // LINE-1
public:
    derived1();
    derived1(int _pr);
};

class derived2 : virtual public base {    // LINE-2
public:
    derived2();
    derived2(int _pr);
};

class dd : public derived2, public derived1 {          // LINE-3

Wednesday, March 11, 2020

WEEK 6 ASSIGNMENT SOLUTION

QUESTION 1:

// Write the appropriate code to extend the Thread class to complete the class Question61.
public class Question61 extends Thread{

public void run()
{
  System.out.print("Thread is Running.");
}

QUESTION 2:

// Create main class Question62 with main() method and appropriate statements in it
public class Question62{
  public static void main(String[] args){
    ThreadRun a = new ThreadRun();
    Thread b = new Thread(a);
    b.start();
  }
}


QUESTION 3:

// Create a class named MyThread and extend/implement the required class/interface

// Define a method in MyThread class to print the output

class MyThread extends B
{
  public void run()
  {
    System.out.print("NPTEL Java");
  }
}

QUESTION 4:

synchronized void print(int n){
   for(int i=1;i<=5;i++){ 
     System.out.println(n*i); 
     try{ 
      Thread.sleep(400); 
     }catch(Exception e){
        System.out.println(e);
     } 
   }
 } 


QUESTION 5:

// Write the necessary code below...
t.setPriority(Thread.MAX_PRIORITY);
t.start();
t.setName("NPTEL");

Saturday, March 7, 2020

WEEK 6 ASSIGNMENT SOLUTION

QUESTION 1:

virtual void compute(){ n = n*n; }           // LINE-1

   
    virtual void show(){ cout << n << endl; } // LINE-2
};

QUESTION 2:


Base::f();          // LINE-1 Call proper function
        cout << name << endl;
    }
    void g() {
        Base::g();          // LINE-2 Call proper function
    }
};

void Base::f(){                // LINE-3 Write proper function header
    cout << "Good day, ";
}

void Base::g(){                // LINE-4 Write proper function header


QUESTION 3:


virtual void computeSalary()=0;                      // LINE-1

    double computePF(int basic) { return (basic*pf / 100); }
};

class Manager : public Employee {
    int basic;
public:
    Manager(int b) : basic(b) { }
    void computeSalary() {

        double pf = Employee::computePF(basic);      // LINE-2

        double sal = basic + pf;
        cout << "Manager's Salary: " << sal << endl;
    }
};

class Analyst : public Employee {
    int basic;
public:
    Analyst(int b) : basic(b) { }
    void computeSalary() {

        double pf = Employee::computePF(basic);    // LINE-3

QUESTION 4:


virtual ~base() { print(); }    // LINE-1

};

class derived : public base {
public:
    derived(int _counter = 0) : base(++_counter) { cout << counter << " "; }
   
    virtual ~derived(){ print(); }   // LINE-2
};

Wednesday, March 4, 2020

WEEK 5 ASSIGNMENT SOLUTION

QUESTION 1 :


//Create a class A which implements the interface Number.
class A implements Number
{
  public int findSqr(int i)
  {
    return i*i;
  }
}

QUESTION 2:

 
//Create a class B, which implements the interface GCD.
class B implements GCD
{
  public int findGCD(int a, int b)
  {
    if(b==0)
      return a;
    else
      return findGCD(b,a%b);
  }
}

QUESTION 3:


//Read any two values for a and b.
 //Get the result of a/b;
a=input.nextInt();
b=input.nextInt();
{
  try
  {
    if(b!=0)
    {
      System.out.print(a/b);
      System.exit(0);
    }
  }
  finally
  {
    System.out.print("Exception caught: Division by zero.");
  }
}

QUESTION 4:


//Define try-catch block to save user input in the array "name",if there is an exception then catch the exception otherwise print the total sum of the array.
try
{
  for(int i=0; i<length; i++)
  {
    name[i]=sc.nextInt();
    sum=sum+name[i];
  }
  System.out.print(sum);
  System.exit(0);
}
finally
{
  System.out.print("You entered bad data.");
}

QUESTION 5:


// Put the following code under try-catch block to handle exceptions
      try
      {
switch (i)
        {
    case 0 :
int zero = 0;
j = 92/ zero;
break;
        case 1 :
int b[ ] = null;
j = b[0] ;
break;
      default:
       System.out.print("No exception");
}
      }
     catch(Exception e)
        {
          System.out.print(e);
        }

Monday, February 24, 2020

WEEK 4 ASSIGNMENT

QUESTION 1:


import java.io.*;
import java.util.*;
import static java.lang.System.*;

QUESTION 2:


// Create an object of Calendar class. 
java.util.Calendar current ;

// Use getInstance() method to initialize the Calendar object.
current = java.util.Calendar.getInstance();

// Initialize the int variable year with the current year
year = current.get(current.YEAR);

QUESTION 3:


interface ExtraLarge{
String extra = "This is extra-large";
void display();
}

class Large {
    public void Print() {
        System.out.println("This is large");
    }
}

class Medium extends Large {
    public void Print() {
      super.Print();  
        System.out.println("This is medium");
    }
}
class Small extends Medium {
    public void Print() {
        super.Print();  
        System.out.println("This is small");
    }
  }


class Question43 implements ExtraLarge{
    public static void main(String[] args) {
        Small s = new Small();
        s.Print();
  Question43 q = new Question43();
  q.display();
    }
  public void display(){
    System.out.println(extra);
  }
}


QUESTION 4:


// Call show() of First interface.
First.super.show();
// Call show() of Second interface.
Second.super.show();

QUESTION 5:


// Interface ShapeX is created
interface ShapeX {
 public String base = "This is Shape1";
 public void display1();
}

// Interface ShapeY is created which extends ShapeX
interface ShapeY extends ShapeX {
 public String base = "This is Shape2";
 public void display2();
}

// Class ShapeG is created which implements ShapeY
class ShapeG implements ShapeY {
 public String base = "This is Shape3";
 //Overriding method in ShapeX interface
 public void display1() {
  System.out.println("Circle: " + ShapeX.base);
 }
 // Override method in ShapeY interface
  public void display2(){
  System.out.println("Circle: " + ShapeY.base);}
}

Saturday, February 15, 2020

WEEK 3 ASSIGNMENT SOLUTION

HEY! GUYS HERE IS THE CODE OF ALL THE QUESTIONS:

QUESTION 1:

if (n<=1) 
            return (1-n); 
        return fib(n - 1) + fib(n - 2); 

QUESTION 2:

class Point{
  double x,y;
 
  public double distance(Point p1, Point p2)
                {
                  
                  double root=(p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y);
                  root=Math.sqrt(root);
                  System.out.print(root);
                  return root;
                }
}

QUESTION 3:


//Create a derived class constructor which can call the one parametrized constructor of the base class
double height;
Test1(double l, double h){
  super(l);
  this.length=l;
  this.height=h;
}

//Create a derived class constructor which can call the two parametrized constructor of the base class
Test1(double l, double b, double h){
  super(l,b);
  this.length=l;
  this.breadth=b;
  this.height=h;
}
  
  

//Override the method calculate() in the derived class to find the volume of a shape instead of finding the area of a shape

double calculate(){
  
  return length*breadth*height;}

QUESTION 4:


QuestionScope a= new QuestionScope();
System.out.println(a.sum(n1,n2));
System.out.print(QuestionScope.multiply(n1,n2));

QUESTION 5:


static void swap(Question obj)
        {
          int temp;
          temp=obj.e1;
          obj.e1=obj.e2;
          obj.e2=temp;
        }


Tuesday, February 11, 2020

PROGRAMMING IN C++ WEEK 3

HELLO!! FRIENDS HERE I HAVE PASTED ONLY THE SOLUTION AND NOT THE COMPLETE PROGRAM SO PASTE IT CAREFULLY IN YOUR SOLUTION.

QUESTION 1:

mutable int bill;                  // LINE-1

public:
    Customer(int _cust_id, string _name, int _bill)
        : cust_id(_cust_id), name(_name), bill(_bill) {}

    void changeBill(int s)const {    // LINE-2

        bill = s;
    }

    void display()const {            // LINE-3 

QUESTION 2:

public:
Point(int _x, int _y) : x(_x), y(_y){} 

// Copy constructor 
Point( const Point& p2 ) : x( p2.x*10 ), y( p2.y*10 ){} 

QUESTION 3:

class Point {
    mutable int x;    // LINE-1

    mutable int y;    // LINE-2
public:
    Point(int _x, int _y) : x(_x), y(_y){}

    void changePoint(int _x, int _y)const {    // LINE-3

        x = _x;
        y = _y;
    }

    void showPoint()const {    // LINE-4

QUESTION 4:

// LINE-1: define parametrized constructor 
Rectangle::Rectangle(int _h, int _w)
{
  hp=&_h;
  wp=&_w;
}


// LINE-2: define destructor
Rectangle::~Rectangle()
{
  
}

// LINE-3 define function area()
int Rectangle::area()
{
  int a;
  a=(*hp)*(*wp);
  return a;
}

Sunday, February 2, 2020

PROGRAMMING IN JAVA WEEK 1 ASSIGNMENT SOLUTION

Here I have pasted only the answer and not the complete program so please paste the stuff carefully, I have tried to copy the whole program but it is not selecting the whole program at once.

QUESTION 1 :

//Calculate the perimeter 
perimeter=2*Math.PI*radius;

//Calculate the area
area=Math.PI*radius*radius;

if(area>0&&perimeter>0)
        {
          System.out.println(perimeter);
          System.out.print(area);
        }

else
        {
          System.out.print("please enter non zero positive number");
        }

QUESTION 2:

//Use if...else ladder to find the largest among 3 numbers and store the largest number in a variable called result.

if(x>y&&x>z)
          result=x;

else if(y>x&&y>z)
          result=y;
          
        else 
          result=z;
          
        System.out.print(result);

QUESTION 3 :

//Use for or while loop do the operation

for(int i=0; i<n*2; i=i+2)
        {
          if(i%3==0)
            sum=sum+i;
        }

System.out.print(sum);

QUESTION 4:

//Use while loop check the number is Armstrong or not.

int i=n;
int count=0; 
while(i>0)
        {
          i=i/10;
          count++;
        }
i=n;
int rem;
int sum=0;
while(i>0)
        {
          rem=i%10;
          i=i/10;
          int a=rem;
          for(int j=0; j<count-1; j++)
            rem=rem*a;
          sum=sum+rem;
        }
          
//store the output(1 or 0) in result variable.
if(sum==n)
          result=1;
else
          result=0;

System.out.print(result);

QUESTION 5:

 //Initialize maximum element as first element of the array.
   //Traverse array elements to get the current max.

int mm=arr[0];
int sum=0;
for(i=0; i<arr.length; i++)
    {
      sum=sum+arr[i];
      if(arr[i]>mm)
        mm=arr[i];
    }
   //Store the highest mark in the variable result.
result=mm;
   //Store average mark in avgMarks.
mark_avg=sum/arr.length;

System.out.println(result);
System.out.print(mark_avg);

Sunday, January 26, 2020

SIX WAYS TO MAKE PEOPLE LIKE YOU

We are often curious of how will  people react after meeting us for first time when we move to a new place, joined a new job, etc. Here I am listing six ways to as per my knowledge which you can apply in your life to make people like you especially if you are meeting them first time.


1. BECOME GENUINELY INTERESTED IN OTHER PEOPLE

       This is very basic thing to do to make the conversation with the other person workout. We know that many times we are so obsessed in our thoughts that we do not actually pay attention to the person to whom we are talking with or we just don't like the topic on which the other person is talking about, in both the cases we are likely to fail in making that person to like us.

   

     So, if you really want to make the thing work out than get interested in what other person is talking or what you can do is find a certain topic which interests you both .


2. Smile

   A smile can be understood by every person living on this planet. A smile on your face can transfer good vibes to other person.This expression can communicate the happiness and joyfulness to other person. And this thing also doesn't require much effort all you have to do is stretch you  lips wide and show your teeth. I am not promoting fake smiling but trying to tell to show how happy you feel after meeting that person , it really worked for me many times. Whether  you are anchoring on stage , public speaking , making a you tube video, talking to your colleagues a smile on your face can make a huge positive impact on people to whom you are communicating.



    And you know what is amazing thing about smiling that when we smile the other person also smiles(exceptions are always there, but let's not talk about that). So, smile.

  

3. SPELL CORRECT NAME OF THAT PERSON   

   Remember that a person's name is to that person the sweetest and most important sound in any language. If you don't know how to pronounce someones name just ask him/her how to pronounce his/her name and next time pronounce it correctly.


4. BE A GOOD LISTENER

    Always let the other person do a lot of talking, encourage them to speak about themselves. Patiently listening to that person will automatically make you a good conversationalist, cause many people want to talk about themselves and satisfy there ego by telling you what they did. And always remember that be hearty in your approbation and lavish in your praise to be a good listener, i.e show a cheerful approval of what that person is telling and always make a rich praise it.




    So if you aspire to be a good conversationalist, be an attentive listener. To be interesting, be interested. Ask question that other person enjoy answering. Encourage them to talk about themselves and there accomplishments.

    Remember that the people you are talking to are hundred times more interested in themselves and their wants and problems than they are in you and your problems. A person's toothache means more to that person than a famine in china which kills a million people. A boil in one's neck interests one more than forty earthquakes in Africa. Think of that the next time you start a conversation.


5. TALK IN TERMS OF OTHER PERSONS INTEREST

   Everyone who was ever a guest of Theodore Roosevelt was astonished at the range and diversity of his knowledge. Whether his visitor was a cowboy or a Rough Rider, a New York politician or a diplomat. Roosevelt knew what to say. And how was it done? The answer was simple. Whenever Roosevelt expected a visitor, he sat up late a night before, reading up on the subject in which he knew his guest was particularly interested.

   For Roosevelt he knew, as all leaders know, that a royal road to a person's heart is to talk about things that he or she interests most.    

   For example if you visited your relative and you meet a teenage boy who is interested in cricket then talking about current matches going on, who is best player, etc. will excite that boy and will eventually end up you having a good conversation with him.



6. MAKE THE OTHER PERSON FEEL IMPORTANT

    Philosophers have been speculating on the rules of human relationships for thousands of years, and out of all that speculation, there has evolved only one important precept. It is not new. It is as old as history. Zoroaster taught it to his followers in Persia 2500 years ago. Confucius preached it in China 24 centuries ago. Lao-tse, the founder of  Taoism taught it to his disciples in the valley of the Han. Buddha preached it on the bank of the holy Ganges five hundred years before Christ. The sacred book of Hinduism taught it among the stony hills of Judea nineteen centuries ago. Jesus summed it up in one thought - probably the most important rule in the world: "Do unto others as you would have others to unto you".

   Whenever you want somebody to like you always tell them something good about them. For example if your friend has a collection of stones and for him is the most important thing, then praising his collection will eventually make him happy as somebody has praised the thing which is most important to him. You might feel so what is my profit in that conversation?

    What you got is that priceless expression on his face when you praised his collection. And the thing that he will be happy rest of his day, you made his day better by radiating happiness.

   Making feel important  to someone is very easy and simple all you have to do is praise the thing that you think they cared the most or tell them something good  about themselves.