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: A
Please enter second string: A
Strings are Equal.
Please enter first string: a
Please enter second string: A
Strings 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: aaa
Please enter second string: AAA
Strings are Equal.
Please enter first string: aaa
Please enter second string: aAa
Strings 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.
identification division. program-id. greatest. environment division. data division. working-storage section. 77 a pic 999. 77 b pic 999. 77 c pic 999. procedure division. greatest. display "ENTER THE THREE NUMBERS:". accept a. accept b. accept c. if a > b and a > c display a "is greatest" else if b > c display b "is greatest" else display c "is greatest". display " thank you". stop run.
Accept 5 numbers in an array and display it.
//C program to accept a string from user and //display its ascii value and //then display sum of all ascii value of strings #include<stdio.h> #include <string.h> int main() { char String[100]; int Sum,Index; Sum=0; //Sum is initially zero printf("Enter the string:\n"); gets(String); //Accept String from User for(Index=0;Index<strlen(String);Index++) { Sum+=(String[Index]); //Adds (the ASCII values of) the String characters. } printf("The sum is %d\n",Sum); //Printing it as %d gives the equivalent ASCII value. return 0; }
draw a flowchart to display the first tenth even number
The scanf() function is a commonly used function to input information during the execution of a program. scanf() function has its prototype in the stdio.h header file. To accept and display a number: int num; printf("Enter a number: "); scanf("%d",&num); printf("You entered %d",num); To accept and display a character, replace %d with %c and make num a character variable [char]. Plus: gets, fgets, read, fread, getchar, getc, fgetc, getch...
program that display the area of a circle of a reduce
identification division. program-id. greatest. environment division. data division. working-storage section. 77 a pic 999. 77 b pic 999. 77 c pic 999. procedure division. greatest. display "ENTER THE THREE NUMBERS:". accept a. accept b. accept c. if a > b and a > c display a "is greatest" else if b > c display b "is greatest" else display c "is greatest". display " thank you". stop run.
Accept 5 numbers in an array and display it.
Design an algorithm that will accept a perons's name from the screen entered as surname, first name, separated by a comma. Your program is to display the name as frist name, followed by three blanks, followed by the surname. -defining diagram -pseudocode algorithm
//C program to accept a string from user and //display its ascii value and //then display sum of all ascii value of strings #include<stdio.h> #include <string.h> int main() { char String[100]; int Sum,Index; Sum=0; //Sum is initially zero printf("Enter the string:\n"); gets(String); //Accept String from User for(Index=0;Index<strlen(String);Index++) { Sum+=(String[Index]); //Adds (the ASCII values of) the String characters. } printf("The sum is %d\n",Sum); //Printing it as %d gives the equivalent ASCII value. return 0; }
'Acceptable' is an adjective: 'He did not display an acceptable standard of behaviour.'
draw a flowchart to display the first tenth even number
How_do_you_accept_three_numbers_and_check_weather_the_numbers_are_equal_or_unequal_if_it_is_unequal_find_the_greatest_number_among_them
start, inputbox,inputbox,inputbox,inputbox,inputbox,progresh,display,stop
The scanf() function is a commonly used function to input information during the execution of a program. scanf() function has its prototype in the stdio.h header file. To accept and display a number: int num; printf("Enter a number: "); scanf("%d",&num); printf("You entered %d",num); To accept and display a character, replace %d with %c and make num a character variable [char]. Plus: gets, fgets, read, fread, getchar, getc, fgetc, getch...
Start accept 7 number calculate sum print sum stop
public class PrintOctal { public static void main(String[] args) { int n = Integer.parseInt(args[0]); System.out.printf("%o\n", n); } }