-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsolve_problem.c
More file actions
124 lines (103 loc) · 2.83 KB
/
solve_problem.c
File metadata and controls
124 lines (103 loc) · 2.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// ============================================================
// 📌 Practice Problems
// Topic : C Programming - Pointer
// ============================================================
// 👉👉 🔹🔹Qu - 1️⃣
#include <stdio.h>
int main()
{
int *ptr;
int a;
ptr = &a;
*ptr = 0; // Store 0 ;
printf("a = %d\n", a); // value of a = 0;
printf("*ptr = %d\n", *ptr); // value of ptr = 0;
// 2nd part
*ptr = *ptr + 5; // *ptr += 5 ;
printf("a = %d\n", a);
printf("*ptr = %d\n", *ptr);
// 3rd part
(*ptr)++;
printf("a = %d\n", a);
printf("*ptr = %d\n", *ptr);
return 0;
}
// 👉👉 🔹🔹Qu - 2️⃣ print the value of 'i' froms it pointer to pinter
#include <stdio.h>
int main(){
int i = 5;
int *ptr = &i;
int **pptr = &ptr ;
printf("Value of **pptr = :%d\n : " , **pptr);
return 0;
}
// 👉👉 🔹🔹Qu - 3️⃣ Swap 2 Numbers a &b
#include <stdio.h>
int main(){
int a = 5;
int b = 3;
int t = a;
a = b;
b = t;
printf("a = %d , b = %d\n " , a,b) ;
return 0;
}
// 👉👉 🔹🔹Qu - 4️⃣ Write a function to calculate the sum , product & average of 2 Numbers .
// print that average in the main function
#include <stdio.h>
void cal(int a , int b);
int main(){
int a = 3;
int b = 5;
// Function call;
cal(a,b);
printf("%d\n" , (a,b));
return 0 ;
}
// // Function difinition
void cal(int a , int b){
int sum = a +b;
int avg = (a+b) /2;
int pro = (a * b) ;
printf("sum is : %d avg = %d pro = %d\n" , sum, avg, pro);
}
#include <stdio.h>
void calculate(int a, int b, int *sum, int *avg, int *pro);
int main()
{
int a = 5;
int b = 23;
int sum, avg, pro;
calculate(a, b, &sum, &avg, &pro); // function call;
printf("sum = %d avg = %d pro = %d\n", sum, avg, pro);
return 0;
}
// Function Difinition
void calculate(int a, int b, int *sum, int *avg, int *pro)
{
*sum = a + b;
*avg = (a + b) / 2;
*pro = a * b;
}
#include <stdio.h>
void calculation(int a, int b, int *sum, int *avg, int *pro);
int main()
{
int a = 5;
int b = 2;
int sum, avg, pro;
calculation(a, b, &sum, &avg, &pro); // Function call
printf("sum = %d avg = %d , pro = %d\n", calculation);
return 0;
}
// Function Difinition
void calculation(int a, int b, int *sum, int *avg, int *pro)
{
*sum = a + b;
*avg = (a + b) / 2;
*pro = a * b;
}
// Emoji
// 3️⃣ 4️⃣ 5️⃣ 6️⃣ 7️⃣ 8️⃣ 9️⃣ 🔟
// 1️⃣1️⃣ 1️⃣2️⃣ 1️⃣3️⃣ 1️⃣4️⃣ 1️⃣5️⃣ 1️⃣6️⃣ 1️⃣7️⃣ 1️⃣8️⃣ 1️⃣9️⃣ 2️⃣0️⃣
// 2️⃣1️⃣ 2️⃣2️⃣ 2️⃣3️⃣ 2️⃣4️⃣ 2️⃣5️⃣ 2️⃣6️⃣ 2️⃣7️⃣ 2️⃣8️⃣ 2️⃣9️⃣ 3️⃣0️⃣