Академический Документы
Профессиональный Документы
Культура Документы
#include<stdio.h> int main() { int absolute(int n); int n; printf("Enter a number to find its absolute value"); scanf("%d",&n); printf("The absolute value of %d is %d ",n,absolute(n)); return 0; } int absolute(int n) { if(n<0) return -n; else return n; }
Output :
Output :
Output :
inner block m = 30 k = 20 ::m = 10 outer block m = 20 ::m = 10
:";
friend time addtime(time temp1, time temp2) { time temp3; temp3.hh=temp1.hh+temp2.hh; temp3.mm=temp1.mm+temp2.mm; temp3.ss=temp1.ss+temp2.ss; if(temp3.ss>59) { temp3.ss=temp3.ss-60; temp3.mm++; if(temp3.mm>59) { temp3.mm=temp3.mm-60; temp3.hh++; }
int main() { time t1,t2,t3; t1.input(); t2.input(); t3=addtime(t1,t2); cout<<"Added time is :"; t3.output(); return 0; }
Output :
Enter time : 17 02 50 Enter time : 3 07 50 Added time is: 20:10:40
Output:
Enter value: 10 Value : 10 Modifying value using friend class. Value : 5
Output :
Enter x: Enter y: Contents Contents 4 5 of N1: x : 4 y : 5 of N2: x : 4 y : 5