Most Recent

Facebook

C Program to check if a Number Is Positive Or Negative

 Positive or Negative number:    


#include <stdio.h>
int main()
{
    int num = 23;
      
    //Conditions to check if the number is negative/positive or zero
    if (num > 0)
         printf("The number is positive");
    else if (num < 0)
        printf("The number is negative");
    else
        printf("Zero");
    
    return 0;
}            





#include <stdio.h>
int main()
{
    int num = -10;
    
    //Condition to check if num is negative/positive or zero
    if (num >= 0)
    {
        if (num == 0)
            printf("The number is 0");
        else
            printf("The number is Positive");
    }
    else
        printf("The number is Negative");
    
    return 0;
}







#include <stdio.h>
int main()
{
    int num = -4;
    
    //Condition to check if the 0, positive or negative
    
    if(num == 0)
        printf("Zero");
    else
        (num > 0) ? printf("Positive"): printf("Negative");
    
    return 0;
}    

netaji gandi Friday, September 25, 2026
GATE 2027: Important Dates, Question Paper Pattern, and Previous Year Papers (2021–2026)

GATE 2027: Important Dates, Question Paper Pattern, and Previous Year Papers (2021–2026)

Preparing for the Graduate Aptitude Test in Engineering (GATE) requires staying updated with the latest official announcements. If you are gearing up for GATE 2027, which is being organized by the Indian Institute of Technology Madras (IIT Madras), here is everything you need to know in one place.



1. GATE 2027 Question Paper Pattern

Understanding the exam structure is the first step toward a smart preparation strategy. The exam consists of objective-type questions, including Multiple Choice Questions (MCQs), Multiple Select Questions (MSQs), and Numerical Answer Type (NAT) questions.

👉 Check the detailed GATE 2027 Question Paper Pattern here

2. Year-Wise Download of Question Papers & Answer Keys (2021 to 2026)

One of the best ways to crack GATE is to solve past years' question papers. It helps you understand the difficulty level, recurring topics, and time management. You can download official question papers along with their answer keys for the last few years (2021 to 2026).

👉 Download GATE Previous Year Papers and Answer Keys

3. Important Dates for GATE 2027

Don't miss out on crucial deadlines like registration start dates, exam dates, and result declarations. Keep track of the official schedule so you stay ahead of the timeline.

👉 View the complete list of GATE 2027 Important Dates

📥 Bulk Download of GATE Question Papers (2007 to 2026)

Instead of downloading papers one year at a time, IIT Madras has made a Bulk Download archive available on the official portal. This allows aspirants to access nearly two decades of past GATE question papers (from 2007 to 2026) in complete subject-wise/year-wise collections.

  • Why download the bulk archive?

    • Comprehensive Practice: Access 20 years of real GATE questions to track long-term trends, core concepts, and repeating question types.

    • Offline Preparation: Save entire paper sets at once as PDFs for self-study and timed mock sessions without needing continuous internet access.

    • Official Keys Included: Most sets include official answer keys for accurate self-evaluation.

👉 Access the Bulk Download Archive (2007–2026) Here

netaji gandi
Week 09 Programming Assignments 1-5

 W09 Programming Assignments 1

Due date on 2026-09-24, 23:59 IST

Your last recorded submission was on 2026-09-14, 13:43 IST.

Q.

Write suitable code to develop a 2D Flip-Flop Array with dimension 5 × 5, which replaces all input elements with values 0 by 1 and 1 by 0. An example is shown below:

INPUT:
00001
00001
00001
00001
00001

OUTPUT:
11110
11110
11110
11110
11110

Note the following points carefully:
  • Here, the input must contain only 0 and 1.
  • The input and output array size must be of dimension 5 × 5.
  • Flip-Flop: If 0 then 1 and vice-versa.

Java
import java.util.Scanner;

public class W09_P1 {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);

        // Declare the 5X5 2D array to store the input
        char original[][] = new char[5][5];

        // Input 2D Array using Scanner Class and check data validity
        for (int line = 0; line < 5; line++) {
            String input = sc.nextLine();
            char seq[] = input.toCharArray();
            if (seq.length == 5) {
                for (int i = 0; i < 5; i++) {
                    if (seq[i] == '0' || seq[i] == '1') {
                        original[line][i] = seq[i];
                        if (line == 4 && i == 4)
                            flipflop(original);
                    } else {
                        System.out.print("Only 0 and 1 supported.");
                        break;
                    }
                }
            } else {
                System.out.print("Invalid length");
                break;
            }
        }
    } // The main() ends here

    static void flipflop(char[][] flip) {
        // Flip-Flop Operation
        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < 5; j++) {
                if (flip[i][j] == '1')
                    flip[i][j] = '0';
                else
                    flip[i][j] = '1';
            }
        }

        // Output the 2D FlipFlopped Array without a trailing newline after the 5th line
        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < 5; j++) {
                System.out.print(flip[i][j]);
            }
            if (i < 4) {
                System.out.println();
            }
        }
    }
} // The main class ends here




