1. // ^ // / \ // --- // ^ // / \ // / \ // ----- // ^ // / \ // / \ // / \ // ------- // ^ // / \ // / \ // / \ // / \ // --------- #include int main(int argc, char ** argv) { char strNumLines[256]; int numlines; fgets(strNumLines, sizeof(char)*256, stdin); sscanf(strNumLines, "%d", &numlines); int i, j; for(i = 0; i < numlines; i++) { if(i == 0) { for(j = numlines; j > i+1; j--) printf(" "); printf("^\n"); } else if(i == numlines - 1) { printf(" "); for(j = 0; j < 2*i-1; j++) printf("-"); printf("\n"); } else { for(j = numlines; j > i+1; j--) printf(" "); printf("/"); for(j = 0; j < 2*i-1; j++) printf(" "); printf("\\\n"); } } return 0; } 2. /* Program to count the number of words in a string */ #include #include int word_count(char line[]); int main() { int n,i,temp=0,large=0; char line[100]; printf("\n Enter a string: "); fgets(line,sizeof(line),stdin); line[strlen(line)-1]='\0'; printf("\nThere are %d words in the string.\n",word_count(line)); return 0; } int word_count(char line[]) { int wordcnt=0,i=0,flag=0; for(i = 0; i #include #include double min(double a[],int n); int main() { int n,i,temp=0; double * a; char line[100]; printf("\nEnter the number of elements in the array: "); fgets(line,sizeof(line),stdin); sscanf(line,"%d",&n); a = (double *) calloc(n, sizeof(double)); for(i=0;i #include char *non_white(char *line) { while(*line==' ' || *line=='\n' || *line=='\t') line++; return line; } int main() { char line[100]; printf("\n Enter a line"); scanf("%s",line); char *tmp; tmp=non_white(line); printf("\n First non-white character in the input is %c",*tmp); return 0; } 5. #include int main(int argc, char ** argv) { int arr[10] = {1,2,3,4,5,6,7,8,9,10}; int * front, * end; for(front = arr, end = arr+9; front < end; front++, end--) { int temp; temp = *front; *front = *end; *end = temp; } int i; for(i = 0; i < 10; i++) printf("%d ", arr[i]); printf("\n"); }