import java.io.*;
class CatToDog
{
protected byte words(String xs)
{
byte a=0;
for(byte i=0;i<xs.length();i++)
{
if(xs.charAt(i)==' ')
a++;
}
return (byte)(a+1);
}
protected static void main()throws IOException
{
BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
CatToDog o=new CatToDog();
System.out.print("Enter the String: ");
String s=in.readLine();
byte a=o.words(s),b=0,c=0;
String w[]=new String[a];
for(;b<a;b++)
w[b]="";
for(b=0;b<s.length();b++)
{
if(s.charAt(b)==' ')
c++;
else
w[c]+=s.charAt(b);
}
for(b=0;b<a;b++)
{
if(w[b].equalsIgnoreCase("Cat"))
System.out.print("Dog ");
else
System.out.print(w[b]+" ");
}
}}
print c co com comp compu
num = InputBox("Enter a number: ","PROGRAM: Square") sumSquare = CInt(num) * CInt(num) MsgBox("The square of " & num & " = " & sumSquare) ===== *NOTE*: The function CInt() is what we use to convert a text string to become a numeric integer value.
Get the string from user , then U Split the string with space and put in a string array .Then Find Length of string array , Take first letter of each element in array, Except last. Assigned those to a string, then Fetch Last element of an array, Add it With that String.That's it.
#include #include using std::cin;using std::cout;using std::endl;using std::string;using std::getline;int main(){string myStr = "";cout
I assume the program should be case-sensitive. Here is a code of such program:#include #include int main() {char str1[100];char str2[100];printf("Please enter first string: ");gets(str1);printf("Please enter second string: ");gets(str2);if (strcmp(str1, str2) == 0) {printf("Strings are Equal.\n");} else {printf("Strings are Not Equal.\n");}return 0;}Testing:Please enter first string: APlease enter second string: AStrings are Equal.Please enter first string: aPlease enter second string: AStrings are Not Equal.If you want to make not case-sensitive comparing before checking you should make both string in lowercase or uppercase.Here is how it should look:#include #include #include void upString(char *str);int main() {char str1[100];char str2[100];printf("Please enter first string: ");gets(str1);printf("Please enter second string: ");gets(str2);upString(str1);upString(str2);if (strcmp(str1, str2) == 0) {printf("Strings are Equal.\n");} else {printf("Strings are Not Equal.\n");}return 0;}void upString(char *str) {register int ind = 0;while (str[ind]) {str[ind] = toupper(str[ind]);ind++;}}Testing:Please enter first string: aaaPlease enter second string: AAAStrings are Equal.Please enter first string: aaaPlease enter second string: aAaStrings are Equal.Note: You should not be using gets() function in real-world application. There is no way you can limit number of characters to read thus allowing to overflow buffer. It was used only for example.
print c co com comp compu
Here's a Python program that accomplishes this: def convert_case(input_str): return input_str.swapcase() user_input = input("Enter a string: ") converted_str = convert_case(user_input) print("Converted string:", converted_str)
num = InputBox("Enter a number: ","PROGRAM: Square") sumSquare = CInt(num) * CInt(num) MsgBox("The square of " & num & " = " & sumSquare) ===== *NOTE*: The function CInt() is what we use to convert a text string to become a numeric integer value.
#include <iostream> #include <string> int main() { std::string myStr = ""; std::cout << std::endl << "Enter a string: "; std::cin >> myStr; system("PAUSE"); return 0; }
#include<stdio.h> #include<conio.h> void main() { char string[20]; int i=0; printf("Enter the string.\n"); while(i<=19) { scanf("%c",&string[i]); i++; } while(i>=0) { printf("%c",string[i]); i--; } getch(); } In this program it is compulsory to enter 20 characters. Now we can write a program in which it is not necessary. #include<stdio.h> #include<conio.h> #include<string.h> void main() { char string[20]; int length; printf("enter the string.\n"); gets(string); length=strlen(string); length--; while(length>0) { printf("%c",string[length]); length--; } getch(); }
answer:
clear echo -n "Enter the Name / String:" while : do read name echo $name | awk '{print gsub(/[aeiou]/,"")}' done
Write to the program's producers at the BBC.
#include<stdio.h> void main() { int cnt=0,i; char str[100]; printf("Enter the string "); scanf("%s",str); for(i=0;i<strlen(str)-1;i++) { if(str[i]==' ') cnt++; } printf("\nTotal no. of word in string = %d",cnt); }
public class StringLength { public static void main(String args[]) { String firstString; String secondString; System.out.println("Please enter string (group of characters) "); firstString=sc.nextString(); System.out.println("Please enter second string (group of characters) "); secondString=sc.nextString(); if(firstString>secondString) { System.out.println(); //create blank line System.out.println("First String is greater than the second string"); System.out.println(); } else { System.out.println("Second string is greater than the first string"); System.out.println(); } }//closes the main method }//closes the class.
Get the string from user , then U Split the string with space and put in a string array .Then Find Length of string array , Take first letter of each element in array, Except last. Assigned those to a string, then Fetch Last element of an array, Add it With that String.That's it.
#include #include using std::cin;using std::cout;using std::endl;using std::string;using std::getline;int main(){string myStr = "";cout