bsc

Comprehensive codebase and cou...
Log | Files | Refs | README | LICENSE

commit 3c2bd4af00d5adda20ad923b16d4a24180a53adc
parent 70a704aaf12e629388c8f2bb5f1989287f87cd1f
Author: Amit Dutta <amitdutta4255@gmail.com>
Date:   Sun, 12 Oct 2025 14:37:58 +0530

docs

Diffstat:
Mdocs/generate_index.py | 122++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------
Mdocs/index.html | 4397++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------
Mdocs/template.html | 336++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------
3 files changed, 4429 insertions(+), 426 deletions(-)

diff --git a/docs/generate_index.py b/docs/generate_index.py @@ -1,4 +1,5 @@ import os +import html # --- Configuration --- # The root URL of your repository. @@ -7,47 +8,48 @@ REPO_URL = "https://github.com/notamitgamer/bsc" EXCLUDED_DIRS = ['.git', '.github', '.vscode', 'MinGW64', 'print', 'docs'] # List of files to exclude from the list. EXCLUDED_FILES = ['index.html', 'README.md', 'CODE_OF_CONDUCT.md', 'CONTRIBUTING.md', - 'LICENSE', 'main.js', 'package.json', 'SECURITY.md', 'server.js', 'template.html'] + 'LICENSE', 'main.js', 'package.json', 'SECURITY.md', 'server.js', 'template.html', 'generate_index.py'] # --- End Configuration --- +def get_language_class(filename): + """Gets the highlight.js language class from the file extension.""" + if filename.endswith('.c'): + return 'c' + if filename.endswith('.py'): + return 'python' + if filename.endswith('.html'): + return 'xml' + if filename.endswith('.js'): + return 'javascript' + if filename.endswith('.css'): + return 'css' + return 'plaintext' + def generate_file_list(): """Walks the repo and generates an HTML list of its files and directories with folder contents.""" items = [] - # SVG Icons for folders and files + # SVG Icons folder_icon = '<svg class="w-6 h-6 text-blue-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"></path></svg>' file_icon = '<svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg>' chevron_down = '<svg class="w-5 h-5 text-gray-500 transition-transform duration-200" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"></path></svg>' + github_icon = '<svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg>' # Walk through the repository's root directory for root, dirs, files in os.walk('.', topdown=True): - # Exclude specified directories from being traversed dirs[:] = [d for d in dirs if d not in EXCLUDED_DIRS] if root == '.': - # Sort directories alphabetically dirs.sort() files.sort() - # Create expandable sections for directories with their contents for dirname in dirs: encoded_dirname = dirname.replace(' ', '%20') folder_url = f"{REPO_URL}/tree/main/{encoded_dirname}" - - # Get files in this directory dir_path = os.path.join('.', dirname) try: - dir_files = [] - if os.path.exists(dir_path): - for item in os.listdir(dir_path): - item_path = os.path.join(dir_path, item) - if os.path.isfile(item_path) and not item.startswith('.'): - # Filter out .exe files and other binary files - if not item.endswith(('.exe', '.png', '.jpg', '.jpeg', '.gif', '.md')): - dir_files.append(item) - dir_files.sort() + dir_files = sorted([item for item in os.listdir(dir_path) if os.path.isfile(os.path.join(dir_path, item)) and not item.startswith('.') and not item.endswith(('.exe', '.png', '.jpg', '.jpeg', '.gif', '.md'))]) - # Create folder section with files file_count = len(dir_files) folder_header = f''' <li class="border rounded-lg overflow-hidden"> @@ -58,8 +60,10 @@ def generate_file_list(): <span class="font-medium text-gray-800">{dirname}</span> <span class="ml-2 text-sm text-gray-500">({file_count} files)</span> </div> - <div class="flex items-center space-x-2"> - <a href="{folder_url}" target="_blank" class="text-blue-500 font-semibold text-sm hover:underline" onclick="event.stopPropagation()">GitHub</a> + <div class="flex items-center space-x-4"> + <a href="{folder_url}" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" onclick="event.stopPropagation()" title="View folder on GitHub"> + {github_icon} + </a> <div class="chevron" id="chevron-{dirname}">{chevron_down}</div> </div> </div> @@ -69,25 +73,43 @@ def generate_file_list(): items.append(folder_header) - # Add files in the directory for filename in dir_files: encoded_filename = filename.replace(' ', '%20') + file_path = os.path.join(dirname, filename) file_url = f"{REPO_URL}/blob/main/{encoded_dirname}/{encoded_filename}" + + file_content = "" + try: + with open(file_path, 'r', encoding='utf-8', errors='ignore') as f: + file_content = f.read() + except Exception as e: + file_content = f"Error reading file: {e}" + + escaped_content = html.escape(file_content) + code_block_id = f"code-{dirname}-{filename}".replace('.', '_').replace(' ', '_') + lang_class = get_language_class(filename) + file_item = f''' <li> - <a href="{file_url}" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> {file_icon} <span class="text-gray-700">{filename}</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="{file_url}" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + {github_icon} + </a> + <button onclick="showCode('{code_block_id}', '{filename}')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="{code_block_id}" class="hidden" data-github-url="{file_url}"> + <pre><code class="language-{lang_class}">{escaped_content}</code></pre> + </div> </li>''' items.append(file_item) - # Close folder section items.append(' </ul>\n </div>\n </li>') except (OSError, PermissionError): - # If we can't access the directory, just show it as a simple folder simple_folder = f''' <li> <a href="{folder_url}" target="_blank" class="flex items-center p-4 bg-gray-100 hover:bg-blue-100 rounded-lg transition-colors duration-200"> @@ -98,35 +120,61 @@ def generate_file_list(): </li>''' items.append(simple_folder) - # Add top-level files (if any) top_level_files = [f for f in files if f not in EXCLUDED_FILES] for filename in top_level_files: encoded_filename = filename.replace(' ', '%20') url = f"{REPO_URL}/blob/main/{encoded_filename}" - items.append(f'<li><a href="{url}" target="_blank" class="flex items-center p-4 bg-gray-100 hover:bg-green-100 rounded-lg transition-colors duration-200">{file_icon}<span class="font-medium text-gray-800">{filename}</span><span class="ml-auto text-green-500 font-semibold text-sm">View on GitHub &rarr;</span></a></li>') + + file_content = "" + try: + with open(filename, 'r', encoding='utf-8', errors='ignore') as f: + file_content = f.read() + except Exception as e: + file_content = f"Error reading file: {e}" + + escaped_content = html.escape(file_content) + code_block_id = f"code-root-{filename}".replace('.', '_').replace(' ', '_') + lang_class = get_language_class(filename) + + items.append(f''' + <li class="border rounded-lg overflow-hidden"> + <div class="flex items-center p-4 bg-gray-100 hover:bg-green-100 rounded-lg transition-colors duration-200"> + {file_icon} + <span class="font-medium text-gray-800">{filename}</span> + <div class="ml-auto flex items-center space-x-4"> + <a href="{url}" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + {github_icon} + </a> + <button onclick="showCode('{code_block_id}', '{filename}')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="{code_block_id}" class="hidden bg-white p-4 border-t" data-github-url="{url}"> + <pre><code class="language-{lang_class}">{escaped_content}</code></pre> + </div> + </li>''') - break # Only process the top level + break return "\n".join(items) def main(): """Generates the final index.html from a template.""" - # Get the directory of this script script_dir = os.path.dirname(os.path.abspath(__file__)) - repo_root = os.path.dirname(script_dir) # Go up one level from docs/ + # Assuming the script is run from a sub-directory like 'docs' + repo_root = os.path.abspath(os.path.join(script_dir, '..')) - # Change to repo root directory for file walking original_cwd = os.getcwd() - os.chdir(repo_root) + # It's better to construct paths from the repo_root than to change directory try: - # Define paths relative to the script location + # Construct paths relative to the repo root + os.chdir(repo_root) template_path = os.path.join(script_dir, 'template.html') output_path = os.path.join(script_dir, 'index.html') try: - with open(template_path, 'r') as f: + with open(template_path, 'r', encoding='utf-8') as f: template = f.read() except FileNotFoundError: print(f"Error: The template file was not found at {template_path}") @@ -134,16 +182,14 @@ def main(): file_list_html = generate_file_list() - # Replace the placeholder with our generated list final_html = template.replace('<!--FILE_LIST_PLACEHOLDER-->', file_list_html) - with open(output_path, 'w') as f: + with open(output_path, 'w', encoding='utf-8') as f: f.write(final_html) - print(f"{output_path} generated successfully.") + print(f"index.html generated successfully in '{output_path}'.") finally: - # Always change back to original directory os.chdir(original_cwd) if __name__ == "__main__": diff --git a/docs/index.html b/docs/index.html @@ -1,32 +1,69 @@ <!DOCTYPE html> <html lang="en"> -<head> - <meta charset="UTF-8"> - <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <head> + <meta charset="UTF-8" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>BSc Repository File Index</title> <script src="https://cdn.tailwindcss.com"></script> - <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet"> + <link + href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" + rel="stylesheet" + /> + <link + rel="stylesheet" + href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/github-dark.min.css" + /> + <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script> + <style> - body { - font-family: 'Inter', sans-serif; + body { + font-family: "Inter", sans-serif; + } + .chevron.rotated { + transform: rotate(180deg); + } + #modal-body pre { + max-height: 70vh; + } + /* Animation for success feedback */ + .btn-success-pulse { + background-color: #10b981 !important; /* Tailwind green-500 */ + box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5); /* green-500 with opacity */ + animation: pulse-success 0.5s ease-out; + } + @keyframes pulse-success { + 0% { + box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5); + } + 50% { + box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); } - .chevron.rotated { - transform: rotate(180deg); + 100% { + box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); } + } </style> -</head> -<body class="bg-gray-50"> + </head> + <body class="bg-gray-100"> <div class="container mx-auto px-4 py-8 md:py-16"> - <div class="max-w-4xl mx-auto bg-white rounded-2xl shadow-lg overflow-hidden"> - <div class="p-8"> - <div class="text-center mb-8"> - <h1 class="text-3xl md:text-4xl font-bold text-gray-800">BSc Repository Contents</h1> - <p class="text-gray-500 mt-2">A quick navigation guide to the files in the repository.</p> - </div> - <div class="space-y-4"> - <h2 class="text-lg font-semibold text-gray-700 border-b pb-2">Files and Folders</h2> - <ul class="space-y-3"> - + <div + class="max-w-4xl mx-auto bg-white rounded-2xl shadow-lg overflow-hidden" + > + <div class="p-8"> + <div class="text-center mb-8"> + <h1 class="text-3xl md:text-4xl font-bold text-gray-800"> + BSc Repository Contents + </h1> + <p class="text-gray-500 mt-2"> + A quick navigation guide to the files in the repository. + </p> + </div> + <div class="space-y-4"> + <h2 class="text-lg font-semibold text-gray-700 border-b pb-2"> + Files and Folders + </h2> + <ul class="space-y-3"> + <li class="border rounded-lg overflow-hidden"> <div class="folder-header bg-gray-100 p-4 cursor-pointer hover:bg-blue-100 transition-colors duration-200" onclick="toggleFolder('c')"> <div class="flex items-center justify-between"> @@ -35,8 +72,10 @@ <span class="font-medium text-gray-800">c</span> <span class="ml-2 text-sm text-gray-500">(7 files)</span> </div> - <div class="flex items-center space-x-2"> - <a href="https://github.com/notamitgamer/bsc/tree/main/c" target="_blank" class="text-blue-500 font-semibold text-sm hover:underline" onclick="event.stopPropagation()">GitHub</a> + <div class="flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/tree/main/c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" onclick="event.stopPropagation()" title="View folder on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> <div class="chevron" id="chevron-c"><svg class="w-5 h-5 text-gray-500 transition-transform duration-200" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"></path></svg></div> </div> </div> @@ -45,59 +84,311 @@ <ul class="divide-y divide-gray-200"> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/c/1.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">1.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/c/1.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-c-1_c', '1.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-c-1_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/c/1.c"> + <pre><code class="language-c">// Write a program (WAP) to print the sum and product of digits of an integer. +// Author - Amit Dutta, Date - 13th SEP, 2025 + +#include&lt;stdio.h&gt; + +int main() { + int inp, result_sum = 0, result_product = 1, temp; + printf(&quot;Please enter the number : &quot;); + scanf(&quot;%d&quot;,&amp;inp); + printf(&quot;\n&quot;); + + if (inp &lt; 0) { + printf(&quot;\nPlease enter a valid non negetive integer.&quot;); + return 1; + } + + temp = inp; + while (temp != 0 ) { + result_sum = result_sum + (temp % 10); + result_product = result_product * (temp % 10); + temp = temp / 10; + } + + printf(&quot;\nSum of the digits of the input number &#x27;%d&#x27; is : %d&quot; + &quot;\nProduct of the digits of the input number &#x27;%d&#x27; is : %d&quot;, + inp, result_sum, inp, result_product); + return 0; +} + +</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/c/2.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">2.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/c/2.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-c-2_c', '2.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-c-2_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/c/2.c"> + <pre><code class="language-c">//WAP to reverse a non-negative integer. +// Author - Amit Dutta, Date - 13th SEP, 2025 + +#include&lt;stdio.h&gt; + +int main() { + int inp, result = 0, temp; + printf(&quot;PLease enter the number you want to reverse : &quot;); + scanf(&quot;%d&quot;,&amp;inp); + printf(&quot;\n&quot;); + + if (inp &lt; 0) { + printf(&quot;\nPlease enter a non negetive integer.&quot;); + return 1; + } + + temp = inp; + while ( temp != 0) { + result = (result * 10) + (temp % 10); + temp = temp / 10; + } + + printf(&quot;\nReverse of the input &#x27;%d&#x27; is : %d&quot;, inp, result); + return 0; +} + +</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/c/3.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">3.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/c/3.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-c-3_c', '3.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-c-3_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/c/3.c"> + <pre><code class="language-c">// WAP to compute the sum of the first n terms of the following series S =1+1/2+1/3+1/4+...... +// Author - Amit Dutta, Date - 13th SEP, 2025 + +#include&lt;stdio.h&gt; + +int main() { + int n, i; + float result = 0; + printf(&quot;Please enter the value for &#x27;n&#x27; : &quot;); + scanf(&quot;%d&quot;, &amp;n); + printf(&quot;\n&quot;); + + if (n &lt;= 0) { + printf(&quot;\nPlease enter a positve number greater than ZERO.&quot;); + return 1; + } + + for (i = 1; i &lt;= n; i++) { + result = result + (1.0 / i); + } + + printf(&quot;\nSum of the first %d terms of the following series S =1+1/2+1/3+1/4+...... is : %f&quot;,n,result); + return 0; +} +</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/c/4.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">4.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/c/4.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-c-4_c', '4.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-c-4_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/c/4.c"> + <pre><code class="language-c">//WAP to compute the sum of the first n terms of the following series,S =1-2+3-4+5...... +// Author - Amit Dutta, Date - 13th SEP, 2025 + +#include&lt;stdio.h&gt; + +int main() { + int n, result = 0, temp, i; + printf(&quot;Please enter the value for &#x27;n&#x27; for this series &#x27;s = 1-2+3-4+5-....&#x27;: &quot;); + scanf(&quot;%d&quot;,&amp;n); + printf(&quot;\n&quot;); + + if (n &lt;= 0) { + printf(&quot;\nPlease enter a positive integer.&quot;); + return 1; + } + + for (i = 1; i&lt;= n; i++) { + if (i % 2 == 0) { + result = result - i; + } + else { + result = result + i; + } + } + + printf(&quot;\nAns : %d&quot;, result); +} +</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/c/5.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">5.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/c/5.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-c-5_c', '5.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-c-5_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/c/5.c"> + <pre><code class="language-c">/*Write a function to find whether a given no. is prime or not. +Use the same to generate the prime numbers less than 100.*/ +// Author - Amit Dutta, Date - 13th SEP, 2025 + +#include&lt;stdio.h&gt; + +int isPrime(int inp) { + int i, is_prime = 1; + + if (inp &lt; 2) is_prime = 0; + + for (i = 2; i &lt;= inp / 2; i++) if (inp % i == 0) { + is_prime = 0; + break; + } + + return is_prime; +} + + +int main() { + int inp, i; + printf(&quot;Enter the number you want to check : &quot;); + scanf(&quot;%d&quot;,&amp;inp); + printf(&quot;\n&quot;); + + if (isPrime(inp)) printf(&quot;\nGiven input &#x27;%d&#x27; is a Prime Number.&quot;,inp); + else printf(&quot;\nGiven input &#x27;%d&#x27; is not a Prime Number.&quot;,inp); + + printf (&quot;\nSeries of prime number upto 100 : &quot;); + for (i = 2; i &lt; 100; i++) if (isPrime(i)) printf(&quot; %d&quot;,i); + + return 0; +} +</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/c/6.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">6.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/c/6.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-c-6_c', '6.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-c-6_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/c/6.c"> + <pre><code class="language-c">/*Write a function that checks whether a given string is Palindrome or not. +Use this function to find whether the string entered by the user is Palindrome or not.*/ +// Author - Amit Dutta, Date - 13th SEP, 2025 + +#include&lt;stdio.h&gt; +#include&lt;string.h&gt; + +int isPalindrome(char inp[]) { + int len = strlen(inp); + int i = 0; //starting point + int j = len - 1; //end point + + while (i &lt; j) { + if (inp[i] != inp[j]) { + return 0; + } + i++; + j--; + } + + return 1; +} + +int main() { + char inp[20]; + printf(&quot;Enter the number : &quot;); + scanf(&quot;%s&quot;,inp); + if (isPalindrome(inp)) printf(&quot;\n\nInput &#x27;%s&#x27; is a Palindrome number.&quot;, inp); + else printf(&quot;\n\nInput &#x27;%s&#x27; is not a Palindrome number.&quot;, inp); + return 0; +} +</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/c/7.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">7.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/c/7.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-c-7_c', '7.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-c-7_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/c/7.c"> + <pre><code class="language-c">// WAP to compute the factors of a given number +// Author - Amit Dutta, Date - 13th SEP, 2025 + +#include&lt;stdio.h&gt; +#include&lt;stdlib.h&gt; + +int main() { + int inp, num, i; + printf(&quot;Please enter the number to get the factors from it : &quot;); + scanf(&quot;%d&quot;, &amp;inp); + + num = abs(inp); + + if (num == 0) { + printf(&quot;\n\n0 has infinitely many factors (all integers).&quot;); + return 1; + } + + printf(&quot;\n\nThe factors of &#x27; %d &#x27; is :- &quot;, inp); + printf(&quot;\nPositive : &quot;); + for (i = 1; i &lt;= num ; i++) if (num % i == 0) printf(&quot; %d&quot;, i); + printf(&quot;\nNegative : &quot;); + for (i = 1; i &lt;= num ; i++) if (num % i == 0) printf(&quot; %d&quot;, -i); + return 0; +} +</code></pre> + </div> </li> </ul> </div> @@ -111,8 +402,10 @@ <span class="font-medium text-gray-800">letusc</span> <span class="ml-2 text-sm text-gray-500">(42 files)</span> </div> - <div class="flex items-center space-x-2"> - <a href="https://github.com/notamitgamer/bsc/tree/main/letusc" target="_blank" class="text-blue-500 font-semibold text-sm hover:underline" onclick="event.stopPropagation()">GitHub</a> + <div class="flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/tree/main/letusc" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" onclick="event.stopPropagation()" title="View folder on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> <div class="chevron" id="chevron-letusc"><svg class="w-5 h-5 text-gray-500 transition-transform duration-200" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"></path></svg></div> </div> </div> @@ -121,339 +414,2050 @@ <ul class="divide-y divide-gray-200"> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc001.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">luc001.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc001.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-letusc-luc001_c', 'luc001.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-letusc-luc001_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/letusc/luc001.c"> + <pre><code class="language-c">/* Temperature of a city in fahrenheit degrees is input through +the keyboard. WAP to convert this temperature into Centigrade +degrees. */ +/* Author - Amit Dutta, Date - 13 sep, 2025 */ +/* Chapter 1; Page 19; Question NO.: F(a) */ + +#include&lt;stdio.h&gt; +int main() { + float f, c; + printf(&quot;Enter the temperature of city in Fahrenheit : &quot;); + scanf(&quot;%f&quot;, &amp;f); + // formula (F - 32) 5/9 + c = ((f - 32) * 5) / 9; + printf(&quot;\nTemperature in centigrade : %f&quot;, c); + return 0; +} +</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc002.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">luc002.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc002.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-letusc-luc002_c', 'luc002.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-letusc-luc002_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/letusc/luc002.c"> + <pre><code class="language-c">/* The length and breadth of a rectangle and radius of a circle +are input through the keyboard. Write a program to calculate the +area and perimeter of the rectangle, and the area and circumference +of the circle. */ +/* Author - Amit Dutta, Date - 16th SEP, 2025 */ +/* Let Us C; Page - 19; Chap- 1; QNo.: F(b) */ + +#include &lt;stdio.h&gt; +#include &lt;math.h&gt; +int main() +{ + double len, bre, r, area_r, per, area_c, cir; + printf(&quot;Enter the length and breadth of the rectangle : &quot;); + scanf(&quot;%lf %lf&quot;, &amp;len, &amp;bre); + printf(&quot;Enter the Radius of the circle : &quot;); + scanf(&quot;%lf&quot;, &amp;r); + area_r = len * bre; + per = 2 * (len + bre); + area_c = M_PI * r * r; + cir = 2 * M_PI * r; + printf(&quot;\nArea of Rectangle : %lf&quot; + &quot;\nPerimeter of Rectangle : %lf&quot; + &quot;\nArea of Circle : %lf&quot; + &quot;\nCircumference of Circle : %lf&quot;, + area_r, per, area_c, cir); + return 0; +} +</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc003.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">luc003.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc003.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-letusc-luc003_c', 'luc003.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-letusc-luc003_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/letusc/luc003.c"> + <pre><code class="language-c">/* Paper of size AO has dimensions 1189 mm x 841 mm. +Each subsequent size A(n) is defined as A(n-1) cut in +half, parallel to its shorter sides. Thus, paper of +size A1 would have dimensions 841 mm x 594 mm. Write +a program to calculate and print paper sizes A0,� +A1,�A2,�...�A8. */ +/* Author - Amit Dutta, Date - 16th SEP, 2025 */ +/* Let Us C; Page - 19; Chap- 1; QNo.: F(c) */ + +#include&lt;stdio.h&gt; +#include&lt;math.h&gt; +int main() { + double s_long = 1189.0, s_short = 841.0, temp; + int i; + printf(&quot;A0 Dimension : %g mm x %g mm&quot;, floor(s_long), floor(s_short)); + for (i = 1; i &lt;= 8; i++) { + temp = s_long; + s_long = s_short; + s_short = temp / 2; + printf(&quot;\nA%d Dimension : %g mm x %g mm&quot;, i, floor(s_long), floor(s_short)); + } + return 0; +} +</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc004.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">luc004.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc004.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-letusc-luc004_c', 'luc004.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-letusc-luc004_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/letusc/luc004.c"> + <pre><code class="language-c">/* If a five digit number is input through the keyboard, +write a program to calculate the sum of it&#x27;s digit. +(Hint : Use the modulus operator %) */ +/* Author - Amit Dutta, Date - 28th SEP, 2025 */ +/* Let Us C; Page - 37; Chap- 2; QNo.: G(a) */ + +#include &lt;stdio.h&gt; +int main() +{ + int inp, result = 0, i, temp; + printf(&quot;Enter a five digit number : &quot;); + scanf(&quot;%d&quot;, &amp;inp); + if (inp &lt; 10000 || inp &gt; 99999) + { + printf(&quot;\nPlease enter a valid five digit number.&quot;); + return 1; + } + temp = inp; + for (i = 1; i &lt;= 5; i++) + { + result = result + (inp % 10); + inp = inp / 10; + } + printf(&quot;\nSum of the digit &#x27;%d&#x27; is : %d&quot;, temp, result); + return 0; +}</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc005.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">luc005.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc005.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-letusc-luc005_c', 'luc005.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-letusc-luc005_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/letusc/luc005.c"> + <pre><code class="language-c">/* Write a program to recive Cartesian +co-ordinates (x, y) of a point and convert +them into Polar co-ordinates (r, phi) + Hint : r = sqrt (x^2 + y^2) and phi = tan^-1 (y/x) */ +/* Author - Amit Dutta, Date - 28th SEP, 2025 */ +/* Let Us C; Page - 37; Chap- 2; QNo.: G(b) */ + +#include &lt;stdio.h&gt; +#include &lt;math.h&gt; +int main() +{ + double x, y, r, phi; + printf(&quot;Enter the Cartesian Co-Ordinates in this format &#x27;x, y&#x27; : &quot;); + scanf(&quot;%lf, %lf&quot;, &amp;x, &amp;y); + r = sqrt(pow(x, 2) + pow(y, 2)); + phi = atan2(y, x); + printf(&quot;\nPolar Co-Ordinates are : (%g, %g Rad)&quot;, r, phi); + return 0; +}</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc006.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">luc006.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc006.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-letusc-luc006_c', 'luc006.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-letusc-luc006_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/letusc/luc006.c"> + <pre><code class="language-c">/* Write a program to receive values of latitude (L1, L2) and longitude +(G1, G2), in degrees, of two places on the earth and output the distance +(D) between them in nautical miles. The formula for distance in nautical +miles is : + D = 3963 cos^-1(sin L1 sin L2 + cos L1 cos L2 * cos(G2 - G1)) +*/ +/* Author - Amit Dutta, Date - 29th SEP, 2025 */ +/* Let Us C, Chap - 2, Page - 37, Qn no.: G(c) */ + +#include &lt;stdio.h&gt; +#include &lt;math.h&gt; +int main() +{ + double l1, l2, g1, g2, d; + printf(&quot;Enter the Latitude in &#x27;L1, L2&#x27; format : &quot;); + scanf(&quot;%lf, %lf&quot;, &amp;l1, &amp;l2); + printf(&quot;Enter the Longitude in &#x27;G1, G2&#x27; format : &quot;); + scanf(&quot;%lf, %lf&quot;, &amp;g1, &amp;g2); + // Converting degree to radian because function from math.h use radian not degree + l1 = l1 * (M_PI / 180); + l2 = l2 * (M_PI / 180); + g1 = g1 * (M_PI / 180); + g2 = g2 * (M_PI / 180); + d = 3963 * acos(sin(l1) * sin(l2) + cos(l1) * cos(l2) * cos(g2 - g1)); + printf(&quot;Distance in nautical miles : %g&quot;, d); + return 0; +}</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc007.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">luc007.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc007.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-letusc-luc007_c', 'luc007.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-letusc-luc007_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/letusc/luc007.c"> + <pre><code class="language-c">/* Wind-chill factor is the felt air temperature on exposed skin due to wind. +The wind-chill temperature is always lower than the air temperature, and is +calculated as per the following formula. + wcf = 35.74 + 0.6215t + (0.4275t - 35.75) * v^0.16 +Where t is temperature and v is wind velocity. Write a program to receive +values of t and v and calcualate wind-chill factor (wcf). */ +/* Author - Amit Dutta, Date - 30th SEP, 2025 */ +/* Let Us C, Chap - 2, Page - 37, Qn No.: G(d) */ + +#include &lt;stdio.h&gt; +#include &lt;math.h&gt; +int main() +{ + double t, v, wcf; + printf(&quot;Enter the temperature and velociy of the wind : &quot;); + scanf(&quot;%lf %lf&quot;, &amp;t, &amp;v); + wcf = 35.74 + (0.6215 * t) + (((0.4275 * t) - 35.75) * pow(v, 0.16)); + printf(&quot;\nWind-chill factor (wcf) : %g&quot;, wcf); + return 0; +}</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc008.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">luc008.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc008.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-letusc-luc008_c', 'luc008.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-letusc-luc008_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/letusc/luc008.c"> + <pre><code class="language-c">/* If value of an angle is input through the keyboard, +write a program to print all its trigonometric ratios. */ +/* Author - Amit Dutta, Date - 30th SEP, 2025 */ +/* Let Us C, Chap - 2, Page - 37, Qn No.: G(e) */ + +#include &lt;stdio.h&gt; +#include &lt;math.h&gt; +int main() +{ + double inp, rsin, rcos, rtan, rcosec, rsec, rcot; + printf(&quot;Enter the Angle in degree : &quot;); + scanf(&quot;%lf&quot;, &amp;inp); + inp = inp * (M_PI / 180); //changing degree to radian + rsin = sin(inp); + rcos = cos(inp); + rtan = tan(inp); + rcosec = 1 / rsin; + rsec = 1 / rcos; + rcot = 1 / rtan; + printf(&quot;\nTrigonometric ratios :-&quot; + &quot;\nsin = %g &quot; + &quot;\ncos = %g&quot; + &quot;\ntan = %g&quot; + &quot;\ncosec = %g&quot; + &quot;\nsec = %g&quot; + &quot;\ncot = %g&quot;, + rsin, rcos, rtan, rcosec, rsec, rcot); + return 0; +}</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc009.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">luc009.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc009.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-letusc-luc009_c', 'luc009.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-letusc-luc009_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/letusc/luc009.c"> + <pre><code class="language-c">/* Two numbers are input through the keyboard into two locations +C and D. Write a program to interchange the contents of C and D. */ +/* Author - Amit Dutta, Date - 30th SEP, 2025 */ +/* Let Us C, Chap - 2, Page - 37, Qn No.: G(d) */ + +#include &lt;stdio.h&gt; +int main() +{ + double a, b; + printf(&quot;Enter the two number A and B : &quot;); + scanf(&quot;%lf %lf&quot;, &amp;a, &amp;b); + printf(&quot;\nBefore Interchange : &quot;); + printf(&quot;\nA = %g (Memory location = %p)&quot;, a, &amp;a); + printf(&quot;\nB = %g (Memory location = %p)&quot;, b, &amp;b); + a = a + b; + b = a - b; + a = a - b; + printf(&quot;\nAfter Interchange :&quot;); + printf(&quot;\nA = %g (Memory location = %p)&quot;, a, &amp;a); + printf(&quot;\nB = %g (Memory location = %p)&quot;, b, &amp;b); + return 0; +}</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc010.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">luc010.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc010.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-letusc-luc010_c', 'luc010.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-letusc-luc010_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/letusc/luc010.c"> + <pre><code class="language-c">/* A five-digit number is entered through the keyboard. Write a program +to obtain the reversed number and to etermine whether the original and reversed +numbers are equal or not. */ +/* Author - Amit Dutta, Date - 1st OCT, 2025 */ +/* Let Us C, Chap - 3, Page - 53, Qn No.: f(a) */ + +#include &lt;stdio.h&gt; +int main() +{ + int num, rev, temp, i; + printf(&quot;Please enter the number : &quot;); + scanf(&quot;%d&quot;, &amp;num); + if (num &lt; 10000 || num &gt; 99999) + { + printf(&quot;\nPlease enter a five digit number.&quot;); + return 1; + } + temp = num; + for (i = 1; i &lt;= 5; i++) + { + rev = (rev * 10) + num % 10; + num = num / 10; + } + printf(&quot;\nReverse of the Input number : %d&quot;, rev); + if (rev == temp) + printf(&quot;\nOriginal and reversed numbers are equal.&quot;); + else + printf(&quot;\nOrigianl and reversed numbers are not equal.&quot;); + return 0; +}</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc011.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">luc011.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc011.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-letusc-luc011_c', 'luc011.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-letusc-luc011_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/letusc/luc011.c"> + <pre><code class="language-c">/* If ages of Ram, Shyam and Ajay are input through the keyboard, +write a program to determine the youngest of the three. */ +/* Author - Amit Dutta, Date - 1st OCT, 2025 */ +/* Let Us C, Chap- 3, Page - 53, Qn No.: f(b) */ + +#include &lt;stdio.h&gt; +int main() +{ + int ram, shyam, ajay; + printf(&quot;Please enter the age of Ram, Shyam and Ajay : &quot;); + scanf(&quot;%d %d %d&quot;, &amp;ram, &amp;shyam, &amp;ajay); + if (ram == shyam || ram == ajay || shyam == ajay) + printf(&quot;\nThree must have different age.&quot;); + if (ram &lt; shyam &amp;&amp; ram &lt; ajay) + printf(&quot;\nRam is the youngest. Age : %d&quot;, ram); + if (shyam &lt; ram &amp;&amp; shyam &lt; ajay) + printf(&quot;\nShyam is the youngest. Age : %d&quot;, shyam); + if (ajay &lt; ram &amp;&amp; ajay &lt; shyam) + printf(&quot;\nAjay is the youngest. Age : %d&quot;, ajay); + return 0; +}</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc012.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">luc012.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc012.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-letusc-luc012_c', 'luc012.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-letusc-luc012_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/letusc/luc012.c"> + <pre><code class="language-c">/* Write a program to check whether a triangle is valid or not, +if three angles of the triangle are entered through the keyboard. +A triangle is valid if the sum of all the three angles is equal to 180 degrees. */ +/* Author - Amit Dutta, Date - 1st OCT, 2025 */ +/* Let Us C, Chap- 3, Page - 53, Qn No.: f(c) */ + +#include &lt;stdio.h&gt; +int main() +{ + double angle1, angle2, angle3, sum; + printf(&quot;Enter the value of the three angle of the triangle : &quot;); + scanf(&quot;%lf %lf %lf&quot;, &amp;angle1, &amp;angle2, &amp;angle3); + sum = angle1 + angle2 + angle3; + if (sum == 180.0) + printf(&quot;\nThis Triangle is a valid one.&quot;); + else + printf(&quot;\nThis Triangle is not valid. Sum of the angles : %g&quot;, sum); + return 0; +}</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc013.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">luc013.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc013.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-letusc-luc013_c', 'luc013.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-letusc-luc013_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/letusc/luc013.c"> + <pre><code class="language-c">/* Write a program to find the absolute value +of a number entered through the keyboard. */ +/* Author - Amit Dutta, Date - 1st OCT, 2025 */ +/* Let Us C, Chap- 3, Page - 53, Qn No.: f(d) */ + +#include &lt;stdio.h&gt; +#include &lt;math.h&gt; +int main() +{ + double num; + printf(&quot;Enter the number : &quot;); + scanf(&quot;%lf&quot;, &amp;num); + num = abs(num); + printf(&quot;\nAbsolute value of the input is : %g&quot;, num); + return 0; +}</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc014.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">luc014.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc014.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-letusc-luc014_c', 'luc014.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-letusc-luc014_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/letusc/luc014.c"> + <pre><code class="language-c">/* Given the length and breadth of a rectangle, write a program to find +whether the area of the rectangle is greater than it&#x27;s perimeter. +For example, the area of the rectangle with length = 5 and breadth = 4 +is greater than its perimeter. */ +/* Author - Amit Dutta, Date - 1st OCT, 2025 */ +/* Let Us C, Chap- 3, Page - 53, Qn No.: f(e) */ + +#include &lt;stdio.h&gt; +int main() +{ + double len, bre, area, peri; + printf(&quot;Enter the length and breadth of the rectangle : &quot;); + scanf(&quot;%lf %lf&quot;, &amp;len, &amp;bre); + area = len * bre; + peri = 2 * (len + bre); + if (area &gt; peri) + printf(&quot;\nThe area of the rectangle is greater than it&#x27;s perimeter.&quot;); + else if (area &lt; peri) + printf(&quot;\nThe area of the rectangle is lower than it&#x27;s perimeter.&quot;); + else + printf(&quot;\nThe area of the rectangle is same as it&#x27;s perimeter.&quot;); + return 0; +}</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc015.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">luc015.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc015.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-letusc-luc015_c', 'luc015.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-letusc-luc015_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/letusc/luc015.c"> + <pre><code class="language-c">/* Given three points (x1, y1), (x2, y2), and (x3, y3), +write a program to check if the three poins fall on one straight line. */ +/* Author - Amit Dutta, Date - 1st OCT, 2025 */ +/* Let Us C, Chap- 3, Page - 53, Qn No.: f(f) */ + +#include &lt;stdio.h&gt; +#include &lt;math.h&gt; +#define EPSILON 0.0001 +// Define a small tolerance value (EPSILON) for safe floating-point comparison +// This is critical because of minor rounding errors in computer arithmetic. +int main() +{ + double x1, x2, x3, y1, y2, y3, area; + printf(&quot;Enter the point A(x1, y1) : &quot;); + scanf(&quot;%lf %lf&quot;, &amp;x1, &amp;y1); + printf(&quot;Enter the point B(x2, y2) : &quot;); + scanf(&quot;%lf %lf&quot;, &amp;x2, &amp;y2); + printf(&quot;Enter the point C(x3, y3) : &quot;); + scanf(&quot;%lf %lf&quot;, &amp;x3, &amp;y3); + area = 0.5 * ((x1 * (y2 - y3)) + (x2 * (y3 - y1)) + (x3 * (y1 - y2))); + if (fabs(area) &lt; EPSILON) // abs() for integer, fabs() for float, double + printf(&quot;\nA(%g, %g), B(%g, %g) and C(%g, %g) points fall on one straight line.&quot;, x1, y1, x2, y2, x3, y3); + else + printf(&quot;\nA(%g, %g), B(%g, %g) and C(%g, %g) points doesn&#x27;t fall on one straight line.&quot;, x1, y1, x2, y2, x3, y3); + return 0; +}</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc016.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">luc016.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc016.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-letusc-luc016_c', 'luc016.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-letusc-luc016_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/letusc/luc016.c"> + <pre><code class="language-c">/* Given the coordiantes (x, y) of center of a circle and its radius, +write a program that will determine whether a point lies inside the circle, +on the circle or outside the circle. (Hint : Use sqrt() and pow() functions.) */ +/* Author - Amit Dutta, Date - 1st OCT, 2025 */ +/* Let Us C, Chap- 3, Page - 53, Qn No.: f(g) */ + +#include &lt;stdio.h&gt; +#include &lt;math.h&gt; +// Define a small tolerance value (EPSILON) for reliable floating-point comparison +#define EPSILON 0.0001 + +int main() +{ + double h, k; + double R; + double x, y; + double distance_sq; + printf(&quot;Enter the center coordinates (h, k) : &quot;); + scanf(&quot;%lf %lf&quot;, &amp;h, &amp;k); + printf(&quot;Enter the radius (R) : &quot;); + scanf(&quot;%lf&quot;, &amp;R); + printf(&quot;Enter the point P coordinates (x, y) : &quot;); + scanf(&quot;%lf %lf&quot;, &amp;x, &amp;y); + distance_sq = pow(x - h, 2) + pow(y - k, 2); + double radius_sq = R * R; + // Case 1: On the circle (D^2 = R^2) - Use EPSILON for safety! + if (fabs(distance_sq - radius_sq) &lt; EPSILON) + { + printf(&quot;The point P(%g, %g) lies ON THE CIRCLE.\n&quot;, x, y); + } + // Case 2: Inside the circle (D^2 &lt; R^2) + else if (distance_sq &lt; radius_sq) + { + printf(&quot;The point P(%g, %g) lies INSIDE THE CIRCLE.\n&quot;, x, y); + } + // Case 3: Outside the circle (D^2 &gt; R^2) + else + { + printf(&quot;The point P(%g, %g) lies OUTSIDE THE CIRCLE.\n&quot;, x, y); + } + return 0; +}</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc017.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">luc017.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc017.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-letusc-luc017_c', 'luc017.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-letusc-luc017_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/letusc/luc017.c"> + <pre><code class="language-c">/* Given a point (x, y), write a program to find out if it lies on X-axis, Y-axis or origin. */ +/* Author - Amit Dutta, Date - 1st OCT, 2025 */ +/* Let Us C, Chap- 3, Page - 53, Qn No.: f(h) */ + +#include &lt;stdio.h&gt; +#include &lt;math.h&gt; +#define EPSILON 0.00001 + +int main() +{ + double x, y; + printf(&quot;Enter the point P(x, y) : &quot;); + scanf(&quot;%lf %lf&quot;, &amp;x, &amp;y); + if (fabs(x) &lt; EPSILON &amp;&amp; fabs(y) &lt; EPSILON) + printf(&quot;\nPoint P(%g, %g) lies on the origin.&quot;, x, y); + else if (fabs(x) &lt; EPSILON) + printf(&quot;\nPoint P(%g, %g) lies on the Y-Axis.&quot;, x, y); + else if (fabs(y) &lt; EPSILON) + printf(&quot;\nPoint P(%G, %g) lies on the X-Axis.&quot;, x, y); + else + printf(&quot;\nThe point P(%g, %g) lies in a QUADRANT (not on an axis or the origin).&quot;, x, y); + return 0; +}</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc018-logic.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">luc018-logic.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc018-logic.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-letusc-luc018-logic_c', 'luc018-logic.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-letusc-luc018-logic_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/letusc/luc018-logic.c"> + <pre><code class="language-c">/* According to Gregorian calender, it was Monday on the date 01/01/01. +Write a program to find out what is the day on 1st January of any input year. */ +/* Author - Amit Dutta, Date - 1st OCT, 2025 */ +/* Let Us C, Chap- 3, Page - 53, Qn No.: f(i) */ + +#include &lt;stdio.h&gt; + +/** + * @brief Determines if a given year is a leap year. + * * The rule: A year is a leap year if it is divisible by 4, UNLESS it is + * divisible by 100 but NOT by 400. + * * @param year The year to check. + * @return 1 if it is a leap year, 0 otherwise. + */ +int is_leap(int year) { + // Check if divisible by 400 OR (divisible by 4 AND not divisible by 100) + if ((year % 400 == 0) || (year % 4 == 0 &amp;&amp; year % 100 != 0)) { + return 1; + } + return 0; +} + +/** + * @brief Calculates the day of the week for January 1st of the given year. + * * The base date is 01/01/01, which was a Monday (index 1). + * * Day Mapping: 0:Sunday, 1:Monday, 2:Tuesday, 3:Wednesday, 4:Thursday, 5:Friday, 6:Saturday + */ +int main() { + long long year; // Use long long for year input if years far in the future/past are tested + int i; + long long total_days = 0; + int day_index; + + // Day names array for output + const char *day_names[] = {&quot;Sunday&quot;, &quot;Monday&quot;, &quot;Tuesday&quot;, &quot;Wednesday&quot;, &quot;Thursday&quot;, &quot;Friday&quot;, &quot;Saturday&quot;}; + + printf(&quot;Enter the year (e.g., 2025): &quot;); + if (scanf(&quot;%lld&quot;, &amp;year) != 1 || year &lt; 1) { + printf(&quot;Invalid year input. Please enter a positive integer year (&gt;= 1).\n&quot;); + return 1; + } + + // --- Core Logic: Calculate Total Days --- + + // We only need to consider the years that have *passed* before the target year. + // So, we count days from the end of year 0 up to the end of year (year - 1). + int years_passed = year - 1; + + // 1. Calculate the number of leap days up to the end of year (year - 1) + // Formula based on Gregorian calendar rules for years Y-1: + // (Y-1)/4 - (Y-1)/100 + (Y-1)/400 + long long leap_years = years_passed / 4 - years_passed / 100 + years_passed / 400; + + // 2. Total days = (Number of years * 365) + (Number of leap years) + // Note: The loop method (below) is more intuitive but the formula is faster. + // We will use the direct formula for efficiency. + total_days = years_passed * 365 + leap_years; + + // --- Alternate Loop Method (for conceptual simplicity) --- + /* + for (i = 1; i &lt; year; i++) { + total_days += 365; + if (is_leap(i)) { + total_days += 1; // Add 1 for the leap day + } + } + */ + + // --- Determine the Day of the Week --- + + // Since 01/01/01 was Monday (index 1), we use the following setup: + // Index 1 corresponds to Monday. + // The calculation gives the number of days *past* the Monday start (01/01/01). + // The modulo operation gives the remainder (0-6). + + // 0 days elapsed (Year 1): total_days=0. (0 + 1) % 7 = 1 (Monday). Correct. + // 365 days elapsed (Year 2): total_days=365. (365 + 1) % 7 = 2 (Tuesday). Correct. (365 mod 7 = 1, 1+1 = 2) + + day_index = (total_days + 1) % 7; + + // Correct the Day Index to match the array (0:Sun, 1:Mon, ..., 6:Sat) + // The +1 adjusts for the Monday starting point (index 1). + + printf(&quot;\nOn January 1st, %lld, the day was: **%s**.\n&quot;, year, day_names[day_index]); + + return 0; +}</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc018.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">luc018.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc018.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-letusc-luc018_c', 'luc018.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-letusc-luc018_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/letusc/luc018.c"> + <pre><code class="language-c">/* According to Gregorian calender, it was Monday on the date 01/01/01. +if any year is input through the keyboard write a program to find out +what is the day on 1st January of this year. */ +/* Author - Amit Dutta, Date - 1st OCT, 2025 */ +/* Let Us C, Chap- 3, Page - 53, Qn No.: f(i) */ + +#include &lt;stdio.h&gt; + +int is_leap(int year) { + if ((year % 400 == 0) || (year % 4 == 0 &amp;&amp; year % 100 != 0)) { + return 1; + } + return 0; +} + +int main() { + long long year; // long long for year input if years far in the future/past are tested + int i; + long long total_days = 0; + int day_index; + + // Day names array for output + const char *day_names[] = {&quot;Sunday&quot;, &quot;Monday&quot;, &quot;Tuesday&quot;, &quot;Wednesday&quot;, &quot;Thursday&quot;, &quot;Friday&quot;, &quot;Saturday&quot;}; + + printf(&quot;Enter the year (e.g., 2025): &quot;); + if (scanf(&quot;%lld&quot;, &amp;year) != 1 || year &lt; 1) { + printf(&quot;Invalid year input. Please enter a positive integer year (&gt;= 1).\n&quot;); + return 1; + } + int years_passed = year - 1; + long long leap_years = years_passed / 4 - years_passed / 100 + years_passed / 400; + total_days = years_passed * 365 + leap_years; + day_index = (total_days + 1) % 7; + printf(&quot;\nOn January 1st, %lld, the day was: %s.\n&quot;, year, day_names[day_index]); + return 0; +}</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc019.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">luc019.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc019.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-letusc-luc019_c', 'luc019.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-letusc-luc019_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/letusc/luc019.c"> + <pre><code class="language-c">/* If the length of three sides of a triangle are entered through the +keyboard, write a program to check whether the triangle is an isosceles, +an equilateral, a scalene or a right-angled triangle. */ +/* Author - Amit Dutta, Date - 3rd OCT, 2025 */ +/* Let Us C, Chap- 4, Page - 71, Qn No.: D(a) */ + +#include &lt;stdio.h&gt; +#include &lt;math.h&gt; + +#define EPSILON 0.000001 +/* EPSILON is used to compare double values for approximate equality, +mitigating floating-point precision errors. */ + +int main() +{ + double side1, side2, side3; + printf(&quot;Please enter the length of three side of the triangle : &quot;); + scanf(&quot;%lf %lf %lf&quot;, &amp;side1, &amp;side2, &amp;side3); + if (side1 &lt; 1 || side2 &lt; 1 || side3 &lt; 1) + { + printf(&quot;\nLength of a side of triangle should be a positive integer.&quot;); + return 1; + } + if (side1 + side2 &lt; side3 || side1 + side3 &lt; side2 || side2 + side3 &lt; side1) + { + printf(&quot;\nEntered triangle is not VALID.&quot;); + return 1; + } + // isosceles check + if (side1 == side2 || side2 == side3 || side3 == side1) + printf(&quot;\nEntered triangle is a ISOSCELES triangle.&quot;); + else + printf(&quot;\nEntered triangle is NOT a ISOSCELES triangle.&quot;); + // equilateral check + if (side1 == side2 &amp;&amp; side2 == side3) + printf(&quot;\nEntered triangle is a EQUILATERAL triangle.&quot;); + else + printf(&quot;\nEntered triangle is NOT a EQUILATERAL triangle.&quot;); + // scalene check + if (side1 != side2 &amp;&amp; side2 != side3) + printf(&quot;\nEntered triangle is a SCALENE triangle.&quot;); + else + printf(&quot;\nEntered triangle is NOT a SCALENE triangle.&quot;); + // right-angle check + if (fabs(((side1 * side1) + (side2 * side2)) - (side3 * side3)) &lt; EPSILON || + fabs(((side2 * side2) + (side3 * side3)) - (side1 * side1)) &lt; EPSILON || + fabs(((side3 * side3) + (side1 * side1)) - (side2 * side2)) &lt; EPSILON) + printf(&quot;\nEntered triangle is a RIGHT-ANGLED triangle.&quot;); + else + printf(&quot;\nEntered triangle is NOT a RIGHT-ANGLED triangle.&quot;); + return 0; +}</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc020.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">luc020.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc020.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-letusc-luc020_c', 'luc020.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-letusc-luc020_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/letusc/luc020.c"> + <pre><code class="language-c">/* In digital world colors are specified in Red-Green-Blue (RGB) format, +with values of R, G, B varying on an integer scale from 0 to 255. In print +publishing the colors are mentioned in Cyan-Magenta-Yellow-Black (CMYK) format, +with values of C, M, Y, and K varying on a real scale from 0.0 to 1.0. +Write a program that converts RGB color to CMYK color as per the following formulae: + White = Max(Red/255, Green/255, Blue/255) + Cyan = (White-Red/255) / White + Magenta = (White-Green/255) / White + Yellow = (White-Blue/255) / White + Black = 1 - White +Note that if the RGB values are all 0, then the CMY values are all 0 and the K value is 1. */ +/* Author - Amit Dutta, Date - 4th OCT, 2025 */ +/* Let Us C, Chap- 4, Page - 71, Qn No.: D(b) */ + +#include &lt;stdio.h&gt; + +// declaring function +double get_white(double red, double green, double blue) +{ + double max; + max = red / 255; + if (max &lt; (green / 255)) + max = green / 255; + if (max &lt; (blue / 255)) + max = blue / 255; + return max; +} + +int main() +{ + double r, g, b, w, c = 0, m = 0, y = 0, k = 0; + printf(&quot;Enter the RGB color code in &#x27;R G B&#x27; format : &quot;); + scanf(&quot;%lf %lf %lf&quot;, &amp;r, &amp;g, &amp;b); + + // checking for invalid input (negetive input) + if (r &lt; 0 || g &lt; 0 || b &lt; 0) + { + printf(&quot;\nRGB color code can not be a negetive number.&quot;); + return 1; + } + + // checking for invalid input (out of range color code) + if (r &gt; 255 || g &gt; 255 || b &gt; 255) + { + printf(&quot;\nRGB color code can be maximum (255, 255, 255).&quot;); + return 1; + } + + // converting RGB color code to CMYK color code + if (r == 0 &amp;&amp; g == 0 &amp;&amp; b == 0) + k = 1; + else + { + w = get_white(r, g, b); + c = (w - (r / 255)) / w; + m = (w - (g / 255)) / w; + y = (w - (b / 255)) / w; + k = 1 - w; + } + + printf(&quot;\nRGB color (%g, %g, %g) equivalent to CMYK color (%g, %g, %g, %g).&quot;, r, g, b, c, m, y, k); + return 0; +}</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc021.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">luc021.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc021.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-letusc-luc021_c', 'luc021.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-letusc-luc021_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/letusc/luc021.c"> + <pre><code class="language-c">/* A certain grade of steel is graded according to the following conditions: + (i) Hardness must be greater than 50 + (ii) Carbon content must be less than 0.7 + (iii) Tensile strength must be greater than 5600 + +The grades are as follows: + Grade is 10 if all three conditions are met + Grade is 9 if conditions (i) and (ii) are met + Grade is 8 if conditions (ii) and (iii) are met + Grade is 7 if conditions (i) and (iii) are met + Grade is 6 if only one condition is met + Grade is 5 if none of the conditions are met + +Write a program, which will require the user to give values of hardness, +carbon content and tensile strength of the steel under consideration and output +the grade of the steel. */ + +/* Author - Amit Dutta, Date - 4th OCT, 2025 */ +/* Let Us C, Chap- 4, Page - 71, Qn No.: D(c) */ + +#include &lt;stdio.h&gt; +int main() +{ + double hardness, carbon_content, tensile_strength; + printf(&quot;Enter the details of the steel below - \n&quot;); + printf(&quot;1. Hardness : &quot;); + scanf(&quot;%lf&quot;, &amp;hardness); + printf(&quot;2. Carbon Content : &quot;); + scanf(&quot;%lf&quot;, &amp;carbon_content); + printf(&quot;3. Tensile Strength : &quot;); + scanf(&quot;%lf&quot;, &amp;tensile_strength); + + // storing how many conditions are met as boolean result + int condition_met, condition1, condition2, condition3; + condition1 = hardness &gt; 50; + condition2 = carbon_content &lt; 0.7; + condition3 = tensile_strength &gt; 5600; + condition_met = condition1 + condition2 + condition3; + + // now grading according the result + int grade; + if (condition_met == 3) + grade = 10; + else if (condition_met == 2) + { + if (condition1 &amp;&amp; condition2) + grade = 9; + else if (condition2 &amp;&amp; condition3) + grade = 8; + else if (condition1 &amp;&amp; condition3) + grade = 7; + } + else if (condition_met == 1) + grade = 6; + else + grade = 5; + + // printing the result + printf(&quot;\n------------- Result -------------&quot;); + printf(&quot;\n1. Hardness : Condition %s&quot;, condition1 ? &quot;MET&quot; : &quot;DID NOT MET&quot;); + printf(&quot;\n2. Carbon Content : Condition %s&quot;, condition2 ? &quot;MET&quot; : &quot;DID NOT MET&quot;); + printf(&quot;\n3. Tensile Strength : Condition %s&quot;, condition3 ? &quot;MET&quot; : &quot;DID NOT MET&quot;); + printf(&quot;\nTotal Condition Met : %d&quot;, condition_met); + printf(&quot;\n\nGrade : %d\n\n&quot;, grade); + return 0; +} + +/* I did not used this long variable names. I used very short just the first letter of the word. +After writting the whole program, I just renamed the valiables. This is possible in Visual Stdio Code. */</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc022.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">luc022.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc022.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-letusc-luc022_c', 'luc022.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-letusc-luc022_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/letusc/luc022.c"> + <pre><code class="language-c">/* The Body Mass Index (BMI) is defined as ratio of weight of the +person (in Kilograms) to square of the height (in meters). +Write a program that receives weight and height, calculate the BMI, and reports +the BMI catagory as per the following table. + BMI Catagory BMI + Starvation &lt; 15 + Anorexic 15.1 to 17.5 + Underweight 17.6 to 18.5 + Ideal 18.6 to 24.9 + Overweight 25 to 25.9 + Obese 30 to 39.9 + Morbidly Obese &gt;= 40 +*/ +/* Author - Amit Dutta, Date - 4th OCT, 2025 */ +/* Let Us C, Chap- 4, Page - 72, Qn No.: D(d) */ + +#include &lt;stdio.h&gt; + +int main() +{ + double weight, height, bmi; + printf(&quot;Enter your Weight (in Kilograms) and Height (in Meters) : &quot;); + scanf(&quot;%lf %lf&quot;, &amp;weight, &amp;height); + bmi = weight / (height * height); + printf(&quot;\nCalculated BMI : %g&quot;, bmi); + if (bmi &lt; 15) + printf(&quot;\nBMI Catagory : Starvation&quot;); + else if (bmi &gt;= 15.1 &amp;&amp; bmi &lt;= 17.5) + printf(&quot;\nBMI Catagory : Anorexic&quot;); + else if (bmi &gt;= 17.6 &amp;&amp; bmi &lt;= 18.5) + printf(&quot;\nBMI Catagory : Underweight&quot;); + else if (bmi &gt;= 18.6 &amp;&amp; bmi &lt;= 24.9) + printf(&quot;\nBMI Catagory : Ideal&quot;); + else if (bmi &gt;= 25 &amp;&amp; bmi &lt;= 25.9) + printf(&quot;\nBMI Catagory : Overweight&quot;); + else if (bmi &gt;= 30 &amp;&amp; bmi &lt;= 39.9) + printf(&quot;\nBMI Catagory : Obese&quot;); + else if (bmi &gt;= 40) + printf(&quot;\nBMI Catagory : Morbidly Obese&quot;); + else + printf(&quot;\nBMI Catagory : Unclassified&quot;); + return 0; +}</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc023.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">luc023.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc023.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-letusc-luc023_c', 'luc023.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-letusc-luc023_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/letusc/luc023.c"> + <pre><code class="language-c">/* Using conditional operators determine : + (1) Whether the character entered through the keyboard is a + lower case alphabet or not. + (2) Whether a character entered through the keyboard is a special + symbol or not. */ +/* Author - Amit Dutta, Date - 5th OCT, 2025 */ +/* Let Us C, Chap- 4, Page - 72, Qn No.: E(a) */ + +#include &lt;stdio.h&gt; +int main() +{ + char inp; + printf(&quot;Enter the character : &quot;); + scanf(&quot;%c&quot;, &amp;inp); + printf(&quot;\nInput Character &#x27;%c&#x27; is %s a LOWER CASE ALPHABET.&quot;, inp, + (inp &gt;= &#x27;a&#x27; &amp;&amp; inp &lt;= &#x27;z&#x27;) ? &quot;&quot; : &quot;NOT&quot;); + printf(&quot;\nInput Character &#x27;%c&#x27; is %s a SPECIAL SYMBOL.&quot;, inp, + (inp &gt;= &#x27;a&#x27; &amp;&amp; inp &lt;= &#x27;z&#x27; || inp &gt;= &#x27;A&#x27; &amp;&amp; inp &lt;= &#x27;Z&#x27; + || inp &gt;= &#x27;0&#x27; &amp;&amp; inp &lt;= &#x27;9&#x27;) ? &quot;NOT&quot; : &quot;&quot;); + return 0; +}</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc024.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">luc024.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc024.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-letusc-luc024_c', 'luc024.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-letusc-luc024_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/letusc/luc024.c"> + <pre><code class="language-c">/* Write a program using conditional operators to determine whether +a year entered through the keyboard is a leap year or not. */ +/* Author - Amit Dutta, Date - 5th OCT, 2025 */ +/* Let Us C, Chap- 4, Page - 72, Qn No.: E(b) */ + +#include &lt;stdio.h&gt; +int main() +{ + int year; + printf(&quot;Enter the year : &quot;); + scanf(&quot;%d&quot;, &amp;year); + printf(&quot;\nYear %d is %s a Leapyear.&quot;, year, (year % 400 == 0 || year % 4 == 0 &amp;&amp; year % 100 != 0) ? &quot;&quot; : &quot;NOT&quot;); + return 0; +}</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc025.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">luc025.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc025.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-letusc-luc025_c', 'luc025.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-letusc-luc025_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/letusc/luc025.c"> + <pre><code class="language-c">/* Write a program to find the greates of the three numbers entered +through the keyboard. Use conditional operators. */ +/* Author - Amit Dutta, Date - 6th OCT, 2025 */ +/* Let Us C, Chap- 4, Page - 72, Qn No.: E(c) */ + +#include &lt;stdio.h&gt; +int main() +{ + double num1, num2, num3, max; + printf(&quot;Enter three number : &quot;); + scanf(&quot;%lf %lf %lf&quot;, &amp;num1, &amp;num2, &amp;num3); + printf(&quot;\nGreatest of the three number &#x27;%g&#x27;, &#x27;%g&#x27; and &#x27;%g&#x27; is : &#x27;%g&#x27;&quot;, num1, num2, num3, + (num1 &gt; num2 &amp;&amp; num1 &gt; num3) ? num1 : ((num2 &gt; num1 &amp;&amp; num2 &gt; num3) ? num2 : num3)); + return 0; +}</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc026.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">luc026.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc026.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-letusc-luc026_c', 'luc026.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-letusc-luc026_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/letusc/luc026.c"> + <pre><code class="language-c">/* Write a program to recieve value of an angle in degreesand check +whether sum of squares of sine and cosine of this angle is equal to 1. */ +/* Author - Amit Dutta, Date - 6th OCT, 2025 */ +/* Let Us C, Chap- 4, Page - 73, Qn No.: E(d) */ + +#include &lt;stdio.h&gt; +#include &lt;math.h&gt; +#define EPSILON 0.0000001 + +int main() +{ + double angle, result; + printf(&quot;Enter the angle value in degree : &quot;); + // checking if the input is other than number. + if(scanf(&quot;%lf&quot;, &amp;angle) != 1) { + printf(&quot;\nPlease enter a number.&quot;); + return 1; + } + angle = angle * (M_PI / 180); // converting degree to radian + result = pow(sin(angle), 2) + pow(cos(angle), 2); + (fabs(result - 1.0) &lt; EPSILON) ? + printf(&quot;\nsum of squares of sine and cosine of this angle is equal to 1.&quot;) : + printf(&quot;\nsum of squares of sine and cosine of this angle is NOT equal to 1.&quot;); + return 0; +}</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc027.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">luc027.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc027.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-letusc-luc027_c', 'luc027.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-letusc-luc027_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/letusc/luc027.c"> + <pre><code class="language-c">/* Rewrite the folowing program using conditional operations + #include&lt;stdio.h&gt; + int main() + { + float sal; + printf(&quot;Enter the salary&quot;); + scanf(&quot;%f&quot;, &amp;sal); + if(sal &gt;= 25000 &amp;&amp; sal &lt;= 40000) + printf(&quot;Manager\n&quot;); + else + if(sal &gt;= 15000 &amp;&amp; sal &lt; 25000) + printf(&quot;Accountant\n&quot;); + else + printf(&quot;Clerk\n&quot;); + return 0; + } +*/ +/* Author - Amit Dutta, Date - 6th OCT, 2025 */ +/* Let Us C, Chap- 4, Page - 73, Qn No.: E(e) */ + +#include &lt;stdio.h&gt; +int main() +{ + float sal; + printf(&quot;Enter the salary&quot;); + scanf(&quot;%f&quot;, &amp;sal); + (sal &gt;= 25000 &amp;&amp; sal &lt;= 40000) ? printf(&quot;Manager\n&quot;) : + ((sal &gt;= 15000 &amp;&amp; sal &lt; 25000) ? printf(&quot;Accountant\n&quot;) : printf(&quot;Clerk\n&quot;)); + return 0; +}</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc028.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">luc028.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc028.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-letusc-luc028_c', 'luc028.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-letusc-luc028_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/letusc/luc028.c"> + <pre><code class="language-c">/* Write a program to print all the ASCII values and their equivalent +characters using a while loop. The ASCII may vary from 0 to 255. */ +/* Author - Amit Dutta, Date - 7th OCT, 2025 */ +/* Let Us C, Chap- 5, Page - 87, Qn No.: B(a) */ + +#include &lt;stdio.h&gt; +int main() +{ + int i = 0; + printf(&quot;ASCII Value\tCharacter&quot;); + printf(&quot;\n-----------\t---------\n&quot;); + while (i &lt;= 255) + { + printf(&quot;%d.\t%c\n\n&quot;, i, i); + i++; + } + return 0; +}</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc029.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">luc029.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc029.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-letusc-luc029_c', 'luc029.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-letusc-luc029_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/letusc/luc029.c"> + <pre><code class="language-c">/* Write a program to print out all Armstrong numbers between 100 +and 500. If sum of cubes of each digit of the number is equal to the +number itself, then the number is called an Armstrong number. For +example, 153 = (1 * 1 * 1) + (5 * 5 * 5) + (3 * 3 * 3) */ +/* Author - Amit Dutta, Date - 7th OCT, 2025 */ +/* Let Us C, Chap- 5, Page - 87, Qn No.: B(b) */ + +#include &lt;stdio.h&gt; +#include &lt;math.h&gt; +int main() +{ + int num = 100, temp1, temp2, res; + printf(&quot;Armstrong numbers between 100 and 500 :&quot;); + while (num &lt;= 500) + { + temp1 = num; + res = 0; + while (temp1 != 0) + { + temp2 = temp1 % 10; + res = res + pow(temp2, 3); + temp1 = temp1 / 10; + } + if (num == res) + printf(&quot; %d&quot;, num); + num++; + } + return 0; +}</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc030.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">luc030.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc030.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-letusc-luc030_c', 'luc030.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-letusc-luc030_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/letusc/luc030.c"> + <pre><code class="language-c">/* Write a program for a matchstick game being played between the +computer and a user. Your program should ensure that the computer +always wins. Rules for the game are as follows : + - There are 21 matchsticks. + - The computer asks the player to pick 1, 2, 3, or 4 matchsticks. + - After the person picks, the computer does its picking. + - Whoever is forced to pick up the last matchstick loses the game. +*/ +/* Author - Amit Dutta, Date - 8th OCT, 2025 */ +/* Let Us C, Chap- 5, Page - 87, Qn No.: B(c) */ + +/* My Plan: The total number of matchsticks is 21. To guarantee a win, +the computer ensures that after its turn, the number of remaining +matchsticks is always a multiple of 5 plus 1 (i.e., 16, 11, 6, 1). +This is achieved by making the sum of the player&#x27;s pick and the +computer&#x27;s pick equal to 5 in each round. This forces the player +to pick the final matchstick. */ + +#include &lt;stdio.h&gt; +int main() +{ + int remaining_matchsticks = 21, player_pick, computer_pick; + printf(&quot; --- Matchstick Game ---\n&quot;); + printf(&quot;Rules: There are 21 matchsticks. You can pick 1, 2, 3, or 4.\n&quot;); + printf(&quot;Whoever is forced to pick the last matchstick loses the game.\n&quot;); + while (remaining_matchsticks &gt; 1) + { + // game start + printf(&quot;\n--------------------------&quot;); + printf(&quot;\nRemaining Matchsticks : %d&quot;, remaining_matchsticks); + + // player pick and checking input is valid or not + printf(&quot;\nYour turn: Pick 1, 2, 3, or 4 matchsticks: &quot;); + if (scanf(&quot;%d&quot;, &amp;player_pick) != 1) + { + printf(&quot;\n\tPlease enter a number.&quot;); + while (getchar() != &#x27;\n&#x27;) + ; + continue; + } + + // checking player pick is valid or not + if (player_pick &lt; 1 || player_pick &gt; 4) + { + printf(&quot;\n\tPlease enter a number among 1, 2, 3 and 4.&quot;); + while (getchar() != &#x27;\n&#x27;) + ; + continue; + } + + if (player_pick &gt; remaining_matchsticks) + { + printf(&quot;\nInvalid choice! There are not enough matchsticks left.&quot;); + while (getchar() != &#x27;\n&#x27;) + ; + continue; + } + + // computer_picks + computer_pick = 5 - player_pick; + printf(&quot;\ncomputer_picks : %d&quot;, computer_pick); + + // remaining matchsticks + remaining_matchsticks = remaining_matchsticks - (player_pick + computer_pick); + } + + // game over + printf(&quot;\n----------------------------------\n&quot;); + printf(&quot;Only 1 matchstick is left.\n&quot;); + printf(&quot;You are forced to pick the last matchstick. You lose!\n&quot;); + printf(&quot;The computer wins.\n&quot;); + + return 0; +}</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc031-logic.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">luc031-logic.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc031-logic.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-letusc-luc031-logic_c', 'luc031-logic.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-letusc-luc031-logic_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/letusc/luc031-logic.c"> + <pre><code class="language-c">/* Write a program to enter numbers till the user wants. At the end it +should display the count of positive, negative and zeros entered. */ +/* Author - Amit Dutta, Date - 8th OCT, 2025 */ +/* Let Us C, Chap- 5, Page - 87, Qn No.: B(d) */ + +/* + * DETAILED PROGRAM PLAN: + * 1. INITIALIZATION: Set three counters (positive_count, negative_count, zero_count) to zero. + * 2. INPUT LOOP: Start an infinite loop to continuously request user input. + * 3. READ INPUT: Use fgets() to read the user&#x27;s input as a generic string (char array). + * This allows the program to accept multi-digit numbers (e.g., &quot;-500&quot;) or the command (&#x27;n&#x27;). + * 4. TERMINATION CHECK: Immediately check if the input string is exactly &quot;n&quot; using strcmp(). + * If true, the user wants to quit, so break the loop. + * 5. VALIDATION &amp; CONVERSION: If the input is not &quot;n&quot;, use sscanf() to safely attempt to convert + * the string into an integer. + * 6. COUNTING LOGIC: If sscanf() successfully reads an integer (sscanf returns 1): + * - If the number is &gt; 0, increment positive_count. + * - If the number is &lt; 0, increment negative_count. + * - If the number is == 0, increment zero_count. + * 7. ERROR HANDLING: If the input is neither &quot;n&quot; nor a valid number (sscanf returns 0), + * inform the user of invalid input and continue the loop. + * 8. FINAL DISPLAY: After the loop terminates, print the final totals for positive, negative, and zero counts. + */ + +#include &lt;stdio.h&gt; +#include &lt;stdlib.h&gt; // for strtol +#include &lt;string.h&gt; // for strcmp + +// Maximum size of the input line +#define MAX_INPUT_LEN 15 + +int main() { + // Initialize counters + int positive_count = 0; + int negative_count = 0; + int zero_count = 0; + + // Buffer to store the user&#x27;s input as a string (e.g., &quot;123&quot;, &quot;-50&quot;, or &quot;n&quot;) + char input_buffer[MAX_INPUT_LEN]; + int number; + + printf(&quot;--- Number Analyzer ---\n&quot;); + printf(&quot;Enter numbers one by one. Type &#x27;n&#x27; and press Enter to finish.\n\n&quot;); + + // Loop until the user enters &#x27;n&#x27; + while (1) { + printf(&quot;Enter number or &#x27;n&#x27;: &quot;); + + // Read the entire line of input into the buffer + if (fgets(input_buffer, MAX_INPUT_LEN, stdin) == NULL) { + // Handle EOF (end of file) or reading error + break; + } + + // Remove the trailing newline character from the input_buffer + // The last character will be &#x27;\n&#x27; if the input was shorter than MAX_INPUT_LEN + size_t len = strlen(input_buffer); + if (len &gt; 0 &amp;&amp; input_buffer[len - 1] == &#x27;\n&#x27;) { + input_buffer[len - 1] = &#x27;\0&#x27;; + } + + // 1. Check for the termination condition + if (strcmp(input_buffer, &quot;n&quot;) == 0) { + printf(&quot;\n&#x27;n&#x27; received. Stopping input...\n&quot;); + break; // Exit the while loop + } + + // 2. Attempt to convert the input string to an integer + // sscanf attempts to read the string according to the format &quot;%d&quot; (decimal integer) + // It returns 1 if a number was successfully read. + int conversions = sscanf(input_buffer, &quot;%d&quot;, &amp;number); + + if (conversions == 1) { + // Conversion was successful, now check the number&#x27;s sign + if (number &gt; 0) { + positive_count++; + } else if (number &lt; 0) { + negative_count++; + } else { + zero_count++; + } + printf(&quot; -&gt; Number recorded: %d\n&quot;, number); + } else { + // Conversion failed. The input was neither &#x27;n&#x27; nor a valid integer. + printf(&quot; -&gt; Invalid input. Please enter a valid number or &#x27;n&#x27;.\n&quot;); + } + } + + // Display the final results + printf(&quot;\n====================================\n&quot;); + printf(&quot; Analysis Complete\n&quot;); + printf(&quot;====================================\n&quot;); + printf(&quot;Positive numbers entered: %d\n&quot;, positive_count); + printf(&quot;Negative numbers entered: %d\n&quot;, negative_count); + printf(&quot;Zeroes entered: %d\n&quot;, zero_count); + printf(&quot;Total numbers recorded: %d\n&quot;, positive_count + negative_count + zero_count); + printf(&quot;====================================\n&quot;); + + return 0; +}</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc031.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">luc031.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc031.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-letusc-luc031_c', 'luc031.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-letusc-luc031_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/letusc/luc031.c"> + <pre><code class="language-c">/* Write a program to enter numbers till the user wants. At the end it +should display the count of positive, negative and zeros entered. */ +/* Author - Amit Dutta, Date - 8th OCT, 2025 */ +/* Let Us C, Chap- 5, Page - 87, Qn No.: B(d) */ + +#include &lt;stdio.h&gt; +int main() +{ + int choice = 1, num, positive_count = 0, negative_count = 0, zero_count = 0; + while (choice == 1) + { + printf(&quot;\nEnter the number (Type any character and press Enter to finish.) : &quot;); + choice = scanf(&quot;%d&quot;, &amp;num); // Checking whether the user has input any characters + if (choice == 1) + { + printf(&quot;Number recorded : %d&quot;, num); + if (num &lt; 0) + negative_count++; + else if (num &gt; 0) + positive_count++; + else if (num == 0) + zero_count++; + } + else + { + // If the user inputs any characters, then choice = 0, it means he doesn&#x27;t want to give any more input; + choice = 0; + printf(&quot;\nCharacter received. Stopping input...\n&quot;); + } + } + // Display the final results + printf(&quot;\n====================================\n&quot;); + printf(&quot; Analysis Complete\n&quot;); + printf(&quot;====================================\n&quot;); + printf(&quot;Positive numbers entered: %d\n&quot;, positive_count); + printf(&quot;Negative numbers entered: %d\n&quot;, negative_count); + printf(&quot;Zeroes entered: %d\n&quot;, zero_count); + printf(&quot;Total numbers recorded: %d\n&quot;, positive_count + negative_count + zero_count); + printf(&quot;====================================\n&quot;); +}</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc032.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">luc032.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc032.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-letusc-luc032_c', 'luc032.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-letusc-luc032_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/letusc/luc032.c"> + <pre><code class="language-c">/* Write a program to recieve an integer and find its octal equivalent. +(Hint : To obtain octal equivalent of an integer, Divide it continuously +by 8 till dividend does not become zero, then write the remainders +obtained in reverse derection.) */ +/* Author - Amit Dutta, Date - 8th OCT, 2025 */ +/* Let Us C, Chap- 5, Page - 87, Qn No.: B(e) */ + +// using array + +#include &lt;stdio.h&gt; +int main() +{ + int octal[20], decimal, index = 0, temp, rem; + printf(&quot;Enter the decimal number : &quot;); + scanf(&quot;%d&quot;, &amp;decimal); + temp = decimal; + while (temp != 0) + { + rem = temp % 8; + temp = temp / 8; + octal[index] = rem; + index++; + } + printf(&quot;\nDeciaml %d to octal : &quot;, decimal); + while ((index - 1) &gt;= 0) + { + printf(&quot;%d&quot;, octal[index - 1]); + index--; + } + return 0; +}</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc033.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">luc033.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/luc033.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-letusc-luc033_c', 'luc033.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-letusc-luc033_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/letusc/luc033.c"> + <pre><code class="language-c">/* Write a program to find the range of a set of numbers entered +through the keyboard. Range is the difference between the smallest +and biggest number in the list. */ +/* Author - Amit Dutta, Date - 8th OCT, 2025 */ +/* Let Us C, Chap- 5, Page - 87, Qn No.: B(f) */ + +#include &lt;stdio.h&gt; +int main() +{ + int choice = 1, set_of_numbers[30], num, index = -1; + while (choice == 1) + { + printf(&quot;\nEnter the number (Type any character and press Enter to finish.) : &quot;); + choice = scanf(&quot;%d&quot;, &amp;num); // Checking whether the user has input any characters + if (choice != 1) + { + // If the user inputs any characters, then choice = 0, it means he doesn&#x27;t want to give any more input; + choice = 0; + printf(&quot;\nCharacter received. Stopping input...\n&quot;); + break; + } + index++; + set_of_numbers[index] = num; + } + int max = set_of_numbers[0], min = set_of_numbers[0]; + while (index &gt;= 0) + { + if (max &lt; set_of_numbers[index]) + max = set_of_numbers[index]; + if (min &gt; set_of_numbers[index]) + min = set_of_numbers[index]; + index--; + } + int range = max - min; + printf(&quot;\nBiggest number in the set : %d&quot;, max); + printf(&quot;\nSmallest number in the set : %d&quot;, min); + printf(&quot;\nRange : %d&quot;, range); + return 0; +}</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/lucproblem001.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">lucproblem001.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/lucproblem001.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-letusc-lucproblem001_c', 'lucproblem001.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-letusc-lucproblem001_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/letusc/lucproblem001.c"> + <pre><code class="language-c">/* Consider a currency system in which there are notes of six denominations, +namely, Rs. 1, Rs. 2, rs. 5, Rs. 10, Rs. 50, Rs. 100. If a sum +of Rs. N is entered through the keyboard, Write a program to compute +the smallest number of notes that will combine to give Rs. N. */ +/* Author - Amit Dutta, Date - 29th SEP, 2025 */ +/* Let Us C, Chap - 2, Page - 22, Problem 2.3 */ + +#include &lt;stdio.h&gt; +int main() +{ + int n, nonotes, temp; + printf(&quot;Enter the amount : &quot;); + scanf(&quot;%d&quot;, &amp;n); + if (n &lt; 1) + { + printf(&quot;\nAmount should be a positive integer.&quot;); + return 1; + } + temp = n; + nonotes = n / 100; + n = n % 100; + nonotes = nonotes + (n / 50); + n = n % 50; + nonotes = nonotes + (n / 10); + n = n % 10; + nonotes = nonotes + (n / 5); + n = n % 5; + nonotes = nonotes + (n / 2); + n = n % 2; + nonotes = nonotes + n; + printf(&quot;\nthe smallest number of notes that will combine to give Rs. %d : %d&quot;, temp, nonotes); + return 0; +}</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/lucproblem002.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">lucproblem002.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/lucproblem002.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-letusc-lucproblem002_c', 'lucproblem002.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-letusc-lucproblem002_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/letusc/lucproblem002.c"> + <pre><code class="language-c">/* A year is entered through the keyboard, write a program to +determine whether the year is leap or not. Use the logical operators +&amp;&amp; and || . */ +/* Author - Amit Dutta, Date - 02th OCT, 2025 */ +/* Let Us C, Chap - 4, Page - 64, Problem 4.1 */ + +#include &lt;stdio.h&gt; +int main() +{ + int year; + printf(&quot;Enter year : &quot;); + scanf(&quot;%d&quot;, &amp;year); + if (year % 4 == 0 &amp;&amp; year &amp; 100 != 0 || year % 400 == 0) + printf(&quot;\nYear %d is a leapyear.&quot;, year); + else + printf(&quot;\nYear %d is not a leapyear.&quot;, year); + return 0; +}</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/lucproblem003.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">lucproblem003.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/lucproblem003.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-letusc-lucproblem003_c', 'lucproblem003.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-letusc-lucproblem003_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/letusc/lucproblem003.c"> + <pre><code class="language-c">/* If a character is entered through the keyboard, Write a program +to determine whether the character is a capital letter, a small case letter, +a digit or a speacial symbol. +The following table shows the range of ASCII values for various characters : + Characters ASCII Values + A - Z 65 - 90 + a - z 97 - 122 + 0 - 9 48 - 57 + special symbols 0 - 47, 58 - 64, 91 - 96, 123 - 127 +*/ +/* Author - Amit Dutta, Date - 02th OCT, 2025 */ +/* Let Us C, Chap - 4, Page - 65, Problem 4.2 */ + +#include &lt;stdio.h&gt; +int main() +{ + char inp; + printf(&quot;Enter one character : &quot;); + scanf(&quot; %c&quot;, &amp;inp); + if (inp &gt;= 64 &amp;&amp; inp &lt;= 90) + printf(&quot;\nInput &#x27;%c&#x27; is a CAPITAL LETTER.&quot;, inp); + if (inp &gt;= 97 &amp;&amp; inp &lt;= 122) + printf(&quot;\nInput &#x27;%c&#x27; is a SMALL CASE LETTER.&quot;, inp); + if (inp &gt;= 48 &amp;&amp; inp &lt;= 57) + printf(&quot;\nInput &#x27;%c&#x27; is a DIGIT.&quot;, inp); + if (inp &gt;= 0 &amp;&amp; inp &lt;= 47 || inp &gt;= 58 &amp;&amp; inp &lt;= 64 + || inp &gt;= 91 &amp;&amp; inp &lt;= 96 || inp &gt;= 123 &amp;&amp; inp &lt;= 127) + printf(&quot;\nInput &#x27;%c&#x27; is a SPECIAL SYMBOL.&quot;, inp); + return 0; +}</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/lucproblem004.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">lucproblem004.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/lucproblem004.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-letusc-lucproblem004_c', 'lucproblem004.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-letusc-lucproblem004_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/letusc/lucproblem004.c"> + <pre><code class="language-c">/* If the lengths of three sides of a triangle are entered through the +keyboard, write a program to check whether the triangle is valid or not. +The triangle is valid if the sum of two sides is greater that the largest +of the three sides. */ +/* Author - Amit Dutta, Date - 02th OCT, 2025 */ +/* Let Us C, Chap - 4, Page - 66, Problem 4.3 */ + +#include &lt;stdio.h&gt; +int main() +{ + double side1, side2, side3; + printf(&quot;Enter the length of side1, side2 and side3 of the triangle : &quot;); + scanf(&quot;%lf %lf %lf&quot;, &amp;side1, &amp;side2, &amp;side3); + if (side1 &lt;= 0 || side2 &lt;= 0 || side3 &lt;= 0) + { + printf(&quot;\nTriangle sides must be positive.\n&quot;); + return 1; + } + if ((side1 + side2 &gt; side3) &amp;&amp; (side1 + side3 &gt; side2) &amp;&amp; (side2 + side3 &gt; side1)) + // Triangle Inequality Theorem + printf(&quot;\nThis triangle is valid.&quot;); + else + printf(&quot;\nThis triangle is not valid.&quot;); + return 0; +}</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/lucproblem005.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">lucproblem005.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/lucproblem005.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-letusc-lucproblem005_c', 'lucproblem005.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-letusc-lucproblem005_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/letusc/lucproblem005.c"> + <pre><code class="language-c">/* Write a program to calculate overtime pay of 10 employees. Overtime is +paid at the rate of Rs. 120.00 per hour for every hour worked above 40 +hours. Assume that employees do not work for fractional part of an hour. */ +/* ONLY WHILE LOOP ALLOWED */ +/* Author - Amit Dutta, Date - 07th OCT, 2025 */ +/* Let Us C, Chap - 5, Page - 83, Problem 5.1 */ + +#include &lt;stdio.h&gt; +#include &lt;conio.h&gt; +int main() +{ + int working_hour, i = 1; + double pay; + while (i &lt;= 10) + { + printf(&quot;Enter the working hour for the employee no. %d : &quot;, i); + if (scanf(&quot;%d&quot;, &amp;working_hour) != 1) + { + printf(&quot;\n\tPlease enter a number as woking hour.\n\n&quot;); + while (getchar() != &#x27;\n&#x27;) + ; + // above line discard the input characters untill getchar() reaches the new line character. + /* if I do not discard the input, after &#x27;continue;&#x27; statement that input will be again taken + by scanf (In the line 17). It will be a infinite loop of error. */ + continue; + } + // checking overtime + if (working_hour &gt; 40) + { + pay = (working_hour - 40) * 120.00; + printf(&quot;\n\tOvertime working hours of Employee %d : %d&quot;, i, (working_hour - 40)); + printf(&quot;\n\tPay of the overtime for Employee %d : Rs. %.2f\n\n&quot;, i, pay); + } + else + printf(&quot;\n\tEmployee %d did not work any overtime.\n\n&quot;, i); + i++; // changing to next employee + } +}</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/lucproblem006.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">lucproblem006.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/lucproblem006.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-letusc-lucproblem006_c', 'lucproblem006.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-letusc-lucproblem006_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/letusc/lucproblem006.c"> + <pre><code class="language-c">/* Write a program to find the factorial value of any number entered +through the keyboard. */ +/* Author - Amit Dutta, Date - 07th OCT, 2025 */ +/* Let Us C, Chap - 5, Page - 84, Problem 5.2 */ + +#include &lt;stdio.h&gt; +int main() +{ + int num, i = 1; + long long fact = 1; + printf(&quot;Enter the number : &quot;); + // checking if the input is valid or not + if (scanf(&quot;%d&quot;, &amp;num) != 1) + { + printf(&quot;\nPlease enter a number.&quot;); + return 1; + } + // result for the negetive input + if (num &lt; 0) + { + printf(&quot;\nFactorial of %d : Undefined&quot;, num); + return 1; + } + // Hard codded result for input &#x27;0&#x27; (zero) + if (num == 0) + { + printf(&quot;\nFactorial of 0 : 1&quot;); + return 0; + } + // calculating result + while (i &lt;= num) { + fact = fact * i; + i++; + } + printf(&quot;\nFactorial of %d : %d&quot;, num, fact); + return 0; +}</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/lucproblem007.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">lucproblem007.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/letusc/lucproblem007.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-letusc-lucproblem007_c', 'lucproblem007.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-letusc-lucproblem007_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/letusc/lucproblem007.c"> + <pre><code class="language-c">/* Two numbers are entered through the keyboard. Write a program to +find the value of one number raised to the power of another */ +/* Author - Amit Dutta, Date - 07th OCT, 2025 */ +/* Let Us C, Chap - 5, Page - 84, Problem 5.3 */ + +#include &lt;stdio.h&gt; +int main() +{ + double num, result; + int power, i = 1; + printf(&quot;Enter the numbers in &#x27;num^power&#x27; format : &quot;); + // checking if the input is valid or not + if (scanf(&quot;%lf^%d&quot;, &amp;num, &amp;power) != 2) + { + printf(&quot;\nPlease enter numbers.&quot;); + return 1; + } + // result for the negetive input + if (power &lt; 0) + { + printf(&quot;\nPlease use a positive number as power.&quot;); + return 1; + } + // Hard codded result for input &#x27;0&#x27; (zero) + if (power == 0) + { + printf(&quot;\n%g to the power of %d is : 1&quot;, num, power); + return 0; + } + result = num; + while (i &lt;= power - 1) + { + result = result * num; + i++; + } + printf(&quot;\n%g to the power of %d is : %g&quot;, num, power, result); + return 0; +}</code></pre> + </div> </li> </ul> </div> @@ -467,8 +2471,10 @@ <span class="font-medium text-gray-800">tuition-c</span> <span class="ml-2 text-sm text-gray-500">(53 files)</span> </div> - <div class="flex items-center space-x-2"> - <a href="https://github.com/notamitgamer/bsc/tree/main/tuition-c" target="_blank" class="text-blue-500 font-semibold text-sm hover:underline" onclick="event.stopPropagation()">GitHub</a> + <div class="flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/tree/main/tuition-c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" onclick="event.stopPropagation()" title="View folder on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> <div class="chevron" id="chevron-tuition-c"><svg class="w-5 h-5 text-gray-500 transition-transform duration-200" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"></path></svg></div> </div> </div> @@ -477,453 +2483,2144 @@ <ul class="divide-y divide-gray-200"> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-PRAC-001.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">APC-PRAC-001.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-PRAC-001.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-tuition-c-APC-PRAC-001_c', 'APC-PRAC-001.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-tuition-c-APC-PRAC-001_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-PRAC-001.c"> + <pre><code class="language-c">/* WAP to calculate area and perimeter of a rectangle +by accepting length and breadth as input. */ +// Author - Amit Dutta, Date - 18th SEP, 2025 + +#include&lt;stdio.h&gt; +int main() { + double length, breadth, area, perimeter; + printf(&quot;Enter the length and breadth of the Rectangle : &quot;); + scanf(&quot;%lf %lf&quot;, &amp;length, &amp;breadth); + area = length * breadth; + perimeter = 2 * (length + breadth); + printf(&quot;\nArea of the Rectangle : %g&quot; + &quot;\nPerimeter of the Rectangle : %g&quot;, area, perimeter); + return 0; + +} + +</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-PRAC-002.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">APC-PRAC-002.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-PRAC-002.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-tuition-c-APC-PRAC-002_c', 'APC-PRAC-002.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-tuition-c-APC-PRAC-002_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-PRAC-002.c"> + <pre><code class="language-c">/* WAP to calculate area of a circle using math library +method. Take radius of the circle as input. */ +/* Author - Amit Dutta, Date - 18th SEP, 2025 */ + +#include &lt;stdio.h&gt; +#include &lt;math.h&gt; +int main() +{ + double r, area; + printf(&quot;Enter the radius of the circle : &quot;); + scanf(&quot;%lf&quot;, &amp;r); + area = M_PI * pow(r, 2); + printf(&quot;\nArea of the circle : %g&quot;, area); + return 0; +}</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-PRAC-003.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">APC-PRAC-003.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-PRAC-003.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-tuition-c-APC-PRAC-003_c', 'APC-PRAC-003.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-tuition-c-APC-PRAC-003_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-PRAC-003.c"> + <pre><code class="language-c">/* WAP to accept diagonal of a square and calculate area, parimeter */ +/* Author - Amit Dutta, Date - 18th SEP, 2025 */ + +#include &lt;stdio.h&gt; +#include &lt;math.h&gt; +int main() +{ + double dia, side, area, peri; + printf(&quot;Enter the diagonal of the square : &quot;); + scanf(&quot;%lf&quot;, &amp;dia); + side = dia / sqrt(2); + area = pow(side, 2); + peri = 4 * side; + printf(&quot;\nArea of the square : %g&quot; + &quot;\nPerimeter of the square : %g&quot;, + area, peri); + return 0; +}</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-PRAC-004.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">APC-PRAC-004.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-PRAC-004.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-tuition-c-APC-PRAC-004_c', 'APC-PRAC-004.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-tuition-c-APC-PRAC-004_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-PRAC-004.c"> + <pre><code class="language-c">/* WAP to calculate and display radius of a circle by taking the area as input. */ +/* Author - Amit Dutta, Date - 18th SEP, 2025 */ + +#include &lt;stdio.h&gt; +#include &lt;math.h&gt; +int main() +{ + double r, area; + printf(&quot;Enter the area of the circle : &quot;); + scanf(&quot;%lf&quot;, &amp;area); + r = sqrt(area / M_PI); + printf(&quot;\nRadius of the circle : %g&quot;, r); + return 0; +}</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-PRAC-005.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">APC-PRAC-005.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-PRAC-005.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-tuition-c-APC-PRAC-005_c', 'APC-PRAC-005.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-tuition-c-APC-PRAC-005_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-PRAC-005.c"> + <pre><code class="language-c">/* WAP a program that accept number of days +as input and represent it as years, months and days. */ +/* Author - Amit Dutta, Date - 19th SEP, 2025 */ + +#include &lt;stdio.h&gt; +int main() +{ + int days, months, years, temp; + printf(&quot;Enter the No. of days : &quot;); + scanf(&quot;%d&quot;, &amp;days); + temp = days; + years = days / 365; + days = days % 365; + months = days / 30; + days = days % 30; + printf(&quot;%d Days = %d Years, %d Months, %d Days&quot;, temp, years, months, days); + return 0; +}</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-PRAC-006.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">APC-PRAC-006.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-PRAC-006.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-tuition-c-APC-PRAC-006_c', 'APC-PRAC-006.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-tuition-c-APC-PRAC-006_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-PRAC-006.c"> + <pre><code class="language-c">/* WAP that accept seconds as input and represent it an hours, minutes and seconds. */ +/* Author - Amit Dutta, Date - 19th SEP, 2025 */ + +#include &lt;stdio.h&gt; +int main() +{ + int sec, hours, minutes, temp; + printf(&quot;Enter the no of seconds : &quot;); + scanf(&quot;%d&quot;, &amp;sec); + temp = sec; + hours = sec / 3600; + sec = sec % 3600; + minutes = sec / 60; + sec = sec % 60; + printf(&quot;\n%d Seconds = %d Hours, %d Minutes, %d Seconds.&quot;, temp, hours, minutes, sec); + return 0; +}</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-PRAC-007.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">APC-PRAC-007.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-PRAC-007.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-tuition-c-APC-PRAC-007_c', 'APC-PRAC-007.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-tuition-c-APC-PRAC-007_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-PRAC-007.c"> + <pre><code class="language-c">/* WAP that accept basic salary of an employee and display gross salary, +net salary generated by below formula. + DA = 25% of the basic salary. + HRA = 12.5% of the basic salary. + PF = 10% of the basic salary. + gross salary = basic salary + da + hra + net salary = gross salary - pf +*/ +/* Author - Amit Dutta, Date - 19th SEP, 2025 */ + +#include &lt;stdio.h&gt; +int main() +{ + double bs, gs, ns, da, hra, pf; + printf(&quot;Enter the basic salary of the employee : &quot;); + scanf(&quot;%lf&quot;, &amp;bs); + da = bs * 0.25; + hra = bs * 0.125; + pf = bs * 0.10; + gs = bs + da + hra; + ns = gs - pf; + printf(&quot;\nGross Salary : %g&quot; + &quot;\nNet Salary : %g&quot;, + gs, ns); + return 0; +}</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-PRAC-008.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">APC-PRAC-008.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-PRAC-008.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-tuition-c-APC-PRAC-008_c', 'APC-PRAC-008.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-tuition-c-APC-PRAC-008_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-PRAC-008.c"> + <pre><code class="language-c">/* WAP to multiply and divide a number by 4 without +using multiplication and division operator. */ +/* Author - Amit Dutta, Date - 19th SEP, 2025 */ + +#include &lt;stdio.h&gt; +int main() +{ + int num, multi, div; + printf(&quot;Enter the number : &quot;); + scanf(&quot;%d&quot;, &amp;num); + multi = num &lt;&lt; 2; + div = num &gt;&gt; 2; + printf(&quot;Multiplication : %d&quot; + &quot;\nDivision : %d&quot;, + multi, div); + return 0; +}</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-PRAC-009.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">APC-PRAC-009.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-PRAC-009.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-tuition-c-APC-PRAC-009_c', 'APC-PRAC-009.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-tuition-c-APC-PRAC-009_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-PRAC-009.c"> + <pre><code class="language-c">/* WAP to swap two integer variable without using Third variable. */ +/* Author - Amit Dutta, Date - 19th SEP, 2025 */ + +#include &lt;stdio.h&gt; +int main() +{ + int a = 4, b = 6; + printf(&quot;Before swap : A = %d and B = %d&quot;, a, b); + a = a ^ b; + b = a ^ b; + a = a ^ b; + printf(&quot;\nAfter swap : A = %d and B = %d&quot;, a, b); + return 0; +}</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-PRAC-010.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">APC-PRAC-010.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-PRAC-010.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-tuition-c-APC-PRAC-010_c', 'APC-PRAC-010.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-tuition-c-APC-PRAC-010_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-PRAC-010.c"> + <pre><code class="language-c">/* WAP to calculate and display the valve of the given expression : + (1/a^3) + (1/(b+2)^3) + (1/(c^4 + root(2))) + take a, b, c as input. +*/ +/* Author - Amit Dutta, Date - 19th SEP, 2025 */ + +#include &lt;stdio.h&gt; +#include &lt;math.h&gt; +int main() +{ + double a, b, c, result; + printf(&quot;Enter the value for a, b and c : &quot;); + scanf(&quot;%lf %lf %lf&quot;, &amp;a, &amp;b, &amp;c); + result = (1 / pow(a, 3)) + (1 / pow((b + 2), 3)) + (1 / (pow(c, 4) + sqrt(2))); + printf(&quot;\nResult = %g&quot;, result); + return 0; +}</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-S-001.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">APC-S-001.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-S-001.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-tuition-c-APC-S-001_c', 'APC-S-001.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-tuition-c-APC-S-001_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-S-001.c"> + <pre><code class="language-c">#include&lt;stdio.h&gt; +int main() { + int a = 9, b = 4, c; + c = a + b; + printf(&quot;A + B = %d\n&quot;, c); + c = a / b; + printf(&quot;A / B = %d\n&quot;, c); + c = a % b; + printf(&quot;A %% B = %d\n&quot;, c); + return 0; +} +</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-S-002.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">APC-S-002.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-S-002.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-tuition-c-APC-S-002_c', 'APC-S-002.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-tuition-c-APC-S-002_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-S-002.c"> + <pre><code class="language-c">#include&lt;stdio.h&gt; +int main() { + int a = 5, b = 5, c = 10; + printf(&quot;a = b = %d\n&quot;, a == b); + printf(&quot;a &gt; b = %d\n&quot;, a &gt; b); + printf(&quot;a &lt; b = %d\n&quot;, a &lt; b); + return 0; +} +</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-S-003.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">APC-S-003.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-S-003.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-tuition-c-APC-S-003_c', 'APC-S-003.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-tuition-c-APC-S-003_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-S-003.c"> + <pre><code class="language-c">#include &lt;stdio.h&gt; +int main() { + int a = 5, b = 5, c = 10, result; + + result = (a == b) &amp;&amp; (c &gt; b); + printf(&quot;Result is %d\n&quot;, result); + + result = (a == b) &amp;&amp; (c &lt; b); + printf(&quot;Result is %d\n&quot;, result); + + result = (a != b) || (c &lt; b); + printf(&quot;Result is %d\n&quot;, result); + + result = (a != b) || (c &lt; b); + printf(&quot;Result is %d\n&quot;, result); + + result = !(a != b); + printf(&quot;Result is %d\n&quot;, result); + + result = !(a == b); + printf(&quot;Result is %d\n&quot;, result); + + return 0; +} +</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-SPS-001.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">APC-SPS-001.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-SPS-001.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-tuition-c-APC-SPS-001_c', 'APC-SPS-001.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-tuition-c-APC-SPS-001_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-SPS-001.c"> + <pre><code class="language-c">// WAP to perform arithmatic operation on integer data + +#include&lt;stdio.h&gt; +int main() { + int a, b, sum, sub, multi, div, mod; + printf(&quot;Enter 1st number : &quot;); + scanf(&quot;%d&quot;, &amp;a); + printf(&quot;Enter 2nd number : &quot;); + scanf(&quot;%d&quot;, &amp;b); + sum = a + b; + sub = a - b; + multi = a * b; + div = a / b; + mod = a % b; + printf(&quot;\nSum = %d&quot;, sum); + printf(&quot;\nSubtraction = %d&quot;, sub); + printf(&quot;\nMultiplication = %d&quot;, multi); + printf(&quot;\nDivision = %d&quot;, div); + printf(&quot;\nModulas = %d&quot;, div); + return 0; +} +</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-SPS-002.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">APC-SPS-002.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-SPS-002.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-tuition-c-APC-SPS-002_c', 'APC-SPS-002.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-tuition-c-APC-SPS-002_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-SPS-002.c"> + <pre><code class="language-c">/* WAP to swap two integers. Display both numbers +before and after swap */ + +#include&lt;stdio.h&gt; +int main() { + int a = 10, b = 20, temp; + printf(&quot;Before swap A : %d, B : %d&quot;, a, b); + temp = a; + a = b; + b = temp; + printf(&quot;\nAfter swap A : %d, B : %d&quot;, a, b); + return 0; +} +</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-SPS-003.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">APC-SPS-003.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-SPS-003.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-tuition-c-APC-SPS-003_c', 'APC-SPS-003.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-tuition-c-APC-SPS-003_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-SPS-003.c"> + <pre><code class="language-c">/* Bitwise AND &#x27;&amp;&#x27; */ + +#include&lt;stdio.h&gt; +int main() { + unsigned int a = 4, b = 5, c = 6; + unsigned int x, y; + x = a &amp; b; + y = b &amp; c; + printf(&quot;x = %u y = %u&quot;, x, y); + return 0; +} +</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-SPS-004.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">APC-SPS-004.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-SPS-004.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-tuition-c-APC-SPS-004_c', 'APC-SPS-004.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-tuition-c-APC-SPS-004_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-SPS-004.c"> + <pre><code class="language-c">#include&lt;stdio.h&gt; +int main() { + int x = 25, y = 19, z; + z = x - y; + z = z &amp; x ; + printf(&quot;Z = %d&quot;, z); + return 0; +} +</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-SPS-005.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">APC-SPS-005.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-SPS-005.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-tuition-c-APC-SPS-005_c', 'APC-SPS-005.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-tuition-c-APC-SPS-005_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-SPS-005.c"> + <pre><code class="language-c">/* Bitwise OR &#x27;|&#x27; */ + +#include&lt;stdio.h&gt; +int main() { + int x = 12, y = 14, z = 10, res; + x++; + z++; + x = x + y + z; + res = x | y; + z = res | z; + printf(&quot;x = %d y = %d z = %d res = %d&quot;, x, y, z, res); + return 0; +} +</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-SPS-006.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">APC-SPS-006.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-SPS-006.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-tuition-c-APC-SPS-006_c', 'APC-SPS-006.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-tuition-c-APC-SPS-006_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-SPS-006.c"> + <pre><code class="language-c">/* Bitwise NOT &#x27;~&#x27; */ + +#include&lt;stdio.h&gt; +int main() { + int x = 12, y = 15, z = 21; + int res, res1, res2; + res = x &gt; 10; + res1 = ~res; + res2 = ~x; + printf(&quot;REs = %d, Res1 = %d, Res2 = %d&quot;, res, res1, res2); + return 0; +} +</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-SPS-007.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">APC-SPS-007.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-SPS-007.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-tuition-c-APC-SPS-007_c', 'APC-SPS-007.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-tuition-c-APC-SPS-007_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-SPS-007.c"> + <pre><code class="language-c">/* WAP to check a number is even or odd using bitwise operator */ + +#include&lt;stdio.h&gt; +int main() { + int x, res = 1; + printf(&quot;Enter a number : &quot;); + scanf(&quot;%d&quot;, &amp;x); + res = res &amp; x; + if (res == 0) { + printf(&quot;\nInput %d is a even number.&quot;, x); + } + else { + printf(&quot;\nInput %d is a odd number.&quot;, x); + } + return 0; +} +</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-SPS-008.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">APC-SPS-008.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-SPS-008.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-tuition-c-APC-SPS-008_c', 'APC-SPS-008.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-tuition-c-APC-SPS-008_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/tuition-c/APC-SPS-008.c"> + <pre><code class="language-c">/* WAP to calculate area of circle by accepting radius as input */ +/* Author : Amit Dutta, Date : 15th September, 2025 */ + +#include&lt;stdio.h&gt; +#include&lt;math.h&gt; +int main() { + double r, area; + printf(&quot;Enter the radius of circle : &quot;); + scanf(&quot;%lf&quot;, &amp;r); + area = M_PI * r * r; + printf(&quot;\nArea : %lf&quot;, area); + return 0; +} +</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P001.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">P001.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P001.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-tuition-c-P001_c', 'P001.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-tuition-c-P001_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P001.c"> + <pre><code class="language-c">//sample code +// Author - Amit Dutta, Date - Unknown + +#include&lt;stdio.h&gt; +int main() { + printf(&quot;Hello world&quot;); + return 0; +} +</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P002.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">P002.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P002.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-tuition-c-P002_c', 'P002.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-tuition-c-P002_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P002.c"> + <pre><code class="language-c">//sample code with a new line charecter +// Author - Amit Dutta, Date - Unknown + +#include&lt;stdio.h&gt; +int main() { + printf(&quot;Hello\nworld&quot;); + return 0; +} +</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P003.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">P003.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P003.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-tuition-c-P003_c', 'P003.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-tuition-c-P003_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P003.c"> + <pre><code class="language-c">//WAP to perform addtion and multiplication of two integer numbers +// Author - Amit Dutta, Date - Unknown + +#include&lt;stdio.h&gt; +int main() { + int a, b, sum, multi; + printf(&quot;Enter the 1st number : &quot;); + scanf(&quot;%d&quot;,&amp;a); + printf(&quot;Enter the 2nd number : &quot;); + scanf(&quot;%d&quot;,&amp;b); + sum = a + b; + multi = a * b; + printf(&quot;\nSum = %d&quot; + &quot;\nMultiplication = %d&quot;,sum,multi); + return 0; +} +</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P004.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">P004.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P004.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-tuition-c-P004_c', 'P004.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-tuition-c-P004_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P004.c"> + <pre><code class="language-c">/* WAP to find and display the value of given expression : +((x+3)/4) - ((2x+4)/3) taking the value of x = 5 */ +// Author - Amit Dutta, Date - Unknown + +#include&lt;stdio.h&gt; +int main() { + double x =5, result; + result = ((x + 3) / 4) - ((2 * x + 4) / 3); + printf(&quot;Result = %lf&quot;,result); + return 0; +} +</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P005.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">P005.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P005.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-tuition-c-P005_c', 'P005.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-tuition-c-P005_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P005.c"> + <pre><code class="language-c">/* A person is paid Rs. 455 for each day he works and fined +Rs. 150 for each day he remains absent. WAP to calculate his +monthly income taking the number of days present as input. */ +// Author - Amit Dutta, Date - Unknown + +#include&lt;stdio.h&gt; +int main() { + int daily_wage = 455, fine = 150, present, absent, income; + printf(&quot;No of days present : &quot;); + scanf(&quot;%d&quot;, &amp;present); + absent = 30 - present; + income = (present * 455) - (absent * 150); + printf(&quot;\nIncome : %d&quot;,income); + return 0; +} +</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P006.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">P006.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P006.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-tuition-c-P006_c', 'P006.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-tuition-c-P006_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P006.c"> + <pre><code class="language-c">/* The normal temperature of human body +is 98.6 Degree Fahrenheit. WAP to convert the temperature +to Degree Celcius and display the output. */ +// Author - Amit Dutta, Date - Unknown + +#include&lt;stdio.h&gt; +int main() { + double f = 98.6, c; + c = ((f - 32) * 5) / 9; + printf(&quot;Temperature in Celcius is : %lf&quot;,c); + return 0; +} +</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P007.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">P007.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P007.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-tuition-c-P007_c', 'P007.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-tuition-c-P007_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P007.c"> + <pre><code class="language-c">/* A shopkeeper offers 10% discount on printed +price of a digital camera. However a customer has +to pay 6% GST on the remaining amount. WAP to +calculate and display the amount to paid by the +customer, taking the printed price as input. */ +// Author - Amit Dutta, Date - Unknown + +#include&lt;stdio.h&gt; +int main() { + double mrp, final_price, temp; + printf(&quot;Enter the printed price : &quot;); + scanf(&quot;%lf&quot;, &amp;mrp); + temp = mrp * 0.90; + final_price = temp * 1.06; + printf(&quot;\nCustomer have to pay : %lf&quot;, final_price); + return 0; +} +</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P008.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">P008.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P008.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-tuition-c-P008_c', 'P008.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-tuition-c-P008_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P008.c"> + <pre><code class="language-c">/* A shopkeeper offers 30% discount on purchasing an +item whereas the other shopkeeper offers 2 successive +discount of 20% and 10% for purchasing the same item. +WAP to caompute and display the discounted price of the +item by taking the price as input. */ +// Author - Amit Dutta, Date - Unknown + +#include&lt;stdio.h&gt; +int main() { + double mrp, shop1, shop2, temp; + printf(&quot;Enter the price : &quot;); + scanf(&quot;%lf&quot;, &amp;mrp); + shop1 = mrp * 0.70; + temp = mrp * 0.80; + shop2 = temp * 0.90; + printf(&quot;\nShopkeeper 1 price : %lf&quot; + &quot;\nShopkeeper 2 price : %lf&quot;,shop1,shop2); + return 0; +} +</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P009.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">P009.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P009.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-tuition-c-P009_c', 'P009.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-tuition-c-P009_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P009.c"> + <pre><code class="language-c">/* WAP to calculate gross and net salary +by accepting basic salary as input. +IMP : DA = 30% of Basic Pay + HRA = 20% of Basic Pay + PF = 12.5% of Basic Pay + Gross Salary = Basic Pay + DA + HRA + Net Salary = Gross Salary - PF +*/ +// Author - Amit Dutta, Date - Unknown + +#include&lt;stdio.h&gt; +int main() { + double bs, da, hra, pf, gs, ns; + printf(&quot;Enter the Basic Salary : &quot;); + scanf(&quot;%lf&quot;, &amp;bs); + da = bs * 0.3; + hra = bs * 0.2; + pf = bs * 0.125; + gs = bs + da + hra; + ns = gs - pf; + printf(&quot;\nGross Salary : %lf&quot; + &quot;\nNet Salary : %lf&quot;, gs, ns); + return 0; +} +</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P010.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">P010.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P010.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-tuition-c-P010_c', 'P010.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-tuition-c-P010_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P010.c"> + <pre><code class="language-c">/* WAP to find and display the difference +between compound Interest and Simple Interest. +Take principle amount as input. +Hint : si = (p * r * t) / 100 + a = p * ((1 + (r / 100)) ^ t) + ci = a - p +*/ +// Author - Amit Dutta, Date - Unknown + +#include&lt;stdio.h&gt; +#include&lt;math.h&gt; +int main() { + double p, r, t, si, a, ci, dif; + printf(&quot;Enter the principle amount, rate of interest, time in year : &quot;); + scanf(&quot;%lf %lf %lf&quot;, &amp;p, &amp;r, &amp;t); + si = (p * r * t) / 100; + a = p * pow((1 + (r / 100)), t); + ci = a - p; + dif = ci - si; + printf(&quot;\nSimple Interest : %lf&quot; + &quot;\nCompound Interest : %lf&quot; + &quot;\nInterest Difference : %lf&quot;, si, ci, dif); + return 0; +} +</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P011.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">P011.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P011.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-tuition-c-P011_c', 'P011.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-tuition-c-P011_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P011.c"> + <pre><code class="language-c">/* The time period of a simple pendulam is +given by the formula : + t = 2 * pi * square_root(l / g) +WAP to calculate T take length(L) and gravity +as input +*/ +// Author - Amit Dutta, Date - Unknown + +#include&lt;stdio.h&gt; +#include&lt;math.h&gt; +int main() { + double l, g, t; + printf(&quot;Enter the Length and Gravity measures : &quot;); + scanf(&quot;%lf %lf&quot;, &amp;l, &amp;g); + t = 2 * M_PI * sqrt(l / g); + // using M_PI variable for PI value from math.h header file + printf(&quot;\nTime Period : %lf&quot;, t); + return 0; +} +</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P012.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">P012.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P012.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-tuition-c-P012_c', 'P012.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-tuition-c-P012_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P012.c"> + <pre><code class="language-c">/* WAP to swap two integer variable without +using third variable */ +// using Approch Mode : simple, slow, time consuming +// Author - Amit Dutta, Date - Unknown + +#include&lt;stdio.h&gt; +int main() { + int a = 4, b = 6; + printf(&quot;Before Swap : A = %d, B = %d&quot;, a, b); + a = a + b; + b = a - b; + a = a - b; + printf(&quot;\nAfter Swap : A = %d, B = %d&quot;, a, b); + return 0; +} +</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P013.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">P013.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P013.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-tuition-c-P013_c', 'P013.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-tuition-c-P013_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P013.c"> + <pre><code class="language-c">/* WAP to swap two integer variable without +using third variable */ +// using Approch Mode : complex, fast, less time consumimg +// Author - Amit Dutta, Date - Unknown + +#include&lt;stdio.h&gt; +#include&lt;math.h&gt; +int main() { + int a = 4, b = 6; + printf(&quot;Before Swap : A = %d, B = %d&quot;, a, b); + a = a ^ b; + b = a ^ b; + a = a ^ b; + printf(&quot;\nAfter Swap : A = %d, B = %d&quot;, a, b); + return 0; +} +</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P014.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">P014.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P014.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-tuition-c-P014_c', 'P014.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-tuition-c-P014_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P014.c"> + <pre><code class="language-c">/* WAP to accept the diagonal of +square. Find and display the area and +perimeter of the square. */ +// Author - Amit Dutta, Date - Unknown + +#include&lt;stdio.h&gt; +#include&lt;math.h&gt; +int main() { + double d, side, area, per; + printf(&quot;Enter the diagonal : &quot;); + scanf(&quot;%lf&quot;, &amp;d); + side = d / sqrt (2); + area = side * side; + per = 4 * side; + printf(&quot;\nArea of the Square : %lf&quot; + &quot;\nPerimeter of the Square : %lf&quot;, area, per); + return 0; +} +</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P015.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">P015.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P015.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-tuition-c-P015_c', 'P015.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-tuition-c-P015_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P015.c"> + <pre><code class="language-c">/*WAP to accept number of days and +display it after converting into +number of years, months and days */ +// Author - Amit Dutta, Date - Unknown + +#include&lt;stdio.h&gt; +int main() { + int day, month, year, temp; + printf(&quot;Enter the number of days : &quot;); + scanf(&quot;%d&quot;, &amp;day); + temp = day; + year = day / 365; + day = day % 365; + month = day / 30; + day = day % 30; + printf(&quot;\n%d Days = %d Years %d Months %d Days&quot;, temp, year, month, day); + return 0; +} +</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P016.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">P016.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P016.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-tuition-c-P016_c', 'P016.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-tuition-c-P016_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P016.c"> + <pre><code class="language-c">/* WAP to calculate and display radius of a +circle by taking the area as input */ +// Author - Amit Dutta, Date - Unknown + +#include&lt;stdio.h&gt; +#include&lt;math.h&gt; +int main() { + double area, r; + printf(&quot;Enter the area of a circle : &quot;); + scanf(&quot;%lf&quot;, &amp;area); + r = sqrt((7 * area) / 22); + printf(&quot;\nRadius : %lf&quot;, r); + return 0; +} +</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P017.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">P017.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P017.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-tuition-c-P017_c', 'P017.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-tuition-c-P017_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P017.c"> + <pre><code class="language-c">/* Find maximum between three number. */ +// Author - Amit Dutta, Date - Unknown + +#include &lt;stdio.h&gt; +int main() +{ + int a, b, c, max; + printf(&quot;Enter the value for a, b, c : &quot;); + scanf(&quot;%d %d %d&quot;, &amp;a, &amp;b, &amp;c); + max = a; + if (max &lt; b) + max = b; + if (max &lt; c) + max = c; + printf(&quot;Maximum : %d&quot;, max); + return 0; +}</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P018.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">P018.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P018.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-tuition-c-P018_c', 'P018.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-tuition-c-P018_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P018.c"> + <pre><code class="language-c">/* WAP to input the cost price and selling price and +calculate profit, profit percentage, loss percentage or +display the manage nither profit nor loss. */ +// Author - Amit Dutta, Date - Unknown + +#include &lt;stdio.h&gt; +int main() +{ + double cost, sell, pro, prop, loss, lossp; + printf(&quot;Enter the cost and selling price : &quot;); + scanf(&quot;%lf %lf&quot;, &amp;cost, &amp;sell); + if (sell &gt; cost) + { + pro = sell - cost; + prop = (pro / cost) * 100; + printf(&quot;Profit : RS %g, Profit Percentage : %g&quot;, pro, prop); + } + else if (sell &lt; cost) + { + loss = cost - sell; + lossp = (loss / cost) * 100; + printf(&quot;Loss : RS %g, Loss Percentage : %g&quot;, loss, lossp); + } + else + printf(&quot;Neither loss nor Profit.&quot;); + return 0; +}</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P019.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">P019.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P019.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-tuition-c-P019_c', 'P019.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-tuition-c-P019_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P019.c"> + <pre><code class="language-c">/* WAP to input the distance covered and calculate +the amount to be paid by the passanger. + Distance Rate + =&lt;5KM RS 90 + next 10KM RS 20/KM + next 10KM RS 10/KM + more than 25KM RS 9/KM +*/ +// Author - Amit Dutta, Date - Unknown + +#include &lt;stdio.h&gt; +int main() +{ + double dis, amt; + printf(&quot;Enter the distance : &quot;); + scanf(&quot;%lf&quot;, &amp;dis); + if (dis &lt;= 5.0) + amt = 90.0; + else if (dis &gt; 5.0 &amp;&amp; dis &lt;= 15.0) + amt = 90.0 + (dis - 5.0) * 20; + else if (dis &gt; 15.0 &amp;&amp; dis &lt;= 25.0) + amt = 90.0 + 200.0 + (dis - 15.0) * 10; + else if (dis &gt; 25.0) + amt = 90.0 + 200.0 + 100.0 + (dis - 25.0) * 9; + printf(&quot;\nAmount to be paid : %g&quot;, amt); + return 0; +}</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P020.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">P020.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P020.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-tuition-c-P020_c', 'P020.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-tuition-c-P020_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P020.c"> + <pre><code class="language-c">/* WAP to calculate and display the maturity amount +taking the sum and number of days as input. + No. of Days Rate of Interest + Upto 180 days 5.5 % + 181 to 364 days 7.5 % + exact 365 days 9.0 % + more than 365 days 8.5 % +*/ +// Author - Amit Dutta, Date - Unknown + +#include &lt;stdio.h&gt; +int main() +{ + double nod, amt, s, i; + printf(&quot;Enter the amount and the time in days : &quot;); + scanf(&quot;%lf %lf&quot;, &amp;s, &amp;nod); + if (nod &lt;= 180) + i = (s * 5.5 * (nod / 365)) / 100; + else if (nod &gt; 180.0 &amp;&amp; nod &lt;= 364.0) + i = (s * 7.5 * (nod / 365)) / 100; + else if (nod == 365.0) + i = (s * 9.0 * 1) / 100; + else if (nod &gt; 365.0) + i = (s * 8.5 * (nod / 365)) / 100; + amt = s + i; + printf(&quot;Amount to be paid : %g&quot;, amt); + return 0; +}</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P021.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">P021.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P021.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-tuition-c-P021_c', 'P021.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-tuition-c-P021_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P021.c"> + <pre><code class="language-c">/* WAP to input a positive number and check if it is a perfect +square number or not. */ +/* Author - Amit Dutta, Date - 8th OCT, 2025 */ +// This code has not been compiled. +// If you find any issues, please create a new issue on GitHub regarding them. + +#include &lt;stdio.h&gt; +#include &lt;math.h&gt; +int main() +{ + int n, temp; + double sr; + printf(&quot;Enter the number : &quot;); + scanf(&quot;%d&quot;, &amp;n); + sr = sqrt(n); + temp = (int)sr; + if (temp * temp == n) + printf(&quot;\nThis is a perfect square.&quot;); + else + printf(&quot;\nThis is not a perfect square.&quot;); + return 0; +}</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P022.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">P022.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P022.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-tuition-c-P022_c', 'P022.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-tuition-c-P022_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P022.c"> + <pre><code class="language-c">/* WAP to find out smallest of three numbers without using if_else block. */ +/* Author - Amit Dutta, Date - 8th OCT, 2025 */ +// This code has not been compiled. +// If you find any issues, please create a new issue on GitHub regarding them. + +#include &lt;stdio.h&gt; +int main() +{ + int a, b, c, min; + printf(&quot;Enter three number : &quot;); + scanf(&quot;%d %d %d&quot;, &amp;a, &amp;b, &amp;c); + min = (a &lt; b &amp;&amp; a &lt; c) ? a : (b &lt; a &amp;&amp; b &lt; c) ? b + : c; + printf(&quot;Minimum = %d&quot;, min); + return 0; +}</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P023.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">P023.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P023.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-tuition-c-P023_c', 'P023.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-tuition-c-P023_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P023.c"> + <pre><code class="language-c">/* WAP to input the total cost and compute the amount to be paid +by the customer. */ +/* Author - Amit Dutta, Date - 8th OCT, 2025 */ +// This code has not been compiled. +// If you find any issues, please create a new issue on GitHub regarding them. + +#include &lt;stdio.h&gt; +int main() +{ + double cost, amt; + printf(&quot;Enter the total cost : &quot;); + scanf(&quot;%lf&quot;, &amp;cost); + if (cost &lt;= 2000) + amt = cost * 0.94; + else if (cost &gt; 2000 &amp;&amp; cost &lt;= 5000) + amt = cost * 0.9; + else if (cost &gt; 5000 &amp;&amp; cost &lt;= 10000) + amt = cost * 0.85; + else if (cost &gt; 10000) + amt = cost * 0.8; + printf(&quot;\nAmount to be paid : %g&quot;, amt); + return 0; +}</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P024.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">P024.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P024.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-tuition-c-P024_c', 'P024.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-tuition-c-P024_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P024.c"> + <pre><code class="language-c">/* WAP to check whether a year is leapyear or not. */ +/* Author - Amit Dutta, Date - 8th OCT, 2025 */ +// This code has not been compiled. +// If you find any issues, please create a new issue on GitHub regarding them. + +#include &lt;stdio.h&gt; +int main() +{ + int year; + printf(&quot;Enter the year : &quot;); + scanf(&quot;%d&quot;, &amp;year); + if (year % 4 == 0 &amp;&amp; year % 100 != 0) + printf(&quot;\nYear %d is a leapyear.&quot;, year); + else if (year % 400 == 0) + printf(&quot;\nYear %d is a leapyear (Century).&quot;, year); + else + printf(&quot;\nYear %d is not a leapyear.&quot;, year); + return 0; +}</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P025.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">P025.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P025.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-tuition-c-P025_c', 'P025.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-tuition-c-P025_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P025.c"> + <pre><code class="language-c">/* WAP to input the electricity unit consumed and calculate the total +bill amount according to the given condition : + for 1st 50 unit Rs. 0.50 per unit + next 100 unit Rs. 0.75 per unit + next 100 unit Rs. 1.20 per unit + above 250 unit Rs. 1.50 per unit +And additional charge of 20 percent is added to the bill. +*/ +/* Author - Amit Dutta, Date - 8th OCT, 2025 */ +// This code has not been compiled. +// If you find any issues, please create a new issue on GitHub regarding them. + +#include &lt;stdio.h&gt; +int main() +{ + double unit, amt; + printf(&quot;Enter the electricity consp(unit) : &quot;); + scanf(&quot;%lf&quot;, &amp;amt); + if (unit &lt;= 50) + amt = unit * 0.50; + else if (unit &gt; 50 &amp;&amp; unit &lt;= 50) + amt = 25 + ((unit - 50) * 0.75); + else if (unit &gt; 150 &amp;&amp; unit &lt;= 250) + amt = 25 + 75 + ((unit - 150) * 1.20); + else if (unit &gt; 250) + amt = 25 + 75 + 120 + ((unit - 250) * 1.50); + amt = amt * 1.20; + printf(&quot;\nAmount to be paid : %g&quot;, amt); + return 0; +}</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P026.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">P026.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P026.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-tuition-c-P026_c', 'P026.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-tuition-c-P026_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P026.c"> + <pre><code class="language-c">/* WAP to input sum (p), rate of interest (r), time (t) and type of interest +(&#x27;s&#x27; for simple interest amd &#x27;c&#x27; for compound interest). Calculate and display +the interest earned + si = (p * r * t) / 100 + compoundInterest = p * ((1 + r / 100)^t - 1) +*/ +/* Author - Amit Dutta, Date - 8th OCT, 2025 */ + +#include &lt;stdio.h&gt; +#include &lt;math.h&gt; +#include &lt;ctype.h&gt; +int main() +{ + double principalAmount, rateOfInterest, timePeriod, simpleInterest, compoundInterest; + char mode; + printf(&quot;Enter the principle amount, Rate of interest, Time : &quot;); + scanf(&quot;%lf %lf %lf&quot;, &amp;principalAmount, &amp;rateOfInterest, &amp;timePeriod); + printf(&quot;\nEnter the mode (&#x27;s&#x27; : simple interest, &#x27;c&#x27; : compound interest) : &quot;); + scanf(&quot; %c&quot;, &amp;mode); + mode = tolower(mode); + switch (mode) + { + case &#x27;s&#x27;: + simpleInterest = (principalAmount * rateOfInterest * timePeriod) / 100; + printf(&quot;\nSimple Interest : %g&quot;, simpleInterest); + break; + case &#x27;c&#x27;: + compoundInterest = principalAmount * (pow((1 + rateOfInterest / 100), timePeriod) - 1); + printf(&quot;\nCompound Interest : %g&quot;, compoundInterest); + break; + default: + printf(&quot;\nInvalid Input&quot;); + return 1; + } + return 0; +}</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P027.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">P027.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P027.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-tuition-c-P027_c', 'P027.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-tuition-c-P027_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P027.c"> + <pre><code class="language-c">/* Purchase Discount on Discount on + Amount Laptop Desktop + -------- ----------- ----------- + Upto 20k 3.0% 5.0% + 20001 - 50k 5.0% 7.5% + 50001 - 75k 7.5% 10.5% + more than 75k 10.0% 15.0% +WAP to input amount of purchase and type of purchase (&#x27;L&#x27; : laptop, &#x27;D&#x27; : desktop) +and display the discount amount and the discounted price (Net Amount). +*/ +/* Author - Amit Dutta, Date - 8th OCT, 2025 */ +// This code has not been compiled. +// If you find any issues, please create a new issue on GitHub regarding them. + +#include &lt;stdio.h&gt; +#include &lt;ctype.h&gt; +int main() +{ + double principal_amount, desktop_discount, laptop_discount, discount_amount, discounted_price; + char choice; + printf(&quot;Enter the purchase amount : &quot;); + scanf(&quot;%lf&quot;, &amp;principal_amount); + printf(&quot;Type of purchase (&#x27;L&#x27; : Laptop, &#x27;D&#x27; : Desktop) : &quot;); + scanf(&quot; %c&quot;, &amp;choice); + choice = toupper(choice); + if (principal_amount &lt;= 20000) + { + laptop_discount = 0.03; + desktop_discount = 0.05; + } + else if (principal_amount &gt; 20000 &amp;&amp; principal_amount &lt;= 50000) + { + laptop_discount = 0.05; + desktop_discount = 0.075; + } + else if (principal_amount &gt; 50000 &amp;&amp; principal_amount &lt;= 75000) + { + laptop_discount = 0.075; + desktop_discount = 0.105; + } + else if (principal_amount &gt; 75000) + { + laptop_discount = 0.1; + desktop_discount = 0.15; + } + switch (choice) + { + case &#x27;L&#x27;: + discount_amount = principal_amount * laptop_discount; + discounted_price = principal_amount - discount_amount; + printf(&quot;\nDiscount Amount : %g&quot; + &quot;\nDiscounted Price : %g&quot;, + discount_amount, discounted_price); + break; + case &#x27;D&#x27;: + discount_amount = principal_amount * desktop_discount; + discounted_price = principal_amount - discount_amount; + printf(&quot;\nDiscount Amount : %g&quot; + &quot;\nDiscounted Price : %g&quot;, + discount_amount, discounted_price); + break; + default: + printf(&quot;\nInvalid Input.&quot;); + return 1; + } + return 0; +}</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P028.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">P028.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P028.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-tuition-c-P028_c', 'P028.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-tuition-c-P028_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P028.c"> + <pre><code class="language-c">/* WAP to calculate factorial of a number */ +/* Author - Amit Dutta, Date - 11th OCT, 2025 */ + +#include &lt;stdio.h&gt; +int main() +{ + int i = 1, num, fact = 1; + printf(&quot;Enter the number : &quot;); + if (scanf(&quot;%d&quot;, &amp;num) != 1) + { + printf(&quot;\nPlease enter a number.&quot;); + return 1; + } + if (num == 0) + { + printf(&quot;\nFactorial of 0 : 1&quot;); + return 0; + } + if (num &lt; 0) + { + printf(&quot;\nFactorial of %d : UNDEFINED&quot;, num); + return 0; + } + while (i &lt;= num) + { + fact = fact * i; + i++; + } + printf(&quot;Factorial of %d : %d&quot;, num, fact); + return 0; +}</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P029.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">P029.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P029.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-tuition-c-P029_c', 'P029.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-tuition-c-P029_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P029.c"> + <pre><code class="language-c">/* WAP to perform addition of first n natural numbers. sum = 1 + 2 + 3 + ... */ +/* Author - Amit Dutta, Date - 11th OCT, 2025 */ + +#include &lt;stdio.h&gt; +int main() +{ + int num, i = 0, result = 0; + printf(&quot;Enter the value for n : &quot;); + if (scanf(&quot;%d&quot;, &amp;num) != 1) + { + printf(&quot;\nPlease enter a number.&quot;); + return 1; + } + if (num &lt; 1) + { + printf(&quot;\nPlease enter a positive number.&quot;); + return 1; + } + while (i &lt;= num) + { + result = result + i; + i++; + } + printf(&quot;\nResult : %d&quot;, result); + return 0; +}</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P030.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">P030.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P030.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-tuition-c-P030_c', 'P030.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-tuition-c-P030_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P030.c"> + <pre><code class="language-c">/* Display the first 15 terms of the series. */ +/* Author - Amit Dutta, Date - 11th OCT, 2025 */ + +#include &lt;stdio.h&gt; +#include &lt;math.h&gt; + +int main() +{ + int i, r; + + // 3, 6, 9, 12, ... + { + i = 3, r = 0; + printf(&quot;Series 1 (3, 6, 9, 12, ...) :&quot;); + while (i &lt;= 15) + { + r = r + 3; + printf(&quot; %d&quot;, r); + i++; + } + } + + // 1, 4, 9, 16, ... + { + i = 1; + printf(&quot;\nSeries 2 (1, 4, 9, 16, ...) :&quot;); + while (i &lt;= 15) + { + printf(&quot; %d&quot;, i * i); + i++; + } + } + + // 4, 8, 16, 32, ... + { + i = 1, r = 2; + printf(&quot;\nSeries 3 (4, 8, 16, 32, ...) :&quot;); + while (i &lt;= 15) + { + r = r * 2; + printf(&quot; %d&quot;, r); + i++; + } + } + + // 0, 7, 26, ... + { + i = 1, r; + printf(&quot;\nSeries 4 (0, 7, 26, ...) :&quot;); + while (i &lt;= 15) + { + r = (int)pow(i, 3) - 1; + printf(&quot; %d&quot;, r); + i++; + } + } + + return 0; +} +</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P031.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">P031.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P031.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-tuition-c-P031_c', 'P031.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-tuition-c-P031_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P031.c"> + <pre><code class="language-c">/* Find the sum of the series */ +/* Author - Amit Dutta, Date - 11th OCT, 2025 */ + +#include &lt;stdio.h&gt; +#include &lt;math.h&gt; + +int main() +{ + double a, res, n; + int i; + + // s = (a ^ 2) + (a ^ 2 / 2) + (a ^ 2 / 3) + ... + (a ^ 2 / 10) + { + res = 0, i = 1; + printf(&quot;--- s = (a ^ 2) + (a ^ 2 / 2) + (a ^ 2 / 3) + ... + (a ^ 2 / 10) ---&quot;); + printf(&quot;\nEnter the number : &quot;); + scanf(&quot;%lf&quot;, &amp;a); + while (i &lt;= 10) + { + res = res + ((a * a) / i); + i++; + } + printf(&quot;S = %g&quot;, res); + } + + // s = 1 + (2 ^ 2 / a) + (3 ^ 3 / a ^ 2) + ... + n + { + res = 0, i = 0; + printf(&quot;\n--- // s = 1 + (2 ^ 2 / a) + (3 ^ 3 / a ^ 2) + ... + n ---&quot;); + printf(&quot;\nEnter the value for a and n : &quot;); + scanf(&quot; %lf %lf&quot;, &amp;a, &amp;n); + while (i &lt;= n - 1) + { + res = res + (pow(i + 1, i + 1) / pow(a, i)); + i++; + } + printf(&quot;S = %g&quot;, res); + } + + return 0; +}</code></pre> + </div> </li> <li> - <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P032.c" target="_blank" class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> <span class="text-gray-700">P032.c</span> - <span class="ml-auto text-green-500 text-sm">View Code &rarr;</span> - </a> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P032.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-tuition-c-P032_c', 'P032.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-tuition-c-P032_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/tuition-c/P032.c"> + <pre><code class="language-c">/* WAP to input a number and check whether it is a Niven number +or not. (When a number is divisible by its sum of digit) e.g. : n = 126*/ +/* Author - Amit Dutta, Date - 11th OCT, 2025 */ + +#include &lt;stdio.h&gt; +int main() +{ + int n, temp, sod = 0; + printf(&quot;Enter the number : &quot;); + scanf(&quot;%d&quot;, &amp;n); + temp = n; + while (temp &gt; 0) + { + sod = sod + (temp % 10); + temp = temp / 10; + } + if (n % sod == 0) + printf(&quot;\nIt is Niven number.&quot;); + else + printf(&quot;\nIt is not a Niven number.&quot;); + return 0; +}</code></pre> + </div> </li> </ul> </div> </li> - </ul> - </div> - </div> - <footer class="text-center py-4 bg-gray-100 border-t"> - <p class="text-sm text-gray-500">This page is an index for the <a href="https://github.com/notamitgamer/bsc" class="text-blue-600 hover:underline">bsc repository</a>.</p> - </footer> + </ul> + </div> </div> + <footer class="text-center py-4 bg-gray-50 border-t"> + <p class="text-sm text-gray-500"> + This page is an index for the + <a + href="https://github.com/notamitgamer/bsc" + class="text-blue-600 hover:underline" + >bsc repository</a + >. + </p> + </footer> + </div> </div> - + + <!-- Code Viewer Modal --> + <div + id="code-modal" + class="fixed inset-0 bg-gray-900 bg-opacity-80 flex items-center justify-center p-4 hidden z-50" + > + <div + class="bg-gray-800 text-gray-100 rounded-lg shadow-2xl w-full max-w-5xl max-h-full flex flex-col" + > + <!-- Modal Header --> + <div + class="flex items-center justify-between p-4 border-b border-gray-700 bg-gray-900 rounded-t-lg" + > + <h3 id="modal-filename" class="text-lg font-mono text-gray-300"></h3> + <div class="flex items-center space-x-3"> + <button + id="share-btn" + class="bg-gray-700 text-gray-200 p-2 rounded-md hover:bg-gray-600 relative transition-colors" + title="Share file link (Copies GitHub URL if sharing is unavailable)" + > + <!-- Default Share Icon --> + <svg + class="w-5 h-5" + fill="none" + stroke="currentColor" + viewBox="0 0 24 24" + xmlns="http://www.w3.org/2000/svg" + id="share-icon-default" + > + <path + stroke-linecap="round" + stroke-linejoin="round" + stroke-width="2" + d="M4 12v8a2 2 0 002 2h12a2 2 0 002-2v-8m-4-6l-4-4-4 4m4-4v13" + ></path> + </svg> + <!-- Success Checkmark Icon (Hidden by Default) --> + <svg + class="w-5 h-5 absolute inset-0 m-auto hidden text-green-400" + id="share-icon-success" + fill="none" + stroke="currentColor" + viewBox="0 0 24 24" + xmlns="http://www.w3.org/2000/svg" + > + <path + stroke-linecap="round" + stroke-linejoin="round" + stroke-width="2" + d="M5 13l4 4L19 7" + ></path> + </svg> + </button> + <button + id="copy-code-btn" + class="bg-gray-700 text-gray-200 p-2 rounded-md hover:bg-gray-600 relative transition-colors" + title="Copy code to clipboard" + > + <!-- Default Copy Icon --> + <svg + xmlns="http://www.w3.org/2000/svg" + width="16" + height="16" + fill="currentColor" + class="bi bi-copy w-5 h-5" + viewBox="0 0 16 16" + id="copy-icon-default" + > + <path + fill-rule="evenodd" + d="M4 2a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2zm2-1a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V2a1 1 0 0 0-1-1zM2 5a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1v-1h1v1a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h1v1z" + /> + </svg> + <!-- Success Checkmark Icon (Hidden by Default) --> + <svg + class="w-5 h-5 absolute inset-0 m-auto hidden text-green-400" + id="copy-icon-success" + fill="none" + stroke="currentColor" + viewBox="0 0 24 24" + xmlns="http://www.w3.org/2000/svg" + > + <path + stroke-linecap="round" + stroke-linejoin="round" + stroke-width="2" + d="M5 13l4 4L19 7" + ></path> + </svg> + </button> + <button + onclick="hideCode()" + class="text-gray-400 hover:text-white text-3xl leading-none" + > + &times; + </button> + </div> + </div> + <!-- Modal Body --> + <div id="modal-body" class="p-1 overflow-y-auto"> + <div id="modal-code-container" class="rounded-b-lg"> + <!-- Code will be injected here --> + </div> + </div> + </div> + </div> + <script> - function toggleFolder(folderName) { - const content = document.getElementById(`folder-${folderName}`); - const chevron = document.getElementById(`chevron-${folderName}`); - - if (content.classList.contains('hidden')) { - content.classList.remove('hidden'); - chevron.classList.add('rotated'); - } else { - content.classList.add('hidden'); - chevron.classList.remove('rotated'); + function toggleFolder(folderName) { + const content = document.getElementById(`folder-${folderName}`); + const chevron = document.getElementById(`chevron-${folderName}`); + + if (content.classList.contains("hidden")) { + content.classList.remove("hidden"); + chevron.classList.add("rotated"); + } else { + content.classList.add("hidden"); + chevron.classList.remove("rotated"); + } + } + + const modal = document.getElementById("code-modal"); + const modalFilename = document.getElementById("modal-filename"); + const modalCodeContainer = document.getElementById( + "modal-code-container" + ); + + const copyBtn = document.getElementById("copy-code-btn"); + const copyIconDefault = document.getElementById("copy-icon-default"); + const copyIconSuccess = document.getElementById("copy-icon-success"); + + const shareBtn = document.getElementById("share-btn"); + const shareIconDefault = document.getElementById("share-icon-default"); + const shareIconSuccess = document.getElementById("share-icon-success"); + + let currentFileUrl = ""; + + /** + * Shows a successful copy animation on a button. + * @param {HTMLElement} button - The button element. + * @param {HTMLElement} defaultIcon - The default icon element. + * @param {HTMLElement} successIcon - The success icon element. + */ + function animateSuccess(button, defaultIcon, successIcon) { + // 1. Swap icons + defaultIcon.classList.add("hidden"); + successIcon.classList.remove("hidden"); + + // 2. Apply success visual cue (green background pulse) + button.classList.add("btn-success-pulse"); + button.classList.remove("bg-gray-700", "hover:bg-gray-600"); + + // 3. Revert after 2 seconds + setTimeout(() => { + successIcon.classList.add("hidden"); + defaultIcon.classList.remove("hidden"); + button.classList.remove("btn-success-pulse"); + button.classList.add("bg-gray-700", "hover:bg-gray-600"); + }, 2000); + } + + function showCode(codeBlockId, filename) { + const codeBlock = document.getElementById(codeBlockId); + if (codeBlock) { + modalFilename.textContent = filename; + modalCodeContainer.innerHTML = codeBlock.innerHTML; + + currentFileUrl = codeBlock.dataset.githubUrl || ""; + + hljs.highlightElement(modalCodeContainer.querySelector("code")); + + modal.classList.remove("hidden"); + document.body.style.overflow = "hidden"; + } + } + + function hideCode() { + modal.classList.add("hidden"); + document.body.style.overflow = "auto"; + } + + copyBtn.addEventListener("click", () => { + const codeToCopy = modalCodeContainer.querySelector("code").innerText; + navigator.clipboard.writeText(codeToCopy).then( + () => { + // Use the reusable animation function for code copy + animateSuccess(copyBtn, copyIconDefault, copyIconSuccess); + }, + (err) => { + console.error("Failed to copy text: ", err); + // Replace old alert with a console error or a custom message box if needed + } + ); + }); + + shareBtn.addEventListener("click", async () => { + // Ensure currentFileUrl is set (it's the GitHub link) + if (!currentFileUrl) return; + + const shareData = { + title: modalFilename.textContent, + text: `Check out the code for ${modalFilename.textContent}`, + url: currentFileUrl, + }; + + // 1. Try to use Web Share API + if (navigator.share) { + try { + await navigator.share(shareData); + // If sharing is successful, no need for clipboard animation + } catch (err) { + // User likely cancelled the share dialog, no action needed + if (err.name !== 'AbortError') { + console.error("Share failed:", err.message); } + } + } else { + // 2. Fallback: Copy URL to clipboard + navigator.clipboard.writeText(currentFileUrl).then(() => { + // Trigger animation to show link was copied + animateSuccess(shareBtn, shareIconDefault, shareIconSuccess); + }); + } + }); + + document.addEventListener("keydown", (e) => { + if (e.key === "Escape" && !modal.classList.contains("hidden")) { + hideCode(); } + }); </script> -</body> + </body> </html> diff --git a/docs/template.html b/docs/template.html @@ -1,54 +1,314 @@ <!DOCTYPE html> <html lang="en"> -<head> - <meta charset="UTF-8"> - <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <head> + <meta charset="UTF-8" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>BSc Repository File Index</title> <script src="https://cdn.tailwindcss.com"></script> - <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet"> + <link + href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" + rel="stylesheet" + /> + <link + rel="stylesheet" + href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/github-dark.min.css" + /> + <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script> + <style> - body { - font-family: 'Inter', sans-serif; + body { + font-family: "Inter", sans-serif; + } + .chevron.rotated { + transform: rotate(180deg); + } + #modal-body pre { + max-height: 70vh; + } + /* Animation for success feedback */ + .btn-success-pulse { + background-color: #10b981 !important; /* Tailwind green-500 */ + box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5); /* green-500 with opacity */ + animation: pulse-success 0.5s ease-out; + } + @keyframes pulse-success { + 0% { + box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5); } - .chevron.rotated { - transform: rotate(180deg); + 50% { + box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); } + 100% { + box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); + } + } </style> -</head> -<body class="bg-gray-50"> + </head> + <body class="bg-gray-100"> <div class="container mx-auto px-4 py-8 md:py-16"> - <div class="max-w-4xl mx-auto bg-white rounded-2xl shadow-lg overflow-hidden"> - <div class="p-8"> - <div class="text-center mb-8"> - <h1 class="text-3xl md:text-4xl font-bold text-gray-800">BSc Repository Contents</h1> - <p class="text-gray-500 mt-2">A quick navigation guide to the files in the repository.</p> - </div> - <div class="space-y-4"> - <h2 class="text-lg font-semibold text-gray-700 border-b pb-2">Files and Folders</h2> - <ul class="space-y-3"> - <!--FILE_LIST_PLACEHOLDER--> - </ul> - </div> - </div> - <footer class="text-center py-4 bg-gray-100 border-t"> - <p class="text-sm text-gray-500">This page is an index for the <a href="https://github.com/notamitgamer/bsc" class="text-blue-600 hover:underline">bsc repository</a>.</p> - </footer> + <div + class="max-w-4xl mx-auto bg-white rounded-2xl shadow-lg overflow-hidden" + > + <div class="p-8"> + <div class="text-center mb-8"> + <h1 class="text-3xl md:text-4xl font-bold text-gray-800"> + BSc Repository Contents + </h1> + <p class="text-gray-500 mt-2"> + A quick navigation guide to the files in the repository. + </p> + </div> + <div class="space-y-4"> + <h2 class="text-lg font-semibold text-gray-700 border-b pb-2"> + Files and Folders + </h2> + <ul class="space-y-3"> + <!--FILE_LIST_PLACEHOLDER--> + </ul> + </div> + </div> + <footer class="text-center py-4 bg-gray-50 border-t"> + <p class="text-sm text-gray-500"> + This page is an index for the + <a + href="https://github.com/notamitgamer/bsc" + class="text-blue-600 hover:underline" + >bsc repository</a + >. + </p> + </footer> + </div> + </div> + + <!-- Code Viewer Modal --> + <div + id="code-modal" + class="fixed inset-0 bg-gray-900 bg-opacity-80 flex items-center justify-center p-4 hidden z-50" + > + <div + class="bg-gray-800 text-gray-100 rounded-lg shadow-2xl w-full max-w-5xl max-h-full flex flex-col" + > + <!-- Modal Header --> + <div + class="flex items-center justify-between p-4 border-b border-gray-700 bg-gray-900 rounded-t-lg" + > + <h3 id="modal-filename" class="text-lg font-mono text-gray-300"></h3> + <div class="flex items-center space-x-3"> + <button + id="share-btn" + class="bg-gray-700 text-gray-200 p-2 rounded-md hover:bg-gray-600 relative transition-colors" + title="Share file link (Copies GitHub URL if sharing is unavailable)" + > + <!-- Default Share Icon --> + <svg + class="w-5 h-5" + fill="none" + stroke="currentColor" + viewBox="0 0 24 24" + xmlns="http://www.w3.org/2000/svg" + id="share-icon-default" + > + <path + stroke-linecap="round" + stroke-linejoin="round" + stroke-width="2" + d="M4 12v8a2 2 0 002 2h12a2 2 0 002-2v-8m-4-6l-4-4-4 4m4-4v13" + ></path> + </svg> + <!-- Success Checkmark Icon (Hidden by Default) --> + <svg + class="w-5 h-5 absolute inset-0 m-auto hidden text-green-400" + id="share-icon-success" + fill="none" + stroke="currentColor" + viewBox="0 0 24 24" + xmlns="http://www.w3.org/2000/svg" + > + <path + stroke-linecap="round" + stroke-linejoin="round" + stroke-width="2" + d="M5 13l4 4L19 7" + ></path> + </svg> + </button> + <button + id="copy-code-btn" + class="bg-gray-700 text-gray-200 p-2 rounded-md hover:bg-gray-600 relative transition-colors" + title="Copy code to clipboard" + > + <!-- Default Copy Icon --> + <svg + xmlns="http://www.w3.org/2000/svg" + width="16" + height="16" + fill="currentColor" + class="bi bi-copy w-5 h-5" + viewBox="0 0 16 16" + id="copy-icon-default" + > + <path + fill-rule="evenodd" + d="M4 2a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2zm2-1a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V2a1 1 0 0 0-1-1zM2 5a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1v-1h1v1a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h1v1z" + /> + </svg> + <!-- Success Checkmark Icon (Hidden by Default) --> + <svg + class="w-5 h-5 absolute inset-0 m-auto hidden text-green-400" + id="copy-icon-success" + fill="none" + stroke="currentColor" + viewBox="0 0 24 24" + xmlns="http://www.w3.org/2000/svg" + > + <path + stroke-linecap="round" + stroke-linejoin="round" + stroke-width="2" + d="M5 13l4 4L19 7" + ></path> + </svg> + </button> + <button + onclick="hideCode()" + class="text-gray-400 hover:text-white text-3xl leading-none" + > + &times; + </button> + </div> + </div> + <!-- Modal Body --> + <div id="modal-body" class="p-1 overflow-y-auto"> + <div id="modal-code-container" class="rounded-b-lg"> + <!-- Code will be injected here --> + </div> </div> + </div> </div> - + <script> - function toggleFolder(folderName) { - const content = document.getElementById(`folder-${folderName}`); - const chevron = document.getElementById(`chevron-${folderName}`); - - if (content.classList.contains('hidden')) { - content.classList.remove('hidden'); - chevron.classList.add('rotated'); - } else { - content.classList.add('hidden'); - chevron.classList.remove('rotated'); + function toggleFolder(folderName) { + const content = document.getElementById(`folder-${folderName}`); + const chevron = document.getElementById(`chevron-${folderName}`); + + if (content.classList.contains("hidden")) { + content.classList.remove("hidden"); + chevron.classList.add("rotated"); + } else { + content.classList.add("hidden"); + chevron.classList.remove("rotated"); + } + } + + const modal = document.getElementById("code-modal"); + const modalFilename = document.getElementById("modal-filename"); + const modalCodeContainer = document.getElementById( + "modal-code-container" + ); + + const copyBtn = document.getElementById("copy-code-btn"); + const copyIconDefault = document.getElementById("copy-icon-default"); + const copyIconSuccess = document.getElementById("copy-icon-success"); + + const shareBtn = document.getElementById("share-btn"); + const shareIconDefault = document.getElementById("share-icon-default"); + const shareIconSuccess = document.getElementById("share-icon-success"); + + let currentFileUrl = ""; + + /** + * Shows a successful copy animation on a button. + * @param {HTMLElement} button - The button element. + * @param {HTMLElement} defaultIcon - The default icon element. + * @param {HTMLElement} successIcon - The success icon element. + */ + function animateSuccess(button, defaultIcon, successIcon) { + // 1. Swap icons + defaultIcon.classList.add("hidden"); + successIcon.classList.remove("hidden"); + + // 2. Apply success visual cue (green background pulse) + button.classList.add("btn-success-pulse"); + button.classList.remove("bg-gray-700", "hover:bg-gray-600"); + + // 3. Revert after 2 seconds + setTimeout(() => { + successIcon.classList.add("hidden"); + defaultIcon.classList.remove("hidden"); + button.classList.remove("btn-success-pulse"); + button.classList.add("bg-gray-700", "hover:bg-gray-600"); + }, 2000); + } + + function showCode(codeBlockId, filename) { + const codeBlock = document.getElementById(codeBlockId); + if (codeBlock) { + modalFilename.textContent = filename; + modalCodeContainer.innerHTML = codeBlock.innerHTML; + + currentFileUrl = codeBlock.dataset.githubUrl || ""; + + hljs.highlightElement(modalCodeContainer.querySelector("code")); + + modal.classList.remove("hidden"); + document.body.style.overflow = "hidden"; + } + } + + function hideCode() { + modal.classList.add("hidden"); + document.body.style.overflow = "auto"; + } + + copyBtn.addEventListener("click", () => { + const codeToCopy = modalCodeContainer.querySelector("code").innerText; + navigator.clipboard.writeText(codeToCopy).then( + () => { + // Use the reusable animation function for code copy + animateSuccess(copyBtn, copyIconDefault, copyIconSuccess); + }, + (err) => { + console.error("Failed to copy text: ", err); + // Replace old alert with a console error or a custom message box if needed + } + ); + }); + + shareBtn.addEventListener("click", async () => { + // Ensure currentFileUrl is set (it's the GitHub link) + if (!currentFileUrl) return; + + const shareData = { + title: modalFilename.textContent, + text: `Check out the code for ${modalFilename.textContent}`, + url: currentFileUrl, + }; + + // 1. Try to use Web Share API + if (navigator.share) { + try { + await navigator.share(shareData); + // If sharing is successful, no need for clipboard animation + } catch (err) { + // User likely cancelled the share dialog, no action needed + if (err.name !== 'AbortError') { + console.error("Share failed:", err.message); } + } + } else { + // 2. Fallback: Copy URL to clipboard + navigator.clipboard.writeText(currentFileUrl).then(() => { + // Trigger animation to show link was copied + animateSuccess(shareBtn, shareIconDefault, shareIconSuccess); + }); + } + }); + + document.addEventListener("keydown", (e) => { + if (e.key === "Escape" && !modal.classList.contains("hidden")) { + hideCode(); } + }); </script> -</body> + </body> </html>
© notamitgamer • Site Built: 2026-07-21 13:58:23 UTC • git-mirror commit: 1037f62 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror