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

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 SchoolStudent 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 outputPrinter obj = new Printer();obj.print("Hi! I am...

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++)    {   ...

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

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

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-2Question 2 :bool StrCmp(string s1, string s2) {    if (s1.length()>s2.length() || s1.length()<s2.length())    // LINE-1            return 1; ...

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