Step 1: Start
Step 2: Declare two strings, ch
and ch2
Step 3: Concatenate the strings ch
and ch2
using strcat()
Step 4: Convert each character in the concatenated string to uppercase using toupper()
Step 5: Print the resulting string
Step 6: End
#include<stdio.h> #include<string.h> #include<ctype.h> // For toupper() int main() { char ch[20] = "hello"; // Allocate enough space for the concatenated string char ch2[] = "MECH"; // Automatically sizes the second string // Concatenate strings strcat(ch, ch2); // Convert the concatenated string to uppercase using a loop for (int i = 0; ch[i] != '\0'; i++) { ch[i] = toupper((unsigned char) ch[i]); } // Print result printf("Value of first string is: %s\n", ch); return 0; }
Value of first string is: HELLOMECH