The country code and area code of StrÌ_ngnÌ_s, Sweden is 46, (0)152.
The airport code for Stuttgart Airport is STR.
#include<stdio.h> int main() { char str[100]; int i; printf("Please enter a string: "); // gets(str); // fgets is a better option over gets to read multiword string . fgets(str, 100, stdin); // Following can be added for extra precaution for '\n' character // if(str[length(str)-1] == '\n') str[strlen(str)-1]=NULL; for(i=0;str[i]!=NULL;i++) { if(str[i]>='A'&&str[i]<='Z') str[i]+=32; else if(str[i]>='a'&&str[i]<='z') str[i]-=32; } printf("String in toggle case is: %s",str); return 0; }
Nataau3302s
#include<stdio.h> #include<conio.h> #include<string.h> void main() { char str[99]; int i,len=0; clrscr(); printf("Enter the string \n"); while ( i!=\n) scanf("%s",str[i]); len=strlen(str[i]); //Printing the accepted value. for(i=1;1<len;++i) { printf("%s",str[i]); } //Converting the case. for(i=0;i<len;++i) { if(str[i]>='A' && str[i]<='Z') { str[i]+=35; } else { str[i]-=35; } } //Printing the string converted string. for(i=0;i<len;++i) { printf("%s",str[i]); } getch(); }
#include<stdio.h> #include<conio.h> #include<string.h> int main() { int tmp,i; char str[30]; printf("Enter any string: "); gets(str); for(i=0; str[i]!='\0'; i++) { if(str[i-1]==' ' i==0) { 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; } printf("%c",str[i]); } getch(); return 0;}
RemoveSpaces (char *str) { char *new = str; while (*str != '\0') { if (*str != ' ') *(new++) = *str; str++; } *new = '\0'; }
void to_uppercase (char* str) { if (str == 0) return; while (*str != '\0') { if (*str>='a' && *str<='z') *str-=32; ++str; } }
Here's a simple C program to display vowels from a given string: #include <stdio.h> int main() { char str[100]; printf("Enter a string: "); fgets(str, sizeof(str), stdin); printf("Vowels in the string: "); for (int i = 0; str[i] != '\0'; i++) { if (str[i] == 'a' || str[i] == 'e' || str[i] == 'i' || str[i] == 'o' || str[i] == 'u' || str[i] == 'A' || str[i] == 'E' || str[i] == 'I' || str[i] == 'O' || str[i] == 'U') { printf("%c ", str[i]); } } return 0; } This program prompts the user for a string, then iterates over each character to check if it's a vowel, and displays the vowels found.
#include <stdio.h> #include <string.h> /* To read something into a string in C you would do the following: */ char * str; str = malloc(100 * sizeof(char)); scanf("%s", &str); /* Another way to do the same thing is to read character by character: */ for(int i = 0; (i < 100) && (*(str + i) != '\n') ; i++) scanf("%c", str + i); /* This code told the computer to keep reading into str until the computer reads a '\n' or until the computer reads 100 characters (which is how much I mallocated for str) */ /* Changing the '\n' to 'q' means keep reading and don't stop until you find a 'q'
str
Here is program code written in plain C:#include #include void upString(char *str);int main() {char str[100];printf("Enter string: ");gets(str);upString(str);printf("UpperCase version: %s\n", str);return 0;}void upString(char *str) {register int ind = 0;while (str[ind]) {str[ind] = toupper(str[ind]);ind++;}}Testing:Enter string: Testing this application, to see if it works.UpperCase version: TESTING THIS APPLICATION, TO SEE IF IT WORKS.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.
The following code is supposed to take the characters stored in str and move those characters into buff in reverse order, but there is a coding mistake preventing this. Find the bug. // reverses str and puts the result in buff // NOTE: buff must be at least as large as str void strReverse(const int str_length, const char* str, char* buff) { // special case for zero-length strings if( str_length == 0 ) {return; } // reverse int i; for(i = 0; i < str_length; ++i) {buff[i] = str[str_length - i]; } buff[i] = '\0'; }