Coding Practice

Al Muslim: Privacy Policy

PRIVACY POLICY

We care about your data security and privacy. Please review our Privacy Policy: https://rakibofc.blogspot.com/p/al-muslim-privacy-policy.html. By using our App, you agree to be bound by our Privacy Policy, which is incorporated into these Terms of Use.

Difference between a regular string and a raw string in Python

In Python, a regular string is a string that is interpreted according to the rules of the Python interpreter. This means that special characters, such as newline (\n) or tab (\t), are processed and converted into their appropriate representation. For example, the string "Hello\nWorld" would be interpreted as two separate lines, with "Hello" on the first line and "World" on the second line.

A raw string, on the other hand, is a string that is taken exactly as it is, without any special processing. Raw strings are denoted by prefixing the string with the letter r. For example, the string r"Hello\nWorld" would be taken literally, without the \n being interpreted as a newline character.

The main difference between a regular string and a raw string is that a regular string allows for special characters and escape sequences to be processed, while a raw string does not. Raw strings are often used when dealing with file paths or regular expressions, where backslashes are a common part of the syntax. By using a raw string, you can ensure that the backslashes in the string are taken literally, without being interpreted as escape characters.

Here's an example in Python that demonstrates the difference between a regular string and a raw string:

Source Code
# Regular string
string1 = "Hello\nWorld"
print(string1)

# Raw string
string2 = r"Hello\nWorld"
print(string2)
Sample Output
Hello
World
Hello\nWorld

As you can see, the regular string string1 is interpreted by the Python interpreter and the newline character (\n) is processed, resulting in "Hello" being printed on one line and "World" being printed on the next line.

In contrast, the raw string string2 is taken exactly as it is written, and the newline character is not processed. The output of string2 is the literal string "Hello\nWorld".

আল মুসলিম

পরিচিতি (এই পেজের তথ্যগুলো আপডেট করা হবে) English

"আল মুসলিম" অ্যাপটি আপনাকে একজন প্রাক্টিসিং মুসলিম হতে সাহায্য করবে। যা সম্পূর্ণ বিনামূল্যে এবং বিজ্ঞাপনমুক্ত একটি অ্যাপ। এই অ্যাপটি অবস্থান-ভিত্তিক নামাজের সময়, নামাজের এলার্ট, নামাজ মোড, দু'আ রিমাইন্ডার, কুরআনের অডিও তেলাওয়াত (20+ অফলাইন সূরা), দুআ এবং যিকর সহ বিভিন্ন বৈশিষ্ট্য সরবরাহ করে। এটি ইসলামিক আর্টিকেল এবং ইসলামিক তারিখগুলিও প্রদান করে। এই অ্যাপটি বাংলা ও ইংরেজি উভয় ভাষায় ব্যবহার করা যাবে।

দ্রষ্টব্য: অ্যাপটির নাম পরিবর্তন করে "ইসলামিক হতে অনুপ্রাণিত করুন" থেকে "আল মুসলিম" করা হয়েছে।

গোপনীয়তা নীতি

আপনার গোপনীয়তা রক্ষা আমাদের জন্য খুবই গুরুত্বপূর্ণ। আমরা যখন কোন তথ্য সংগ্রহ করি, কেন আমরা এটি সংগ্রহ করি এবং আমরা এটির সাথে কী করি তা জানতে আমরা আপনাকে আমাদের গোপনীয়তা নীতি (Privacy Policy) সম্পর্কে অবহিত করছি। এই গোপনীয়তা ঘোষণা হচ্ছে "আল মুসলিম" অ্যাপের এর জন্য; এই সাইটটিকে "rakibofc.blogspot.com" উল্লেখ করা হয়েছে। এই উভয় পরিষেবা রকিবুল ইসলাম (RakibOFC) দ্বারা রক্ষণাবেক্ষণ ও পরিচালিত।

"আল মুসলিম" অ্যাপ্লিকেশন আপনার নাম, ইমেল ঠিকানা, যোগাযোগ বা অন্যান্য অনুরূপ তথ্য সংগ্রহ করে না।

1. যেসব তথ্য আমরা সংগ্রহ করি

1.1 সাধারণ তথ্য এবং অনুমতি/পারমিশন:

  • আমাদের ব্যবহারকারীদের সঠিক নামাজের সময়, দু'য়ার সময় এবং নামাজ মোডের সময়সূচী প্রদানের জন্য লোকেশন পারমিশন প্রয়োজন। (ব্যবহারকারীর অবস্থান/লোকেশন ব্যবহারকারীর ডিভাইসে ডেটা হিসাবে সংরক্ষণ করা হয়। আমরা ব্যবহারকারীর অবস্থান অন্যদের সাথে শেয়ার করি না, এমনকি আমাদের সার্ভারে সংরক্ষিত হয় না৷)
  • ব্যবহারকারী যখন নামাজ মোড চালু করবেন তখন "Do Not Disturb" পারমিশন প্রয়োজন হবে। এই পারমিশনের মাধ্যমে ডিভাইসকে সাইলেন্ট মোড -এ নেওয়া হয়।
  • সঠিক সময়ে নোটিফিকেশন পাঠানোর জন্য ব্যাটারী অপটিমাইজেশন (Battery Optimization) ডিজেবল করা জরুরী। এই পারমিশন টি ম্যানুয়ালি দিতে হবে। এটি শুধুমাত্র কিছু ডিভাইস প্রস্তুতকারকের উপর নির্ভর করে।

1.2 পারমিশন সেটিংস পরিবর্তন করতে:

আপনি যদি লোকেশনের জন্য আপনার অ্যাপের পারমিশন পরিবর্তন করতে চান -

  1. আল মুসলিম অ্যাপ দীর্ঘক্ষণ প্রেস করুন
  2. অ্যাপ্লিকেশন ইনফো তে ক্লিক করুন
  3. পারমিশনে ক্লিক করুন
  4. অনুমতি/অগ্রাহ্য করুন

ডু নট ডিসটার্ব (Do not disturb) পার্মিশনের জন্য -

  1. আপনার ডিভাইসের সেটিংসে নেভিগেট করুন
  2. অ্যাপের জন্য ডু নট ডিসটার্ব পার্মিশন (Do not disturb permission) খুঁজুন
  3. আল মুসলিম অ্যাপ খুঁজুন
  4. এনাবল/ডিজেবল করুন

ব্যাটারি অপ্টিমাইজেশন পার্মিশনের জন্য -

  1. আপনার ডিভাইসের সেটিংসে নেভিগেট করুন
  2. Optimise battery usage খুঁজুন (এটি বিভিন্ন ডিভাইসের জন্য আলাদা হবে। লিঙ্কে যান এবং আপনার ডিভাইসের জন্য ধাপ অনুসরণ করুন - dontkillmyapp.com)
  3. আল মুসলিম অ্যাপ খুঁজুন
  4. এনাবল/ডিজেবল করুন

2. আমরা যেভাবে আপনার তথ্য ব্যবহার করি

আমরা যে তথ্য সংগ্রহ করি তা আমাদের কাছে সম্পূর্ণ নিরাপদ কারণ আমাদের ব্যবহারকারীদের নিরাপত্তা আমাদের সর্বোচ্চ অগ্রাধিকার। নামাজের সময়, দু'আর সময় এবং নামাজ মোডের সময়সূচী গণনা করতে আমরা ব্যবহারকারীর অবস্থান/লোকেশন (অক্ষাংশ এবং দ্রাঘিমাংশ) সংগ্রহ করি৷ এটি ব্যবহারকারীর ডিভাইসে ডেটা হিসাবে সংরক্ষণ করা হয়। আমরা ব্যবহারকারীর অবস্থান অন্যদের সাথে শেয়ার করি না, এমনকি আমাদের সার্ভারে সংরক্ষিত হয় না৷

