printf does return the length:
size_t len = printf ("%s", str);
#include<stdio.h> #include<string.h> int main() { char a[80]; int rotated_element_number[80]; int rotation; int i; int length; printf("enter the word: \n"); gets(a); length = strlen(a); printf("the reversed string is:\n"); for( rotation=0; rotation<length; rotation++) { for( i=0; i<length; i++) { rotated_element_number[i] = i + rotation; while(rotated_element_number[i] > (length-1)) rotated_element_number[i] -= length; printf("%c", a[rotated_element_number[i]]); } printf("\t"); } getchar(); return 0; }
In pseudo-code: while ( not(end of string) and letter(string at position X) is not 'P' ){ add(array, newposition) = letter(string at position X); }
If you forget the semicolon, your program won't compile.
No, the printf() statement in C can generate multiple lines of output. You can include newline characters (\n) within the string to create line breaks, allowing for formatted output across multiple lines. Additionally, you can call printf() multiple times to print different lines.
int main (void) { char buf[1024]; scanf ("Enter a string: %s", buf); printf ("The length of the string is %d chars long.\n", strlen (buf)); 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(); }
#include<stdio.h> #include<string.h> int main() { char a[80]; int rotated_element_number[80]; int rotation; int i; int length; printf("enter the word: \n"); gets(a); length = strlen(a); printf("the reversed string is:\n"); for( rotation=0; rotation<length; rotation++) { for( i=0; i<length; i++) { rotated_element_number[i] = i + rotation; while(rotated_element_number[i] > (length-1)) rotated_element_number[i] -= length; printf("%c", a[rotated_element_number[i]]); } printf("\t"); } getchar(); return 0; }
In pseudo-code: while ( not(end of string) and letter(string at position X) is not 'P' ){ add(array, newposition) = letter(string at position X); }
#include#include#includeint main() {char a[80];int rotated_element_number[80];int rotation;int i;int length;printf("Enter the word: \n");gets(a);printf("%s\n",a);length = strlen(a);printf("Length is %d\n", length);for( rotation=0; rotation
To calculate string tension in a musical instrument, you can use the formula T F L, where T is the tension in the string, F is the force applied to the string, and L is the length of the string between the points where the force is applied. By measuring the force and length of the string, you can calculate the tension.
main(){ char str[5]="hello"; if(str==NULL) printf("string null"); else printf("string not null"); }
If you forget the semicolon, your program won't compile.
No, the printf() statement in C can generate multiple lines of output. You can include newline characters (\n) within the string to create line breaks, allowing for formatted output across multiple lines. Additionally, you can call printf() multiple times to print different lines.
main(){ char str[5]="hello"; if(str==NULL) printf("string null"); else printf("string not null"); }
The printf() function prints a formatted string.
/*We can calculate this with a lot of methods I'll explain only one of them */ *str = "abcd"; // this is a input string printf("%d", strlen(str));
To determine the tension in a string, you can use the formula T F L, where T is the tension, F is the force applied to the string, and L is the length of the string. By measuring the force and length, you can calculate the tension in the string.