Repository navigation
Expand file tree
/
Copy pathsample.c
More file actions
110 lines (90 loc) · 2.4 KB
/
Copy pathsample.c
File metadata and controls
110 lines (90 loc) · 2.4 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
#include <stdio.h>
#include <math.h>
#include <string.h>
// int nCr(int n, int r);
// int nCr(int n, int r) {
// if (r==0 || n==r) return 1;
// return nCr(n-1,r-1) + nCr(n-1,r);
// }
// int main() {
// int n=4,r=2;
// int result = nCr(n,r);
// printf("%d", result);
// }
struct students {
int m1;
int m2;
int m3;
// float avg;
};
// int main() {
// struct students s1;
// struct students *s = &s1;
// printf("Enter the marks of sutudent in maths :");
// scanf("%d", &s->m1);
// printf("Enter the marks of student in Physics :");
// scanf("%d", &s->m2);
// printf("Enter the marks of student in Chemistry :");
// scanf("%d", &s->m3);
// printf("The marks in m1,m2,m3 is : %d %d %d", s->m1, s->m2, s->m3);
// // struct students s[50];
// // int n;
// // float netavg =0;
// // printf("Enter the number of students :");
// // scanf("%d", &n);
// // for(int i=0; i<n; i++){
// // printf("Student %d:", i+1);
// // printf("Enter the marks in 3 subjects :");
// // scanf("%d %d %d", &s[i].m1, &s[i].m2, &s[i].m3);
// // s[i].avg = (s[i].m1 + s[i].m2 +s[i].m3)/3;
// // netavg += s[i].avg;
// // }
// // netavg = netavg/n;
// // int abavg=0, bwavg=0;
// // for(int i=0; i<n; i++){
// // if(s[i].avg >= netavg) abavg++;
// // else bwavg++;
// // }
// // printf("%d %d", abavg, bwavg);
// return 0;
// }
// int fact(int n);
// int fact(int n) {
// if (n==1) return 1;
// return n*fact(n-1);
// }
// int main() {
// int n, factorial;
// printf("Enter the value of n : ");
// scanf("%d", &n);
// factorial = fact(n);
// printf("The factorial is : %d", factorial);
// return 0;
// }
int main() {
// printf("%d %d", 'A', 'a'); //65 97
int n;
char str[50];
printf("Enter the length of string :");
scanf("%d", &n);
printf("Enter the String : ");
for(int i=0; i<n; i++){
scanf("%c", &str[i]);
} str[n] = '\0';
for(int i=0; i<n; i++){
if(str[i]>='A' && str[i]<='Z'){
str[i] = str[i] + 32;
}
else if(str[i]>='a' && str[i]<='z'){
str[i] = str[i] -32;
}
else{
continue;
}
}
printf("The String inverted is : ");
for(int i=0; i<n; i++){
printf("%c", str[i]);
}
return 0;
}