আমরা লোকেশন ব্যতীত অন্য কোন তথ্য ব্যবহারকারীর কাছ থেকে সংগ্রহ করি না৷

3. গ্রাহক সহায়তা

আমাদের যোগাযোগের ইমেইল হল rakibdev2@gmail.com। যেকোনো সময়ে, আমাদের ব্যবহারকারীরা প্রযুক্তিগত সমস্যা বা নতুন ফীচারের জন্য আমাদের কন্টাক্ট ইমেলের মাধ্যমে আমাদের সাথে যোগাযোগ করতে পারেন।

4. যেসব তথ্য আমরা শেয়ার করি

আমরা ব্যবহারকারীর কোন তথ্য অন্যদের সাথে শেয়ার করি না, এমনকি আমাদের সার্ভারে সংরক্ষিত হয় না৷

5. কিভাবে আমাদের সাথে যোগাযোগ করবেন

গোপনীয়তা নীতি বা সার্ভিস সম্পর্কে আপনার যদি কোনো জিজ্ঞাসা থাকে, আপনি rakibdev2@gmail.com-এ একটি ইমেল পাঠিয়ে আমাদের সাথে যোগাযোগ করতে পারেন। "আল মুসলিম" মাঝে মাঝে গোপনীয়তা নীতি আপডেট করতে পারে, তাই এটি নিয়মিত চেক করার পরামর্শ দেওয়া হচ্ছে। এটি পরিবর্তন করার সময় আপনি বিজ্ঞপ্তি পেতে পারেন আবার নাও পেতে পারেন। গোপনীয়তা নীতিতে কোন পরিবর্তনের পরে পরিষেবাটি ব্যবহার করা পরিবর্তনের সম্মতি হিসাবে বিবেচিত হবে।

শর্তাবলী

অনুগ্রহ করে "আল মুসলিম" অ্যাপটি ব্যবহার করার আগে এই নিয়ম ও শর্তাবলী ("শর্তাবলী") মনোযোগ সহকারে পড়ুন। এই শর্তাবলী সমস্ত ব্যবহারকারী এবং অন্য যারা পরিষেবা অ্যাক্সেস করে বা ব্যবহার করে তাদের জন্য প্রযোজ্য৷ পরিষেবাগুলি অ্যাক্সেস বা ব্যবহার করে আপনি এই শর্তাবলী দ্বারা আবদ্ধ হতে সম্মত হন৷
আপনি যদি শর্তাবলীতে সম্মত না হন, তাহলে আপনাকে অবিলম্বে পরিষেবাটি ব্যবহার বন্ধ করার পরামর্শ দেওয়া হচ্ছে।

4. কপিরাইটস

4.4 আমরা ইসলাম প্রচারের জন্য, মানুষকে ইসলামের বাণী পৌঁছে দেওয়ার জন্য বিভিন্ন তথ্য/কনটেন্ট বিভিন্ন জায়গা থেকে সংগ্রহ করেছি। সংগ্রীত কনটেন্ট গুলো কে রেফারেন্সের অন্তর্ভুক্ত করে হয়েছে। এগুলো সব কপিরাইট ফায়ার ইউজের অন্তর্ভুক্ত।

প্রায়শ জিজ্ঞাসিত প্রশ্ন (এফ.এ.কিউ.)

কিভাবে আল মুসলিম অ্যাপ ব্যবহার করব?

Al Muslim

About (Information on this page will be updated) বাংলা

"Al Muslim" app will help you to become a practicing Muslim. Which is completely free and does not display ads. This app offers a range of features, including location-based prayer times, prayer alerts, prayer mode, dua reminder, audio recitations of the Qur'an (20+ Offline Surah), Dua, and Dhikr. It also provides Islamic articles and Islamic dates. This app can be used in both Bangla and English language.

Note: The name of the app has been changed "Inspire to be Islamic" to "Al Muslim".

Features

  • Prayer Mode
  • Prayer Time
  • Prayer Time Notification Panel
  • Prayer Alert
  • Dua Reminder
  • 20+ Surah with Audio
  • Dua and Dhikr
  • Islamic Articles
  • Al Quran (Coming soon)
  • Salah Guide (Coming soon)
  • Online Quran and Hadith
  • Islamic Date

Prayer Mode

If you turn on the Prayer mode. The device will go to silent mode when prayer time starts and go back to the previous mode when the time will end. You can manually enable and disable the specific Prayer mode. You can also change the particular prayer start and end times.

Prayer Time

This app provides Six-time prayer times. Such as Fajr, Dhuhr, Asr, Maghrib, Isha, and Tahajjud. It also provides Sunrise and Sunset time.

Prayer Time Notification Panel

When you turn on Prayer Time Panel, it will help to show prayer time on the notification panel. It shows five prayer times i.e. Fajr, Dhuhr, Asr, Maghrib, and Isha. There are two types of notification panel types; Layout and expandable.

Prayer Alert

Prayer Alert will help you to send notifications when a specific prayer time will start. It also provides hadith of a specific prayer time which is the benefit of that prayer. It can motivate you to pray regularly. All prayer alert has four different types of notification tones.

Dua Reminder

Dua Reminder will help you to send notifications when a specific dua time will start. It will send notifications for different duas at different times of the day. All dua reminder has four different types of notification tones.

20+ Surah with Audio

“Al Muslim” app provide 20+ surah with audio. There are three types of features for every surah; Arabic, Pronunciation (Bangla & English), and Translation (Bangla & English). It also provides an audio player to hear every surah. The audio player has all the functions that you can easily control.

Dua and Dhikr

Dua and Dhikr provide three types of content. Those are dua in Arabic, Pronunciation (Bangla & English), Translation (Bangla & English), and Importance of dua with reference names and links.

Online Quran and Hadith

"Al Muslim" app provides different types of online Quran and Hadith. Each Quran offers different types of features. Such as Digital copies of the Quran in various translations, Audio recitations, Search and navigation tools, Commentaries, and explanations, etc.

User Controls

  • Hijri Date Adjustment
  • App Theme (Dark Mode & Light Mode)
  • Multiple App Language (Bangla and English)
  • Customizable Alert Sound
  • Six Different Arabic Font
  • Customizable Arabic and Translation Font Size

All controls of the app are controlled by the user!

Note: Sometimes the does not send notifications due to battery optimization. In this situation, please disable battery optimization for this app from app settings or Phone Settings. And stay with Al Muslim!

Privacy Policy

Protecting your privacy is very important to us. When we collect information, why we collect it and what we do with it, we inform you about our Privacy Policy. This privacy statement applies to the "Al Muslim" app; This site is referred to as "rakibofc.blogspot.com". Both these services are maintained and operated by Rakibul Islam (RakibOFC).

Al Muslim application does not collect your name, email address, contact, or other similar information.

1. Information we collect

