-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcaps2.c
More file actions
37 lines (32 loc) · 674 Bytes
/
caps2.c
File metadata and controls
37 lines (32 loc) · 674 Bytes
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
#include <stdio.h>
#include <string.h>
int main(void)
{
printf("Enter a string: ");
char s[256];
fgets(s, 256, stdin);
int lenCount = 0;
int len = strlen(s);
// 32 positions between ascci upper and lower
for (int i=0; i<len; i++)
{
if (s[i] >= 65 && s[i] <= 122)
{
lenCount++;
if (lenCount % 2 == 0)
{
printf("%s", s[i] - 32);
}
else
{
printf("%c", s[i]);
}
}
else
{
printf("%c", s[i]);
}
}
printf("\n");
return 0;
}