Specifier is a typedef-name and a very sensitive in C programming. Using an incorrect specifier for the data type being read or written will generate a run time error.
Missing the inclusion of appropriate header file in c program will generate an error. Such a program may compile but the linker will given an error message as it will not be able to find the functions used in the program.
The test expression done on exact statement. The good habit of using test expression on exact or fulfill statement. So do not use floating point numbers for checking for equality in the test expression.
Semoclone ( ; ) is one of the best sensitive symbols in programming. Placing a semicolon ( ; ) after the WHILE or FOR loop is not a syntax error. So it will not be reported by the compiler. However, it is considered to be a logical error as it change
Not putting // before the start of single statement comment is a compiler error. Not putting the */ after the termination of block comment is a compiler error.
// AHF C PROGRAM SOLVING //solving here 2_D ARRAY programming problemOUTPUT:
#include#include #define pf printf #define MAX_SIZE 100 // Maximum string size for all int main() { char str[1000], rev[100]; int length, i, index, word_start, word_end; //input data pf("Enter any string: "); gets(str); //taking length of the given string length= strlen(str); index = 0; //initialing index variable // start checking of words from the end of string word_start = length - 1; word_end = length - 1; while(word_start > 0) { // If a word is found if(str[word_start] == ' ') { // add the word to the reverse string i = word_start + 1; while(i <= word_end) { rev[index] = str[i]; i++; //update second loop index++; //update index value } rev[index++] = ' '; //taking space after reveres of each word word_end = word_start - 1; } word_start--; //update first while loop } // Finally add the last word for(i=0; i<=word_end; i++) { rev[index] = str[i]; index++; } //end of reverse string rev[index] = '\0'; pf("\nThe given string is: %s", str); pf("\nThe reverse word by word of the given string is: %s", rev); return 0; }
Enter any string: Ahf c programming web site The given string is: Ahf c programming web site. The reverse word by word of the given string is: site web programming c Ahf