اكتب برنامج C للحصول على الفرق المطلق بين n و 51 إذا كانت n أكبر من 51 ، فقم بثلاثة أضعاف الفرق المطلق
الأجوبة
ابحث عن مسائل برمجة سي c | C programming بالانجليزي
/*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;
}
-
2021-05-03
- | Wassim
- | إبلاغ عن إساءة
أسئلة مشابهة