اذهب إلى المحتوى
  • 0

حل مسائل بلغه c

مصعب عبد الكريم

السؤال

مسأله أخرى 

4-write a C program that allow the user to read the temperature in Fahrenheit degree (f), and then convert it Celsius degree (c) using the following equation:

c=5/9(f-32) 

after that print the degree before and after conversion 

5-write a C program that allow the user to enter character and print the ASCII code of character 

رابط هذا التعليق
شارك على الشبكات الإجتماعية

Recommended Posts

  • 0

أهلًا بك،

أنصحك أن تحاول تفكر في حلول الأسئلة بنفسك لأنها بسيطة جدًا وتحتاج فقط جملة إدخال للمستخدم ثم تطبيق شيفرة القانون المعطى بالسؤال ثم جملة إخراج للمستخدم

مع التفكير مرة على مرة سيزداد المنطق البرمجي لديك وتستطيع حل اسئلة متطورة أكثر ستواجهك مستقبلًا

هنا إجابة تحويل درجة الحرارة من فهرنهايت إلى سليزيوس

#include <stdio.h>

int main()
{
    float celsius, fahrenheit;

    /* Input temperature in fahrenheit */
    printf("Enter temperature in Fahrenheit: ");
    scanf("%f", &fahrenheit);

    /* Fahrenheit to celsius conversion formula */
    celsius = (fahrenheit - 32) * 5 / 9;

    /* Print the value of celsius */
    printf("%.2f Fahrenheit = %.2f Celsius", fahrenheit, celsius);

    return 0;
}

هنالك عدة طرق لطباعة الأسكي كود للرمز المدخل، أحدهم الحل التالي

#include <stdio.h>
int main()
{
    char c;
    printf("Enter a character: ");
    // Reads character input from the user
    scanf("%c", &c);  
    
    // %d displays the integer value of a character
    // %c displays the actual character
    printf("ASCII value of %c = %d", c, c);
    return 0;
}

 

رابط هذا التعليق
شارك على الشبكات الإجتماعية

انضم إلى النقاش

يمكنك أن تنشر الآن وتسجل لاحقًا. إذا كان لديك حساب، فسجل الدخول الآن لتنشر باسم حسابك.

زائر
أجب على هذا السؤال...

×   لقد أضفت محتوى بخط أو تنسيق مختلف.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   جرى استعادة المحتوى السابق..   امسح المحرر

×   You cannot paste images directly. Upload or insert images from URL.

  • إعلانات

  • تابعنا على



×
×
  • أضف...