You may submit any number of times before the due date. The final submission will be considered for grading.

This assignment has Public Test cases. Please click on "Compile & Run" button to see the status of Public test cases. Assignment will be evaluated only after submitting using Submit button below. If you only save as or compile and run the Program, your assignment will not be graded and you will not see your score after the deadline.

Evaluation Results

CompilationSuccessful|Public Test Cases: 1/1 Passed

Note: These tests may not be considered while scoring.

Public Test Cases

Test Case
Input
Expected Output
Output
Status
Test Case 1

00001 00001 00001 00001 00001

11110\n
11110\n
11110\n
11110\n
11110
11110\n
11110\n
11110\n
11110\n
11110\n
Presentation Error


W09 Programming Assignments 2

Due date on 2026-09-24, 23:59 IST

Your last recorded submission was on 2026-09-14, 13:44 IST.

Q.

Complete the code to develop a BASIC CALCULATOR that can perform operations like Addition, Subtraction, Multiplication and Division.

Note the following points carefully:
  • Use only double datatype to store calculated numeric values.
  • Assume input to be of integer datatype.
  • The output should be rounded using Math.round() method.
  • Take care of the spaces during formatting output (e.g., single space each before and after =).
  • The calculator should be able to perform required operations on a minimum of two operands as shown in the below example:
Input:
5+6

Output:
5+6 = 11
Java
import java.util.Scanner;

public class W09_P2 {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String input = sc.nextLine(); // Read as string, e.g., 5+6

        // Declare and initialize the required variable(s)
        int i = 0;
        int j = 0;
        double output = 0;
        // Split the input string into character array
        char seq[] = input.toCharArray();
        /*
        Use some method to separate the two operands
        and then perform the required operation.
        */
        for (int a = 0; a < seq.length; a++) {
            if (seq[a] == '+') {
                i = Integer.parseInt(input.substring(0, a));
                j = Integer.parseInt(input.substring(a + 1, seq.length));
                output = (double) i + j;
            } else if (seq[a] == '-') {
                i = Integer.parseInt(input.substring(0, a));
                j = Integer.parseInt(input.substring(a + 1, seq.length));
                output = (double) i - j;
            } else if (seq[a] == '/') {
                i = Integer.parseInt(input.substring(0, a));
                j = Integer.parseInt(input.substring(a + 1, seq.length));
                output = (double) i / j;
            } else if (seq[a] == '*') {
                i = Integer.parseInt(input.substring(0, a));
                j = Integer.parseInt(input.substring(a + 1, seq.length));
                output = (double) i * j;
            }
        }
        System.out.print(input + " = " + Math.round(output));
    } // The main() method ends here
} // The main class ends here
You may submit any number of times before the due date. The final submission will be considered for grading.

This assignment has Public Test cases. Please click on "Compile & Run" button to see the status of Public test cases. Assignment will be evaluated only after submitting using Submit button below. If you only save as or compile and run the Program, your assignment will not be graded and you will not see your score after the deadline.

Evaluation Results

CompilationSuccessful|Public Test Cases: 1/1 Passed

Note: These tests may not be considered while scoring.

Public Test Cases

Test Case
Input
Expected Output
Output
Status
Test Case 1

5+6

5+6 = 11
5+6 = 11
-


W09 Programming Assignments 3

Due date on 2026-09-24, 23:59 IST

Your last recorded submission was on 2026-09-14, 13:46 IST.

Q.

Write a Java program that utilizes multithreading to calculate and print the squares of numbers from a specified begin to a specified end.
The main method is already created.
You need to design a SquareThread class that has two members,
  • int begin;
  • int end;
Each thread should sequentially print the squares of numbers from begin to end (both inclusive).
The same code will be used to create another thread that prints the sqaure of numbers from end to begin in reverse order.
(if begin is greater than end, print the square of each number in reverse order first)
The main method will first call SquareThread with begin and end and then in reverse order.
The class you create should be able to handle such case and print as required in the correct order.
HINT: use the keyword `synchronized` in the run method.
Java
import java.util.Scanner;

class SquareThread extends Thread {
    private int begin;
    private int end;

    public SquareThread(int begin, int end) {
        this.begin = begin;
        this.end = end;
    }

    public synchronized void run() {
        if (begin > end) {
            for (int i = begin; i >= end; i--) {
                System.out.println(i * i);
            }
        } else {
            for (int i = begin; i <= end; i++) {
                System.out.println(i * i);
            }
        }
    }
}

