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;
}