A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /home/premierconsult/public_html/index.php:65)

Filename: core/Input.php

Line Number: 408

A PHP Error was encountered

Severity: Warning

Message: session_start(): Cannot send session cookie - headers already sent by (output started at /home/premierconsult/public_html/index.php:65)

Filename: Session/Session.php

Line Number: 143

A PHP Error was encountered

Severity: Warning

Message: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/premierconsult/public_html/index.php:65)

Filename: Session/Session.php

Line Number: 143

A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /home/premierconsult/public_html/index.php:65)

Filename: controllers/Questions.php

Line Number: 330

اكتب برنامج C للحصول على الفرق المطلق بين n و 51 إذا كانت n أكبر من 51 ، فقم بثلاثة أضعاف الفرق المطلق

اكتب برنامج C للحصول على الفرق المطلق بين n و 51 إذا كانت n أكبر من 51 ، فقم بثلاثة أضعاف الفرق المطلق


اكتب برنامج C للحصول على الفرق المطلق بين n و 51 إذا كانت n أكبر من 51 ، فقم بثلاثة أضعاف الفرق المطلق

الخرج المتوقع :

6
21
0

الأجوبة

/*Write a C program to get the absolute difference between n and 51. If n is greater than 51 return triple the absolute difference*/

#include <stdio.h>
int main(void){
    printf("%d",test(53));
    printf("\n%d",test(30));
    printf("\n%d",test(51));
    }
    
   int test(int n)
        {
         const int x = 51;

            if (n > x)
            {
                return (n - x)*3;
            }
            return x - n;
        }
هل كان المحتوى مفيد؟

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...