public class W09_P3 {
    public static void main(String args[]) throws InterruptedException {
        Scanner scanner = new Scanner(System.in);
        int begin = scanner.nextInt();
        int end = scanner.nextInt();
        scanner.close();
        
        SquareThread thread1 = new SquareThread(begin, end);
        SquareThread thread2 = new SquareThread(end, begin);
        thread1.start();
        thread1.join();
        thread2.start();
    }
}
You may submit any number of times before the due date. The final submission will be considered for grading.

This assignment has Public Test cases. Please click on "Compile & Run" button to see the status of Public test cases. Assignment will be evaluated only after submitting using Submit button below. If you only save as or compile and run the Program, your assignment will not be graded and you will not see your score after the deadline.

Evaluation Results

CompilationSuccessful|Public Test Cases: 2/2 Passed

Note: These tests may not be considered while scoring.

Public Test Cases

Test Case
Input
Expected Output
Output
Status
Test Case 1

1 5

1\n
4\n
9\n
16\n
25\n
25\n
16\n
9\n
4\n
1
1\n
4\n
9\n
16\n
25\n
25\n
16\n
9\n
4\n
1\n
Presentation Error
Test Case 2

9 6

81\n
64\n
49\n
36\n
36\n
49\n
64\n
81
81\n
64\n
49\n
36\n
36\n
49\n
64\n
81\n
Presentation Error


W09 Programming Assignments 4

Due date on 2026-09-24, 23:59 IST

Your last recorded submission was on 2026-09-14, 13:47 IST.

Q.

Complete the code segment to catch the exception in the following, if any.
On the occurrence of such an exception, your program should print
"Please enter valid data".
If there is no such exception, it will print the square of the number entered.
Java
import java.io.*;

class W09_P4 {
    public static void main(String args[]) {
        try {
            java.util.Scanner r = new java.util.Scanner(System.in);
            String number = r.nextLine();
            int x = Integer.parseInt(number);
            System.out.print(x * x);
        } catch (Exception e) {
            System.out.print("Please enter valid data");
        }
    }
}
You may submit any number of times before the due date. The final submission will be considered for grading.

This assignment has Public Test cases. Please click on "Compile & Run" button to see the status of Public test cases. Assignment will be evaluated only after submitting using Submit button below. If you only save as or compile and run the Program, your assignment will not be graded and you will not see your score after the deadline.

Evaluation Results

CompilationSuccessful|Public Test Cases: 2/2 Passed

Note: These tests may not be considered while scoring.

Public Test Cases

Test Case
Input
Expected Output
Output
Status
Test Case 1

2

4
4
-
Test Case 2

p

Please enter valid data
Please enter valid data
-


W09 Programming Assignments 5

Due date on 2026-09-24, 23:59 IST

Your last recorded submission was on 2026-09-14, 13:48 IST.

Q.

Define a class Point with members
  • private double x;
  • private double y;
and methods:
  • public Point(double x, double y){} // Constructor to create a new point
  • public double distance(Point p2){} // Function to return the distance of this Point from another Point
Java
import java.util.Scanner;

public class W09_P5 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double x1 = sc.nextDouble();
        double y1 = sc.nextDouble();
        double x2 = sc.nextDouble();
        double y2 = sc.nextDouble();
        Point p1 = new Point(x1, y1);
        Point p2 = new Point(x2, y2);
        System.out.print(p1.distance(p2));
    }
}

class Point {
    private double x;
    private double y;

    public Point(double x, double y) {
        this.x = x;
        this.y = y;
    }

    public double distance(Point p2) {
        double d;
        d = Math.sqrt((p2.x - x) * (p2.x - x) + (p2.y - y) * (p2.y - y));
        return d;
    }
}
You may submit any number of times before the due date. The final submission will be considered for grading.

This assignment has Public Test cases. Please click on "Compile & Run" button to see the status of Public test cases. Assignment will be evaluated only after submitting using Submit button below. If you only save as or compile and run the Program, your assignment will not be graded and you will not see your score after the deadline.

Evaluation Results

CompilationSuccessful|Public Test Cases: 2/2 Passed

Note: These tests may not be considered while scoring.

Public Test Cases

Test Case
Input
Expected Output
Output
Status
Test Case 1

0 0 1 1

1.4142135623730951
1.4142135623730951
-
Test Case 2

0 0 0 5

5.0
5.0
-


netaji gandi Monday, September 21, 2026

C Program to check if a Number Is Positive Or Negative

  Positive or Negative number:      #include <stdio.h> int main () { int num = 23 ; //Conditions to check if th...