1.1 General information and permissions:

  • Location permission is required for providing our users with accurate Prayer Times, Dua Times, and Prayer Mode Schedule (The user's location is stored as data on the user's device. We do not share the user's location with others, or even store it on our servers)
  • "Do Not Disturb" permission will be required when the user turns on the prayer mode. This permission puts the device into silent mode.
  • It is important to disable Battery Optimization to send notifications at the right time. This permission has to be given manually. It is only depending on some device manufacturer.

1.2 To changing permission settings:

If you want to change your app permissions for Location -

  1. Long press on on Al Muslim app
  2. Click on the App Info option
  3. Click on the Permissions
  4. Allow/Disallow it

For Do not disturb permission -

  1. Navigate to Settings of your Device
  2. Find Do not disturb permission for app
  3. Find Al Muslim app
  4. Enable/Disable it

For Battery Optimization permission -

  1. Navigate to Settings of your Device
  2. Find Optimise battery usage (It should different for different devices. Go to the link and follow the step for your device - dontkillmyapp.com)
  3. Find Al Muslim app
  4. Enable/Disable it

2. How we use your information

The information that we collect is completely safe with us as our users safety is our utmost priority. We collect user location (latitude and longitude) to calculate prayer times, dua times and prayer mode schedules. It is stored as data on the user's device. We do not share the user's location with others, or even store it on our servers.

We do not collect any information from the user other than the location.

3. Customer support

Our contact email is rakibdev2@gmail.com. At any point in time, our users can contact us via our support email address for technical issues or suggestions for new features.

4. Information we share

We do not share any user information with others or even store it on our servers

5. How to contact us

If you have any inquiries regarding the privacy policy or the service, you can reach out to us by sending an email to rakibdev2@gmail.com. "Al Muslim" may occasionally update the privacy policy, so it is advisable to check it regularly. When it changes you may or may not receive notifications. Using the service after any modifications to the privacy policy will be considered as consent to the changes.

Term and Conditions

Please read these terms and conditions ("Terms") carefully before using the "Al Muslim" app. These Terms apply to all users and others who access or use the Service By accessing or using the Services, you agree to be bound by these Terms.
IF YOU DO NOT AGREE TO THE TERMS, YOU ARE RECOMMENDED TO DISCONTINUE USING THE SERVICE IMMEDIATELY.

1. GENERAL TERMS

  • You will not use the app for any illegal or unauthorized purpose.
  • Your use of the app will not violate any applicable law or regulation.
  • Do not use our app for false advertising.

All information on "Al Muslim" is verified by experts anteriorly. If you discover any unworthy material or links leading to unworthy materials, kindly contact us at rakibdev2@gmail.com.

2. PRIVACY POLICY

We care about your data security and privacy. Please review our Privacy Policy: https://rakibofc.blogspot.com/2022/12/inspire-to-be-islamic-en.html#privacy-policy. By using our App, you agree to be bound by our Privacy Policy, which is incorporated into these Terms of Use.

3. THIRD PARTY WEBSITES AND CONTENT

3.1 The "Al Muslim" app might include links to websites that are controlled and maintained by other organizations. These links to third-party websites are not officially endorsed by the organization and by using the service, you accept and agree that the organization is not responsible for any content or links found on these websites.

3.2 Anyone can use the links to third-party websites provided in the "Al Muslim" app, but there are conditions that must be followed:

  1. The user should not assume that the organization is endorsing the services or products of another party unless the endorsement is in writing.
  2. The user should not intend to misrepresent their affiliation with the website.
  3. The linking third-party website should not contain offensive or controversial content, or content that infringes any intellectual property rights or other rights of a third party.

3.3 If the link to the website violates these terms, the user will be responsible for covering any loss or damage caused to the website as a result of the linking.

4. COPYRIGHTS

4.1 "Al Muslim" values the rights of others and expects users to do the same.

4.2 All copyrights, trademarks, and intellectual property rights related to "Al Muslim" and its content belong to the organization or have been legally licensed to it.

4.3 By accessing the services, users agree to use the content provided by the organization for personal, non-commercial purposes only. Users are not allowed to reproduce, transmit, download, store, copy, sell, or distribute any of the content without obtaining prior written consent from the copyright holder.

4.4 We have collected various information/content from various places to spread the message of Islam to people. All contents are incorporated by reference. All of them are dominated by copyright fire use.

If the purpose is to spread Islam, to inspire people; Then you can share the contents of "Al Muslim" as you wish.

5. CHANGES TO TERMS

"Al Muslim" reserves the right to make changes to these terms and conditions periodically. It may also provide additional forms of notifications when making changes. By continuing to use the service after any modification to these terms, it will be considered as acceptance of those changes.

Frequently Ask Question (FAQ)

How to use Al Muslim application?

Project - Linux Toolbox | Based on Shell Script

Table of Content

Chapter 1 Introduction

  1.1 Introduction

  1.2 Design Goals/Objective

Chapter 2 Design/Development/Implementation of the Project

  2.1 Design

  2.2 Code Implementation

Chapter 3 Performance Evaluation

  3.1 Simulation Environment/ Simulation Procedure

  3.2 Results and Discussions

  3.3 Analysis and Outcome

  3.4 Limitations

Chapter 4 Conclusion

  4.1 Introduction

  4.2 Practical Implications

  4.3 Scope of Future Work

References

Chapter 1

Introduction

1.1 Introduction

Linux Toolbox is a tool for Linux operating systems, which allow to check the different type of system information. For example - date, time, device owner, disk usages, memory usages, CPU usages and etc. Another feature of Linux Toolbox is - it will show the current monthly calendar for any year, it can manage a huge of contact information, and it can create a notebook.

1.2 Design Goals/Objective

The sole intention behind the consideration of this project is to generate and manage to show some system information. This project has been developed considering note and contact information keeping the context of the user in mind. Here, the data has been stored in a few text files in the storage.

Chapter 2

Design/Development/Implementation of the Project

2.1 Design

To develop Linux Toolbox, we use Visual Studio Code IDE for code edit. The Linux Toolbox is a simple GUI-based application that has been developed in Shell Script. It is allowed to show system information, enables a store of notebook and contact information. Those are essentially databases that track all information for a user and a user can avail the benefits of using this application. Here, linux_toolbox.sh is the main file. There is also have a file calendar.sh that can show a month of calendar for the user.

2.2 Code Implementation

In this application, users can sign-up, log-in and see the monthly calendar. Also, users can use notebooks and add favorite contact information. We worked with Bash language and use Graphical User Interface via the YAD library. In the case of Bash/Shell Script, we have used some functions such as calendar, home, notebook, view_all_note, contact, and etc which have been used to reduce the code space. Click below to jump in the source code-

Source Code - Linux Toolbox
#!/bin/bash

FILE=$(pwd)/admin.log
LOGGEDIN=$(pwd)/loggedin.log

# bash functions start
#calendar window
function calendar(){
   yad --center --borders=10 --width=420 --title="Linux Toolbox - Calendar" --calendar --button=Back:0

   if [ ${?} -eq 252 ]; then
       echo "Linux Toolbox closed by user"
       exit
   fi
}

function view_all_note() {
    echo "View all note"

    # Get all note from file
    note_file=$(pwd)/notebook.txt

    if [ -f "$note_file" ]; then
        note_text=$(cat notebook.txt)
        notebook=$(yad --scroll --width=450 --height=500 --title="Linux Toolbox - Notebook" --borders=10 --center --separator="ㅤ" \
        --text-align=center \
        --text="<span><b><big><big>My Notes</big></big></b></span>" \
        --form \
        --field="$note_text":LBL \
        --button="Back:0" \
        )
        btn_click=$?

        if [ $btn_click == 0 ]; then
            echo "Back to Notebook"
        elif [ $btn_click == 252 ]; then
            echo "Linux Toolbox closed by user"
            exit
        fi
    else
        echo "No note found"
        notebook=$(yad --scroll --width=450 --height=500 --title="Linux Toolbox - Notebook" --borders=10 --center --separator="ㅤ" \
        --text-align=center \
        --text="<span><b><big><big>My Notes</big></big></b></span>" \
        --form \
        --field="No note found":LBL \
        --button="Back:0" \
        )
        btn_click=$?

        if [ $btn_click == 0 ]; then
            echo "Back to Notebook"
        elif [ $btn_click == 252 ]; then
            echo "Linux Toolbox closed by user"
            exit
        fi
    fi
}

function notebook(){

    while :
    do
        notebook=$(yad --width=450 --height=500 --title="Linux Toolbox - Notebook" --borders=10 --center --separator="ㅤ" \
        --text-align=center \
        --text="<span><b><big><big>Create Your Note</big></big></b></span>" \
        --form --field="<b>Title</b>": \
        --field="":TXT \
        --button="Add:2" \
        --button="View:3" \
        --button="Back:0" \
        )
        btn_click=$?

        if [ $btn_click == 0 ]; then
            echo "Back to home"
            break
        elif [ $btn_click == 2 ]; then
            title=$(echo $notebook | awk -F "ㅤ" '{print $1}')
            notebook=$(echo $notebook | awk -F "ㅤ" '{print $2}')
            break="\n----------------------------------------------------------------------------------------------------------\n"
            echo "Title: $title\nNote: $notebook $break" >> notebook.txt
            echo "Note added"
        elif [ $btn_click == 3 ]; then
            echo "View Note"
            view_all_note
        fi
    done
}

# contact window start
function add_contact(){

    contact_value=$(yad --form --center --borders=10 --width=380 --height=280 --title="Linux Toolbox" --separator='ㅤ' \
    --text-align=center --text="<span><b><big><big>Add Contact</big></big></b></span>"\
    --field="  <b>Name:</b>":LBL \
    --field="" \
    --field="  <b>Phone:</b>":LBL \
    --field="" \
    --field="  <b>Email:</b>":LBL \
    --field="" \
    --button=Add:0 \
    --button=Back:1 \ ) valid=${?}

    code=${?}

    if [ $code == 1 ]; then
        echo "Back to the contact window"
    elif [ $code == 0 ]; then
        echo "$contact_value"
        echo "Add contact"

        name=$(echo $contact_value | awk -F "ㅤ" '{print $2}')
        phone=$(echo $contact_value | awk -F "ㅤ" '{print $4}')
        email=$(echo $contact_value | awk -F "ㅤ" '{print $6}')
        break="------------------------------------------------"
        echo -e "Name: $name | Phone: $phone | Email: $email\n" >> contact_list.log
        add_contact
    fi
}

function phone_number_not_found(){
    echo "Phone number not found"
    $(yad --center --borders=10 --width=350 --height=300 --title="Linux Toolbox" --text="<span><b><big><big>Phone number not found</big></big></b></span>" \
    --button="Back":1 \ )
    code=${?}

    if [ $code == 1 ]; then
        echo "Back to home window"
    elif [ $code == 252 ]; then
        echo "Linux Toolbox closed by user"
        exit
    fi
}

function update_contact(){

    echo "Update contact"

    update_string=$(yad --form --center --borders=10 --width=350 --height=300 --title="Linux Toolbox" --separator='ㅤ' --text-align=center --text="<span><b><big><big>Update Contact</big></big></b></span>" \
    --field="<b>Old Phone:</b>":LBL \
    --field="" \
    --field="<b>New Name:</b>":LBL \
    --field="" \
    --field="<b>New Phone:</b>":LBL \
    --field="" \
    --field="<b>New Email:</b>":LBL \
    --field="" \
    --button="Update":0 \
    --button="Back":1 \ )

    code=${?}

    if [ $code == 1 ]; then
        echo "Back to home window"
    elif [ $code == 0 ]; then
        echo "Update string: $update_string"
        
        old_phone=""
        

        entry_phone=$(echo $update_string | awk -F "ㅤ" '{print $2}')
        full_string=$(grep -i "$entry_phone" contact_list.log)
    
        old_name=$(echo $full_string | awk '{print $2}')
        old_phone=$(echo $full_string | awk '{print $5}')
        old_email=$(echo $full_string | awk '{print $8}')

        echo "Full string: $full_string"
        echo "Old phone: $old_phone"
        echo "Entry phone: $entry_phone"

        if [ ! -z "$old_phone" ]; then
            if [ $entry_phone == $old_phone ]; then
                echo "Phone number found"

                new_name=$(echo $update_string | awk -F "ㅤ" '{print $4}')
                new_phone=$(echo $update_string | awk -F "ㅤ" '{print $6}')
                new_email=$(echo $update_string | awk -F "ㅤ" '{print $8}')

                if [ ! -z "$new_name" ]; then
                    sed -i "s/$old_name/$new_name/g" contact_list.log
                fi
                if [ ! -z "$new_phone" ]; then
                    sed -i "s/$old_phone/$new_phone/g" contact_list.log
                fi
                if [ ! -z "$new_email" ]; then
                    sed -i "s/$old_email/$new_email/g" contact_list.log
                fi
                echo "Contact Updated"
            else
                phone_number_not_found
            fi
        else
            phone_number_not_found
        fi
    elif [ $code == 252 ]; then
        echo "Linux Toolbox closed by user"
        exit
    fi
}

function view_contact(){
    
    echo "View contact"
    v_contact=$(nl -s '. ' -w 1 contact_list.log)

    $(yad --form --center --borders=10 --width=350 --height=300 --title="Linux Toolbox" --separator=' ' --text-align=center --scroll --text="<span><b><big><big>Contact List</big></big></b></span>"\
    --field="":LBL \
    --field="$v_contact":LBL \
    --button="Add":1 \
    --button="Update":2 \
    --button="Search":3 \
    --button="Delete":4 \
    --button="Back":0 \ )

    code=${?}
    
    if [ $code == 0 ]; then
        echo "Back to manage contact window"
    elif [ $code == 1 ]; then
        echo "Add contact"
        add_contact
    elif [ $code == 2 ]; then
        echo "Update contact"
        update_contact
    elif [ $code == 3 ]; then
        echo "Search contact"
        search_contact
    elif [ $code == 4 ]; then
        echo "Delete contact"
        delete_contact
    elif [ $code == 252 ]; then
        echo "Linux Toolbox closed by user"
        exit
    fi

}

function search_contact (){

    echo "Search contact"

    search_field=$(yad --form --center --borders=10 --width=350 --height=300 --title="Linux Toolbox" --separator=' ' --text-align=center --text="<span><b><big><big>Search Contact</big></big></b></span>" \
    --field="":LBL \
    --field="" \
    --button="Search":0 \
    --button="Back":1 \ ) code=${?}

    code=${?}

    if [ $code == 1 ]; then
        echo "Back to home window"
    elif [ $code == 0 ]; then
        echo "Search query: $search_field"
        contact_find $search_field
    elif [ $code == 252 ]; then
        echo "Linux Toolbox closed by user"
        exit
    fi
}

function contact_find {
    echo "Find contact"
    search=$(grep -i $1 contact_list.log)
    find_field=$(yad --form --center --borders=10 --width=450 --height=300 --scroll --title="Linux Toolbox" --separator=' ' --text-align=center --text="<span><b><big><big>Search Contact</big></big></b></span>"\
    --field="<b>Search Query:</b> $1\n\n<b>Result:</b>":LBL \
    --field="$search":LBL \
    --button="Back":1 \ ) code=${?}

    code=${?}

    if [ $code == 1 ]; then
        echo "Back to home window"
    elif [ $code == 252 ]; then
        echo "Linux Toolbox closed by user"
        exit
    fi
}

function delete_contact(){

    delete_string=$(yad --form --center --borders=10 --width=350 --height=300 --title="Linux Toolbox" --separator='ㅤ' --text-align=center --text="<span><b><big><big>Delete Contact</big></big></b></span>" \
    --field="<b>Enter Phone Number:</b>":LBL \
    --field="" \
    --button="Delete":0 \
    --button="Back":1 \ ) code=${?}


    if [ $code == 1 ]; then
            echo "Back to home window"
    elif [ $code == 0 ]; then

        echo "Delete string: $delete_string"
        
        entry_phone=$(echo $delete_string | awk -F "ㅤ" '{print $2}')
        full_string=$(grep -i "$entry_phone" contact_list.log)

        delete_via_phone=$(echo $full_string | awk '{print $5}')

        echo "Delete row: $delete_via_phone"

        if [ ! -z "$delete_via_phone" ]; then
                if [ $entry_phone == $delete_via_phone ]; then
                
                    sed -i -e "/$delete_via_phone/d" contact_list.log
                    echo "Contact deleted"
                else
                    phone_number_not_found
                fi
        else
            phone_number_not_found
        fi
    fi
}
# contact window end

function contact(){
    
    while :
    do
        contact=$(yad --form --center --borders=10 --width=350 --height=300 --title="Linux Toolbox" --separator=' ' --text-align=center --text="<span><b><big><big>Manage Contacts</big></big></b></span>"\
        --field="":LBL \
        --field="<b>Add:</b> Add contact information. i.e: Name, Email Address, and Phone Number.":LBL \
        --field="<b>Update:</b> Update a specific contact.":LBL \
        --field="<b>View:</b> View the contact list after adding one or more contact to list.":LBL \
        --field="<b>Search:</b> Search a specific contact.":LBL \
        --field="<b>Delete:</b> Delete a specific contact.":LBL \
        --button="Add":1 \
        --button="Update":2 \
        --button="View":3 \
        --button="Search":4 \
        --button="Delete":5 \
        --button="Back":0 \ ) code=${?}

        code=${?}
        
        if [ $code == 0 ]; then
            echo "Contact window closed by user"
            ./linux_toolbox.sh
            exit
        elif [ $code == 1 ]; then
            echo "Add contact"
            add_contact
        elif [ $code == 2 ]; then
            echo "Update contact"
            update_contact
        elif [ $code == 3 ]; then
            echo "View contact"
            view_contact
        elif [ $code == 4 ]; then
            echo "Search contact"
            search_contact
        elif [ $code == 5 ]; then
            echo "Delete contact"
            delete_contact
        elif [ $code == 252 ]; then
            echo "Linux Toolbox closed by user"
            exit
        fi
    done
}

function home(){

    date=$(date +'%A %B %d, %Y')
    time=$(date +'%l:%M:%S %p')
    user=$(whoami)
    email=$(awk -F ":" '{print $1}' admin.log)
    # cmd: lscpu 
    #memory_usage=$(free | awk 'FNR==2 {print $3/(1024*1024),"/ "$2/(1024*1024)" GB"}')
    swap_usage=$(free | awk 'FNR==3 {print $3/(1024*1024),"/ "$2/(1024*1024)" GB"}')
    free_disk=$(df | awk 'FNR==4 {print $3/(1024*1024),"/ "$2/(1024*1024)" GB"}')

    total_memory=$(cat /proc/meminfo | awk 'FNR==1 {print $2/(1024*1024)}')
    availabe_memory=$(cat /proc/meminfo | awk 'FNR==3 {print $2/(1024*1024)}')
    memory_usage=$(echo "$total_memory - $availabe_memory" | bc)

    swap_usage=$(free | awk 'FNR==3 {print $3/(1024) "  MB","/ "$2/(1024*1024)" GB"}')
    disk_usage=$(df | awk 'FNR==4 {print $3/(1024*1024) " GB","/ "$2/(1024*1024)" GB"}')

    processor=$(cat /proc/cpuinfo | awk -F ": " 'FNR==5 {print $2}')
    cache_size=$(cat /proc/cpuinfo | awk -F ": " 'FNR==9 {print $2}')
    total_processor=$(cat /proc/cpuinfo | grep processor | wc -l)
    os_type=$(lscpu | awk 'FNR==2 {print $4}')
    os_support=$(lscpu | awk 'FNR==2 {print $3,$4}')
    cpu_speed=$(lscpu | awk 'FNR==16 {print $3}' | sed 's/\..*//')
    cpu_min_speed=$(lscpu | awk 'FNR==18 {print $4}' | sed 's/\..*//')
    cpu_max_speed=$(lscpu | awk 'FNR==17 {print $4}' | sed 's/\..*//')
    total_task=$(ps -e | wc -l)

    yad --title="Linux Toolbox" --center --borders=10 --width=450 --height=500 --text-align=center --separator="" --text="<span><b><big><big>System Info</big></big></b></span>" \
    --field="":LBL \
    --form \
    --field="<b><u>Basic Info</u></b>":LBL \
    --field="<b>Date:</b> $date":LBL \
    --field="<b>Time:</b> $time":LBL \
    --field="<b>Username:</b> $user":LBL \
    --field="<b>Email:</b> $email":LBL \
    --field="":LBL \
    --field="<b><u>Memory Info</u></b>":LBL \
    --field="<b>Memory Usage: </b>$memory_usage GB / $total_memory GB":LBL \
    --field="<b>Memory Available: </b>$availabe_memory GB":LBL \
    --field="<b>Swap Usage: </b>$swap_usage":LBL \
    --field="<b>Disk Usage: </b>$disk_usage":LBL \
    --field="":LBL \
    --field="<b><u>CPU Info</u></b>":LBL \
    --field="<b>Processor: </b>$processor × $total_processor":LBL \
    --field="<b>OS Type: </b>$os_type":LBL \
    --field="<b>OS Support: </b>$os_support":LBL \
    --field="<b>Cache Size: </b>$cache_size":LBL \
    --field="<b>CPU Speed: </b>$cpu_speed MHz":LBL \
    --field="<b>CPU Min Speed: </b>$cpu_min_speed MHz":LBL \
    --field="<b>CPU Max Speed: </b>$cpu_max_speed MHz":LBL \
    --field="<b>Total Task: </b>$total_task":LBL \
    --field="Calendar":FBTN "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "./calendar.sh" \
    --button="Notebook":2 \
    --button="Contact":3 \
    --button="Refresh":1 \
    --button="Log out":4 \
    --button="Exit":0
    code=${?}

    if [ $code == 0 ]; then
        echo "Linux Toolbox closed by user"
        exit
    elif [ $code == 1 ]; then
        echo "Refresh Date: $date $time"
    elif [ $code == 2 ]; then
        echo "Notebook window"
        notebook
    elif [ $code == 3 ]; then
        echo "Contact window"
        contact
    elif [ $code == 4 ]; then
        echo "Logged out"
        rm loggedin.log
        ./linux_toolbox.sh
        exit
    elif [ $code == 252 ]; then
        echo "Linux Toolbox closed by user"
        exit
    fi
}

export -f calendar home notebook view_all_note contact add_contact view_contact search_contact contact_find update_contact phone_number_not_found delete_contact
# bash functions end

if [ -f "$FILE" ]
then
    while :
    do
        
        if [ -f "$LOGGEDIN" ]
        then
            old_usr_pass=$(cat admin.log)
            log_usr_pass=$(cat loggedin.log)

            if [ $old_usr_pass == $log_usr_pass ]
            then
                # If the user has already logged in, redirected in home page
                echo "User already logged in"
                home
            else
                rm loggedin.log
                echo "User not logged in"
            fi
        else
            # login window start
            echo "Login window..."
            # login window
            login=$(yad --form --center --borders=10 --width=400 --height=300 --title="Linux Toolbox - Login" --separator=' ' \
                --button="Calendar":"bash -c calendar" \
                --button=Exit:1 \
                --button=Login:0 \
                --field="Email":\
                --field="Password":\') valid=${?}

            if [ $valid -eq 0 ]; then

                email=$(echo $login | awk '{print $1}') 
                password=$(echo $login | awk '{print $2}')

                echo "Email = $email"

            elif [ $valid -eq 1 ]; then
                echo "Linux Toolbox closed by user"
                exit
            fi
            # login window end

            echo -e "$email:$password" >> temp.log

            old_usr_pass=$(cat admin.log)
            crnt_usr_pass=$(cat temp.log)

            if [ $old_usr_pass == $crnt_usr_pass ]
            then
                rm temp.log
                echo "Login Successful"
                echo "$email:$password" >> loggedin.log
                # login success window start
                home
                # login success window end
            else
                rm temp.log
                # login failed window start
                echo "Login Failed!"
                echo "Wrong email or password"
                # login failed window end
            fi

        fi

    done

else
    # create admin.log file start
    echo "Signup window..."

    # signup window
    signup=$(yad --form --center --borders=10 --width=350 --height=300 --title="Linux Toolbox - Signup" --separator=' ' --text-align=center --text="<span><b><big><big>Signup</big></big></b></span>"\
        --field="":LBL \
        --button="Calendar":"bash -c calendar" \
        --button=Exit:1 \
        --button=Signup:0 \
        --field="Email":\
        --field="Password":\') valid=${?}

    if [ $valid -eq 0 ]; then

        email=$(echo $signup | awk '{print $1}') 
        password=$(echo $signup | awk '{print $2}')

        echo "Email = $email"
        # echo "Password = $password"

        echo "$email:$password" >> admin.log
        # create admin.log file end

        ./linux_toolbox.sh

    elif [ $valid -eq 1 ]; then
        echo "Linux Toolbox closed by user"
        exit
    fi
    
fi
Source Code - Calendar
echo "Calendar window"

yad --center --borders=10 --width=420 --title="Linux Toolbox - Calendar" --calendar --button=Back:0

if [ ${?} -eq 252 ]; then
    echo "Linux Toolbox closed by user"
    exit
fi

Chapter 3 Performance

Evaluation

3.1 Simulation

We have been able to meet the goals we set for ourselves in this project. Our code worked properly and was able to run Linux Toolbox. Also, the additional functions we added for user interaction all worked the way we initially expected. Each step along the way we tested our code to make sure everything was properly mapped.

3.2 Results and Discussions

After running Linux Toolbox, it will show the Sign-up window for the first time. Once the user has successfully signed up, the user will be shown a login window. And then the user needs to log in to use Linux Toolbox. Here users can use a blank email and password when signing up.

Sign-up window
Sign-in window

Figure-1: Sign-up and Login Window

After successful login, users will be able to view system information, add notebooks, and manage contact information.

System Information Window

Figure-2: System Information Window

Calendar Window

Figure-3: Calendar Window

Create Notebook Window

Figure-4: Create Notebook Window

Notebook Window

Figure-5: Notebook Window

Manage Contacts Window

Figure-6: Manage Contacts Window

Update Contacts Window
Search Contacts Window

Figure-7: Update and Search Contacts Window

Search Contacts Window

Figure-8: Search Contacts Window

Figure-9: Contact List Window

3.3 Analysis and Outcome

Our goal was to see the monthly calendar, add notes, manage contact, and view system information. In this project, our code worked properly and was able to successfully run Linux Toolbox. Also, the additional functions we added for user interaction all worked the way we initially expected. Each step along the way we tested our code to make sure everything was properly mapped.

3.4 Limitations

Although Linux Toolbox runs properly, there is some limitation for this application.

  1. In the Manage Contact part, the user can add multiple strings like a name but can’t update multiple strings as a name.
  2. The user can’t modify/update, search and delete Notebook.
  3. There may be other bugs in the Linux toolbox.

Chapter 4

Conclusion

4.1 Introduction

In this project, we gained a lot of knowledge and experience working with the Linux operating system. We learned how to work Bash language. Also, we learned more about the basic principles of Linux application. Our team members have made improvements in various areas such as developing a structured information pathway for all types of software and understanding more about state machines. Although this is a YAD base project, it was a great experience in developing software. The principle behind constructing a Linux Toolbox is to effectively retrieve and implement any information. All the information related to a particular people can be linked and archived only to be retrieved later when they are required most.

4.2 Practical Implications

Linux Toolbox is one of the useful applications used to show the system information. This type of software can be used to note down user information and create contact and also manage the contact information.

4.3 Scope of Future Work

In the future, we have planned to add more features for Linux Toolbox. For example, users can manage background applications such as kill or end process for Linux/GNU operating system. It would be handy for all Linux users. We have a plan to increase the limit of features. And we will upgrade it with many more facilities in the future.

Write a Java program to generate unique random numbers

Generate Unique Random Numbers
Sample Output
Enter a limit of random number: 10
1
5
2
4
9
3
10
6
8
7
Source Code
import java.util.ArrayList;
import java.util.Random;
import java.util.Scanner;

public class Main {

    public static boolean isDuplicate(ArrayList<Integer> numbers, int randomNumber){
        
        for (int i = 0; i < numbers.size(); i++) {
            
            if (numbers.get(i) == randomNumber) {
                
                return true;
            }
        }
        
        return false;
    }
    
    public static void main(String args[]) {

        Random random = new Random();

        int uniqueNumberCount = 0, randomNumber, limit;
        
        ArrayList<Integer> pastNumber = new ArrayList<>();
        
        Scanner in = new Scanner(System.in);
        
        System.out.print("Enter a limit of random number: ");
        limit = in.nextInt();
        
        for (int i = 0; uniqueNumberCount < limit; i++) {
            
            randomNumber = random.nextInt(limit) + 1;
            
            if (!isDuplicate(pastNumber, randomNumber)) {
                
                System.out.println(randomNumber);
                
                pastNumber.add(uniqueNumberCount++, randomNumber);
            }
        }

    }
}
Sample Output
Enter a limit of random number: 5
5
4
2
1
3

Write a C program to convert Binary to Decimal number system

Convert Binary to Decimal number system
Sample Output
Enter binary number: 1111111

Decimal Number: 127
Source Code
// Convert Binary to Decimal number system

#include<stdio.h>
#include<string.h>
#include<math.h>

int main()
{
    int i, bin_length, power, decimal_number = 0;
    char binary_number[100];

    printf("Enter binary number: ");
    scanf("%s", binary_number);

    // Length of binary_number string
    for(i = 0; binary_number[i] != '\0'; i++);
    bin_length = i;

    /*
    Decimal to Binary
    Example:
    Binary number = 1001

    2^3     2^2     2^1     2^0
    1       0       0       1
    8           +           1

    Decimal number = 9

    */

    for(i = 0, power = (bin_length - 1); i < bin_length; i++, power--)
    {
        if(binary_number[i] == '1')
        {
            decimal_number += pow(2, power);
        }
    }

    printf("\nDecimal Number: %d\n\n", decimal_number);

    return 0;
}
Sample Output
Enter binary number: 01101110

Decimal Number: 110

Write a C program to convert Binary to Octal number system

Convert Binary to Octal number system
Sample Output
Enter binary number: 11010

Octacl Number: 32
Source Code
// Convert Binary to Octal number system

#include<stdio.h>
#include<string.h>
#include<math.h>

int main()
{
    int i, bin_length, dec_length, remainder[100];
    int power, decimal_number = 0, octal_number, temp;
    char binary_number[100];

    printf("Enter binary number: ");
    scanf("%s", binary_number);

    // Length of binary_number string
    for(i = 0; binary_number[i] != '\0'; i++);
    bin_length = i;

    /*
    Decimal to Binary
    Example:
    Binary number = 1001

    2^3     2^2     2^1     2^0
    1       0       0       1
    8           +           1

    Decimal number = 9

    */

    for(i = 0, power = (bin_length - 1); i < bin_length; i++, power--)
    {
        if(binary_number[i] == '1')
        {
            decimal_number += pow(2, power);
        }
    }

    i = 0;
    while(decimal_number != 0)
    {
        remainder[i] = (decimal_number % 8);
        decimal_number /= 8;

        i++;
    }
    dec_length = i;

    for(i = (dec_length - 1); i >= 0; i--)
    {
        octal_number +=  (remainder[i] * pow(10, i));
    }

    printf("\nOctacl Number: %d\n\n", octal_number);

    return 0;
}
Sample Output
Enter binary number: 1111111

Octacl Number: 177

Write a C program to find two's complement of a binary number

Find two's complement of a binary number
Sample Output
Enter binary number: 01101110

One's Complement: 10010001
Two's Complement: 10010010
Source Code
// Find two's complement of a binary number

#include<stdio.h>
#include<string.h>

int main()
{
    int i, bin_length;
    char carry = '1', binary_number[100], ones_comp[100], twos_comp[100];
input:
    printf("Enter binary number: ");
    scanf("%s", binary_number);

    // Length of binary_number string
    for(i = 0; binary_number[i] != '\0'; i++);
    bin_length = i;

    for(i = 0; i < bin_length; i++)
    {
        if(binary_number[i] == '0')
        {
            ones_comp[i] = '1';
        }
        else if(binary_number[i] == '1')
        {
            ones_comp[i] = '0';
        }
        else
        {
            printf("Unexpected character! Please enter a valid input...\n\n");
            goto input;
        }
    }
    ones_comp[i] = '\0'; // End of string

    for(i = (bin_length - 1); i >= 0; i--)
    {
        if(ones_comp[i] == '1' && carry == '1')
        {
            twos_comp[i] = '0';
        }
        else if(ones_comp[i] == '0' && carry == '1')
        {
            twos_comp[i] = '1';
            carry = '0';
        }
        else if(carry == '0')
        {
            twos_comp[i] = ones_comp[i];
        }
    }

    printf("\nOne's Complement: %s\nTwo's Complement: %s\n\n", ones_comp, twos_comp);

    return 0;
}
Sample Output
Enter binary number: 00010100    

One's Complement: 11101011
Two's Complement: 11101100

Write a C program to find one's complement of a binary number

Find one's complement of a binary number
Sample Output
Enter binary number: 110101

Binary Number: 110101
One's Complement: 001010
Source Code
// Find one's complement of a binary number

#include<stdio.h>
#include<string.h>

int main()
{
    int i, bin_length;
    char binary_number[100], ones_comp[100];
input:
    printf("Enter binary number: ");
    scanf("%s", binary_number);

    // Length of binary_number string
    for(i = 0; binary_number[i] != '\0'; i++);
    bin_length = i;

    for(i = 0; i < bin_length; i++)
    {
        if(binary_number[i] == '0')
        {
            ones_comp[i] = '1';
        }
        else if(binary_number[i] == '1')
        {
            ones_comp[i] = '0';
        }
        else
        {
            printf("Unexpected character found! Please enter a valid input...\n\n");
            goto input;
        }
    }
    ones_comp[i] = '\0'; // End of string by creating a NULL value.

    printf("\nBinary Number: %s\nOne's Complement: %s\n\n", binary_number, ones_comp);

    return 0;
}
Sample Output
Enter binary number: 1010

Binary Number: 1010
One's Complement: 0101

Write a C program to print Fibonacci series up to n terms

Print Fibonacci series up to n terms
Sample Output
Enter a limit: 10

Fibonacci series: 0 1 1 2 3 5 8 13 21 34
Source Code
// Print Fibonacci series up to n terms

#include<stdio.h>

int main()
{
    int i, limit, first = 0, second = 1, last;

    /*
    FirstNum + LastNum = LastNum
    Fibonacci series: 0 1 1 2 3 5 8 13. . .
    */

    printf("Enter a limit: ");
    scanf("%d", &limit);

    printf("\nFibonacci series: ");
    for(i = 1; i <= limit; i++)
    {
        printf("%d ", first);

        last = first + second;
        first = second;
        second = last;
    }
    printf("\n\n");

    return 0;
}
Sample Output
Enter a limit: 11

Fibonacci series: 0 1 1 2 3 5 8 13 21 34 55

Write a C program to print all Strong numbers between 1 to n

Print all Strong numbers between 1 to n
Sample Output
Enter a limit for Strong numbers: 150

All Strong numbers between 1 to n: 1 2 145
Source Code
// Print all Strong numbers between 1 to n

#include<stdio.h>
#include<math.h>

int main()
{
    int i, j, limit, number, numberClone, digit, sum = 0, factorial = 1;

    printf("Enter a limit for Strong numbers: ");
    scanf("%d", &limit);

    printf("\nAll Strong numbers between 1 to n: ");
    for(i = 1; i <= limit; i++)
    {
        number = numberClone = i;

        while(number != 0)
        {
            digit = (number % 10);
            number = (number / 10);

            // Sum of the factorial of the individual digits
            for(j = 1; j <= digit; j++)
            {
                factorial = (factorial * j);
            }
            sum = (sum + factorial);

            factorial = 1; // Reset value
        }

        if(numberClone == sum)
        {
            printf("%d ", numberClone);
        }

        sum = 0; // Reset value
    }
    printf("\n\n");

    return 0;
}
Sample Output
Enter a limit for Strong numbers: 50000

All Strong numbers between 1 to n: 1 2 145 40585

Write a C program to check whether a number is Strong number or not

Check whether a number is Strong number or not
Sample Output
Enter a number: 145

145 is a Strong number!
Source Code
// Check whether a number is Strong number or not

#include<stdio.h>
#include<math.h>

int main()
{
    int i, number, numberClone, digit, sum = 0, factorial = 1;

    printf("Enter a number: ");
    scanf("%d", &number);

    numberClone = number;

    while(number != 0)
    {
        digit = (number % 10);
        number = (number / 10);

        // Sum of the factorial of the individual digits
        for(i = 1; i <= digit; i++)
        {
            factorial = (factorial * i);
        }
        sum = (sum + factorial);

        factorial = 1; // Reset value
    }
    
    if(numberClone == sum)
    {
        printf("\n%d is a Strong number!\n\n", numberClone);
    }
    else
    {
        printf("\n%d is not a Strong number.\n\n", numberClone);
    }

    return 0;
}
Sample Output
Enter a number: 40585

40585 is a Strong number!

Write a C program to print all Armstrong numbers between 1 to n

Print all Armstrong numbers between 1 to n
Sample Output
Enter a limit for armstrong numbers: 900

All armstrong numbers 1 to 900: 1 2 3 4 5 6 7 8 9 153 370 371 407
Source Code
#include<stdio.h>
#include<math.h>

//Print all Armstrong numbers between 1 to n

int main()
{
    int i, limit, number, numberClone, digit, count = 0, newNumber = 0;

    printf("Enter a limit for armstrong numbers: ");
    scanf("%d", &limit);

    printf("\nAll armstrong numbers 1 to %d: ", limit);
    for(i = 1; i <= limit; i++)
    {
        number = i;
        numberClone = number;
        while(number != 0)
        {
            digit = (number%10);
            number /= 10;
            count++;
        }

        number = numberClone;
        while(number != 0)
        {
            digit = (number%10);
            number /= 10;

            newNumber += pow(digit, count);
        }

        if(numberClone == newNumber)
        {
            printf("%d ", newNumber);
        }

        count = 0;
        newNumber = 0;
    }
    printf("\n\n");

    return 0;
}
Sample Output
Enter a limit for armstrong numbers: 900

All armstrong numbers 1 to 900: 0 1 2 3 4 5 6 7 8 9 153 370 371 407

Take 5 numbers in an array and find all pairs of prime numbers from that array

Find all pair of prime numbers from a array

Sample Input Sample Output
2, 3, 4, 5, 6 2, 3
2, 5
3, 5
Sample Output
Enter 5 element: 2 3 4 5 6
2,3
2,5
3,5
Source Code
#include<stdio.h>

void main()
{
    int i, j, k = 0, isPrime, size = 5, arr[5], primeNum[5];

    printf("Enter 5 element: ");
    for(i = 0; i < size; i++)
    {
        scanf("%d", &arr[i]);
    }

    for(i = 0; i < size; i++)
    {
        if(arr[i] == 2)
        {
            primeNum[k++] = arr[i];
        }
        else
        {
            isPrime = 1;
            for(j = 2; j < arr[i]; j++)
            {
                if(arr[i] % j == 0)
                {
                    isPrime = 0;
                    break;
                }
            }
            if(isPrime == 1)
            {
                primeNum[k++] = arr[i];
            }
        }
    }
    if(k < 2)
    {
        printf("\nPair not possible!");
    }
    for(i = 0; i < ((k * (k+1))/2); i++)
    {
        for(j = i+1; j < k; j++)
        {
            printf("%d,%d\n", primeNum[i], primeNum[j]);
        }
    }
    printf("\n");

}
Sample Output
Enter 5 element: 2 3 5 7 11
2,3
2,5
2,7
2,11
3,5
3,7
3,11
5,7
5,11
7,11

Responsive Blogger, WordPress and Static Demo Templates

Write a C Code to find total marks from given input...

Write a C Code to find total marks from given input: Attendance, Class test, Quiz test, Assignment, Midterm and Final Exam and find the grade using the following method:

  1. If Total mark >=80 then A+
  2. If Total mark >=70 then A
  3. If Total mark >=60 then A
  4. If Total mark >=50 then B
  5. Else Grade = F

Sample Input

Enter Attendance, Class test, Quiz test, Assignment, Midterm and Final Exam: 2.5 7.5 3.5 7 21.5 33

Sample Output

Total Mark: 75 & Grade: A

Sample Output
Enter Attendance, Class test, Quiz test, Assignment, Midterm and Final Exam: 2.5 7.5 3.5 7 21.5 33
Total Mark: 75.000000 & Grade: A
Source Code
#include<stdio.h>

int main()
{
    float attendance, ct, qt, assignment, mid_mark, final_mark, total_mark;

    printf("Enter Attendance, Class test, Quiz test, Assignment, Midterm and Final Exam: ");
    scanf("%f %f %f %f %f %f", &attendance, &ct, &qt, &assignment, &mid_mark, &final_mark);
    //Input: 2.5 7.5 3.5 7 21.5 33

    total_mark = (attendance + ct + qt + assignment + mid_mark + final_mark);

    if(total_mark >= 80 && total_mark <= 100)
    {
        printf("Total Mark: %f & Grade: A+\n\n", total_mark);
    }
    else if(total_mark >= 70 && total_mark <= 79)
    {
        printf("Total Mark: %f & Grade: A\n\n", total_mark);
    }
    else if(total_mark >= 60 && total_mark <= 69)
    {
        printf("Total Mark: %f & Grade: A-\n\n", total_mark);
    }
    else if(total_mark >= 50 && total_mark <= 59)
    {
        printf("Total Mark: %f & Grade: B\n\n", total_mark);
    }
    else
    {
        printf("Total Mark: %f & Grade: F\n\n", total_mark);
    }

    return 0;
}
Sample Output
Enter Attendance, Class test, Quiz test, Assignment, Midterm and Final Exam: 2.5 7.5 3.5 7 21.5 33
Total Mark: 75.000000 & Grade: A

Write a C Code to calculate D = 𝒃^𝟐 − 𝟒𝐚𝐜 and...

Write a C Code to calculate D = 𝒃^𝟐 − 𝟒𝐚𝐜 and show the result according to following conditions:

a. D>0 then Calculate X1, X2. Where 𝒙𝟏 = (−𝒃+√𝒃^𝟐−𝟒𝒂𝒄)/𝟐𝒂 and 𝒙𝟐 = (−𝒃−√𝒃^𝟐−𝟒𝒂𝒄)/𝟐𝒂

        b. D =0 then calculate X. Where 𝐱 = 𝒃^𝟐/𝟐𝒂

        c. D<0 then print “No Solution”.

Sample Input

        Enter a, b & c: 5 6 1

Sample Output

    X1: -0.2

    X2: -1
Sample Output
Enter a, b, & c: 5 6 1
X1: -0.200
x2: -1.000
Source Code
#include<stdio.h>
#include<math.h>

int main()
{
    float D, b, a, c, x, x1, x2;

    printf("Enter a, b, & c: ");
    scanf("%f %f %f", &a, &b, &c);

    D = ((b*b) - 4*a*c);

    if(D > 0)
    {
        x1 = (-b + sqrt(D))/(2*a);
        x2 = (-b - sqrt(D))/(2*a);

        printf("X1: %.3f\nx2: %.3f\n\n", x1, x2);
    }
    else if(D == 0)
    {
        x = (b*b)/(2*a);

        printf("X: %f\n\n");
    }
    else if(D < 0)
    {
        printf("No Solution\n\n");
    }
    return 0;
}
Sample Output
Enter a, b, & c: 5 6 1
X1: -0.200
x2: -1.000

Write a C program to solve the Drake equation...

Write a C program to solve the Drake equation N = R*fp*ne*fl*fi*fc*L. Where R, ne and L must be discrete value.

Sample Input

    Enter R, F(p), n(e), f(l), f(i), f(c), L: 5 0.25 20 0.2 0.15 0.11 150

Sample Output

    The number of communicative civilizations within the Milky Way today: 12.375

Sample Output
Enter R, F(p), n(e), f(l), f(i), f(c): 5 0.25 20 0.2 0.15 0.11 150
The number of communicative civilizations within the Milky Way today: 12.375
Source Code
#include<stdio.h>
#include<math.h>

int main()
{
    float N, fp, fl, fi, fc;
    int R, ne, L;

    printf("Enter R, F(p), n(e), f(l), f(i), f(c): ");
    scanf("%d %f %d %f %f %f %d", &R, &fp, &ne, &fl, &fi, &fc, &L); //Input: 5 0.25 20 0.2 0.15 0.11 150

    float n = (float)R*ne*L;
    N = n*fp*fl*fi*fc;

    printf("The number of communicative civilizations within the Milky Way today: %.3f\n\n", N);

    return 0;
}
Sample Output
Enter R, F(p), n(e), f(l), f(i), f(c): 5 0.25 20 0.2 0.15 0.11 150
The number of communicative civilizations within the Milky Way today: 12.375

Lab Task: MID TERM [20 Marks] | Assignment - June 2021

1. [5] Write a C program to solve the Drake equation N = R*fp*ne*fl*fi*fc*L. Where R, ne and L must be discrete value

Sample Input

    Enter R, F(p), n(e), f(l), f(i), f(c), L: 5 0.25 20 0.2 0.15 0.11 150

Sample Output

    The number of communicative civilizations within the Milky Way today: 12.375

2. [7] Write a C Code to calculate D = 𝒃^𝟐 − 𝟒𝐚𝐜 and show the result according to following conditions:

a. D>0 then Calculate X1, X2. Where 𝒙𝟏 = (−𝒃+√𝒃^𝟐−𝟒𝒂𝒄)/𝟐𝒂 and 𝒙𝟐 = (−𝒃−√𝒃^𝟐−𝟒𝒂𝒄)/𝟐𝒂

        b. D =0 then calculate X. Where 𝐱 = 𝒃^𝟐/𝟐𝒂

        c. D<0 then print “No Solution”.

Sample Input

        Enter a, b & c: 5 6 1

Sample Output

    X1: -0.2

    X2: -1

3. [8] Write a C Code to find total marks from given input: Attendance, Class test, Quiz test, Assignment, Midterm and Final Exam and find the grade using the following method:

  1. If Total mark >=80 then A+
  2. If Total mark >=70 then A
  3. If Total mark >=60 then A
  4. If Total mark >=50 then B
  5. Else Grade = F

Sample Input

Enter Attendance, Class test, Quiz test, Assignment, Midterm and Final Exam: 2.5 7.5 3.5 7 21.5 33

Sample Output

Total Mark: 75 & Grade: A

Change Theme
X