Skip to main content

Blocks

Skip Navigation

Navigation

  • Home

    • Site pages

      • My courses

      • Tags

      • Forumإعلانات الموقع

    • My courses

    • Courses

      • الكليات

        • ملحقة الطب

        • MIT كلية الرياضيات و الإعلام الآلي و الاتصالات ال...

          • قسم الرياضيات

          • قسم الاعلام الالي

            • السداسيات الفردية

              • Licence

              • Ingénieur d'état

                • Ingénieur1-S1

                  • الدروس

                  • اعمال موجهة وتطبيقة

                  • BW

                  • UM-70353

                  • UF-68898

                  • Unix-1

                  • UF-68987

                  • UF-68936

                  • ASD1

                    • Announcements and Chat

                    • Contact Information

                    • MindMap

                    • Course Description

                    • Bibliography

                    • Online C Compiler

                    • Prerequisite Quiz

                    • Chapter I: Introduction

                    • Chapter II: Simple Sequential Algorithm

                    • Chapter III: Conditional Structures

                      • PageLessons

                      • PageC Summary Sheet

                      • PageTutorial 03

                      • PageTutorial 03: Solutions

                      • PagePractical 03

                      • QuizQuiz 02

                      • PageQuiz 02: Solutions

                      • AssignmentHomework 01

                      • PageHomework 01: Solutions

                      • AssignmentHomework 02

                      • PageHomework 02: Solutions

                    • Chapter IV: Loop Structures

                    • Midterm Exam 01

                    • Chapter V: Arrays and Strings

                    • Chapter VI: Custom Data Types

                    • Chapter VII: Modularity

                    • Final Exam

                • Ingénieur2-S3

                • Ingénieur3-S5

              • Master

            • السداسيات الزوجية

          • قسم الاتصالات السلكية واللاسلكية

        • كلية علوم الطبيعة والحياة

        • كلية الحقوق والعلوم السياسية

        • كلية الآداب واللغات والفنون

        • كلية التكنولوجيا

        • كلية العلوم اﻹقتصادية ، والتسيير والعلوم التجارية

        • كلية العلوم الاجتماعية والإنسانية

        • منصة تقييم الدروس عن بعد2025/2024

        • دليل الاستاذ لاستخدام أرضية موودل

        • ESUF-L1- A&B

      • المرافقة البيداغوجية للأساتذة

      • التكوين في الدكتوراه

      • المدرسة العليا للاساتذة

logo
Forgotten your username or password?
usmt
  • 📅 Moodle par année
    • Consultez les cours de l'année académique 2025/2026
    • Consultez les cours de l'année académique 2024/2025
    • Consultez les cours de l'année académique 2023/2024
    • CILT

Algorithms and Data Structures 1
Homework 02

Opened: Wednesday, 23 October 2024, 10:00 AM
Due: Thursday, 31 October 2024, 11:59 PM

Put your answers in a file called StudentNumber_StudentName_ASD1_Homework02.txt. For example, if your student number is 242438187709 and your name is Mohammed Ali, your file name should be 242438187709_MohammedAli_ASD1_Homework01.txt.

Question 01

Consider the following C program.

    #include <stdio.h>
    
    void main() 
    {
        int num;
        
        printf("Enter an integer: ");
        scanf("%d", &num);
        printf("You have entered %d.\n", num);
    }
  1. What does the program do?

  2. Run the program. When prompted, give the program, the input 4 and hit enter. Does the program behave correctly?

  3. Run again the program. When prompted, give the program, the input 4 2 (4, then space, then 2) and hit enter. What do you notice?

Question 02

Consider the following C program.

        #include <stdio.h>
        
        void main() 
        {
            int num;
            
            printf("Enter an integer: ");
            scanf("%d", &num);
            printf("You have entered %d.\n", num);
            
            printf("Enter another integer: ");
            scanf("%d", &num);
            printf("You have entered %d.\n", num);
        }
  1. What does the program do?

  2. Run the program. When prompted, give the program, the input 4 and hit enter. When prompted again, give the program the number 2. Does the program behave correctly?

  3. Run again the program. When prompted, give the program, the input 4 2 (4, then space, then 2) and hit enter. What do you notice?

Question 03

Consider the following C program.

        #include <stdio.h>
        
        void main() 
        {
            int num1, num2, num3;
            
            printf("Enter an integer: ");
            scanf("%d", &num1);
            printf("You have entered %d.\n", num1);
            
            printf("Enter another integer: ");
            scanf("%d", &num2);
            printf("You have entered %d.\n", num2);
            
            printf("Enter another integer: ");
            scanf("%d", &num3);
            printf("You have entered %d.\n", num3);
            
            printf("You have input the numbers %d, %d, and %d.\n", num1, num2, num3);
        }
  1. What does the program do?

  2. Run the program. When prompted, give the program, the input 4 and hit enter. When prompted again, give the program the number 2. When prompted again, give the program the number 1. Does the program behave correctly?

  3. Run again the program. When prompted, give the program, the input 4 2 (4, then space, then 2) and hit enter. What do you notice?

Question 04

Based on your observations before, what can you conclude about scanf()?

◄ Homework 01: Solutions
Homework 02: Solutions ►

Blocks

Back

 https://www.univ-saida.dz/  e-learning@univ-saida.dz  048931000,1304
You are currently using guest access (Log in)