Take 2 numbers from user and print sum, product, and subtraction of two numbers using functions?
[js]
#include<stdio.h>
int sum(int a, int b);
int product(int a, int b);
int subtraction(int a, int b);
int main(void){
int num1, num2;
printf(‘Please enter first number\n’);
scanf("%d\n", &num1);
printf(‘Please enter second number\n’);
scanf("%d\n", &num2);
printf("Sum of two numbers is: %d", sum(num1, num2));
printf("Product of two numbers is: %d", product(num1, num2));
printf("Subtraction of two numbers is: %d", subtraction(num1, num2));
}
int sum(int a, int b){
return a+b;
}
int product(int a, int b){
return a*b;
}
int subtraction(int a, int b){
return b-a;
}
[/js]
Results
Sr# | Name | Roll No | Marks |
---|---|---|---|
1 | 16-mscit-21 Shamraiz Iqbal (Repeater) | 16-mscit-21 | NA |
2 | 16-mscit-29 Iram Naz (Repeater) | 16-mscit-29 | NA |
3 | 17-mscit-01 Ayesha Kanwal | 17-mscit-01 | NA |
4 | 17-mscit-02 Arbaz Naeem | 17-mscit-02 | NA |
5 | 17-mscit-03 Adeela Rani | 17-mscit-03 | NA |
6 | 17-mscit-04 Shaista Khan | 17-mscit-04 | NA |
7 | 17-mscit-05 Asma Benish | 17-mscit-05 | NA |
8 | 17-mscit-06 Maria Ummar | 17-mscit-06 | NA |
9 | 17-mscit-07 Azka Riaz | 17-mscit-07 | NA |
10 | 17-mscit-08 Shar Bano | 17-mscit-08 | NA |
11 | 17-mscit-09 Sahrish Ansar | 17-mscit-09 | NA |
12 | 17-mscit-10 Maryam Akram | 17-mscit-10 | NA |
13 | 17-mscit-11 Seerat Zhra | 17-mscit-11 | NA |
14 | 17-mscit-12 Sana Sultan | 17-mscit-12 | NA |
15 | 17-mscit-13 Kiran Yasmeen | 17-mscit-13 | NA |
16 | 17-mscit-14 Bilal Afzal | 17-mscit-14 | NA |
17 | 17-mscit-15 Pakeeza Arshad | 17-mscit-15 | NA |
18 | 17-mscit-16 Muhammad Zia Awan | 17-mscit-16 | NA |
19 | 17-mscit-17 Fariha Maryam | 17-mscit-17 | NA |
20 | 17-mscit-18 Muhammad Jahangir Alam | 17-mscit-18 | NA |
21 | 17-mscit-19 Tahseena Kanwal | 17-mscit-19 | NA |
22 | 17-mscit-20 Arslan Habib | 17-mscit-20 | NA |