void main() { char ch[8][20]; printf("Enter a string:and $for end of the string "); for (int i = 0; i < 8; i++) { scanf("%s", ch[i]); if(ch[i][0] == '$') break; }
#include <stdio.h> #include <string.h> int main() { char in_str[16] = "I am a good boy"; char out_str[16] = {0}; char current_letter = 0; int str_len = 0; int in_str_pos = 0; int temp_in_str_pos = 0; int out_str_pos = 0; int letter_count = 0;
/* calculate the string len */ str_len = strlen(in_str); in_str_pos = str_len-1; out_str_pos = 0;
while (in_str_pos >= 0) { if(in_str[in_str_pos] != ' ') /* If the letter is not a space */ { letter_count++; in_str_pos--; } else /* If the letter is a space */ { /* put the word in correct order to the output string */ temp_in_str_pos = in_str_pos+1; while (letter_count) { out_str[out_str_pos] = in_str[temp_in_str_pos]; letter_count--; out_str_pos++; temp_in_str_pos++; } /* Add space to the output string */ out_str[out_str_pos] = ' '; out_str_pos++; in_str_pos--; } } /* For last word - in this case "I" */ temp_in_str_pos = in_str_pos+1; while (letter_count) { out_str[out_str_pos] = in_str[temp_in_str_pos]; letter_count--; out_str_pos++; temp_in_str_pos++; }
/* put "end of string" to output string */ out_str[out_str_pos] = '
using strrev() function we can reversed that string #include<stdio.h> #include<string.h> void main() { char a[20]; printf(" Enter the string:"); scanf("%s",&a); strrev=strrev(a); printf(" The reversed string is:%s,sttrrev); }
using c-strings write a program that will analyse the text"1.1my brother is taller than me.1.2 I am a boy of sixteen years old". The program should remove multiple spaces betweem words,find the longest word in the text,search and identify the number of letters"e", extact the number of integers , extract the number of doubles, extract the number of words in each sentence and identify the number of sentences in the text.
A variable carries a value.(already assigned OR from Scanf..what ever the way). I want to know whether the variable is positive or negative. Conditions: ----------- 1.NO looping logic should be used such as for ..while..etc.
2.should not use > or <.
3.should not use any numbers except 0. We can use 0 and equality operator. How to know the number is positive or negative?
Q.8 When a 'C' function call is made, the order in which parameters passed to the function are pushed into the stack is (a) left to right (b) right to left (c) bigger variables are moved first than the smaller variables. (d) smaller variables are moved first than the bigger ones (c) none of the above.