CS508 Assignment No. 01
 Solution and Discussion


  • Cyberian's Gold

    Assignment No. 01 Semester Fall 2019
    CS508- Modern Programming Languages Total Marks: 20

    Due Date: Tuesday, 12 November 2019.

    Instructions
    Please read the following instructions carefully before solving & submitting assignment:
    It should be clear that your assignment will not get any credit if:
    • The assignment is submitted after due date.
    • The submitted assignment does not open or file is corrupt.
    • The assignment is completely or partially copied from (other student or ditto copied from handouts or internet).
    • Student ID is not mentioned in the assignment File or name of file is other than student ID.
    • The assignment is not submitted in .doc or .docx format.
    Uploading instructions
    Your submission must include:
    • Assignment should be in .doc or .docx format.
    • Save your assignment with your ID (e.g. bx180200786.doc).
    Assignment submission through email is NOT acceptable
    Objective
    The objective of this assignment is to learn how we can evaluate different programming languages based on syntax.
    Note:
    Your answer must follow the below given specifications.
    • Font style: “Times New Roman”
    • Font color: “Black”
    • Font size: “12”
    • Bold for heading only.
    • Font in Italic is not allowed at all.
    • Your answer should be precise and to the point, avoid irrelevant detail.

    Lectures Covered: This assignment covers Lecture # 01 – 07
    Deadline
    Your assignment must be uploaded/submitted at or before Tuesday, 12 November 2019.

    In this assignment we will evaluate 3 different languages on the basis of CPU time and Memory used for compilation.
    3 languages we will be using are:
    • Java
    • C#
    • C++
    We will use nested loop which will execute finite number of times. For the sake of consistency, we will be using an online compiler of each language from the same website.
    First you need to calculate the number of time both loops will run, for that we will use student id.
    From the last 4 numbers of student id, first two characters will be number of times the outer loop will execute and last two characters will be number of times the inner loop will execute.
    So, for example if student id is BC180201429 then b3700d9e-9af3-42a2-a3a5-0e283bb1c2c0-image.png

    The outer loop will execute 14 times and inner loop will execute 29 times.
    Use the following compiler https://www.jdoodle.com/.

    1. Note down the CPU Time and memory Used for all the languages and fill the following table with CPU time memory and write the code for all 3 languages also take screen shots for each language and paste it in your solution file.
      Language Code CPU Time Memory Used
      736d9677-6cb8-4ece-b665-09b46c738031-image.png

    2. You must write your student ID and language name in the code so it can be shown in the screen shot as attached below:

    3. You are required to attach screen shots for all 3 languages showing output and resources used.

    6c0ca58e-6108-4e8e-8b9d-34dbf3fb989e-image.png


  • Cyberian's Gold


  • Cyberian's

    using System;
    
    class Program
    {
    static void Main() {
    
    Console.Write("My Student is is BC160401656 \n");
    Console.Write("My Language is C#");
    
        int outerloop=1;
        int innerloop=1;
        for (int i=1;i<=29;i++){
            Console.Write("outerloop:" + outerloop++);
            if (outerloop == 30){
                Console.Write("\n----------\n");
                for (int j=1;j<=79;j++){
                    Console.Write("ïnnerloop:" + innerloop++);
                }
            }
        }
        
    }
    }
    

  • Cyberian's

    public class MyClass {
        public static void main(String args[]){
            System.out.println("My id is BS12345678");
            System.out.println("My language is Java");
            int outerloop=1;
            int innerloop=1;
            for(int i=1;i<=29;i++){
                System.out.print("outerloop:" + outerloop++);
                
                if (outerloop == 30){
                    System.out.println("\n----------\n");
                    for(int j=1;j<=79;j++){
                        System.out.print("innerloop:" + innerloop++);
                    }
                }
                
            }
        }
    }
    

  • Cyberian's Gold

    Correct Solution of C++

    #include <iostream>
    using namespace std;
    int main() {
    int outerloop=1;
    int innerloop=1;
        cout<<"My Student ID is BS12345678\n";
        cout<<"My coding Language is C++\n\n";
    for(int i=1;i<=29;i++){
        cout<<"outerloop:"<<outerloop++;
    
        if (outerloop == 30){
            cout<<"\n.......\n";
            for(int j=1;j<=79;j++){
            cout<<"innerloop:"<<innerloop++;
    
            }
        }
    }
    }
    

  • Cyberian's Gold

    Idea Solution


  • Cyberian's Gold


  • Cyberian's Gold

    @cyberian
    Please and check and any suggestion?


  • Cyberian's

    Java:

    public class MyClass {
    public static void main(String args[]) {
    
    System.out.println("My Student ID is BC160401656");
    System.out.println("My Language is JAVA");
    }
    }
    

    C#:

    using System;
    
    class Program
    {
    static void Main() {
    
    Console.Write("My Student is is BC160401656 \n");
    Console.Write("My Language is C#");
    }
    }
    

    C++:

    #include <iostream>
    
    using namespace std;
    
       int main() {
    
        cout"MY Student ID is BC160401656 \n " ;
    
        cout"Language is C++" ;
    
    }
    


    Recent Topics


|