#include <stdio.h> /* Global Variables */ int w = 100, x = 101, y = 102, z = 103 ; int towers(int) ; main() { int w = 1 , x = 3 ; printf("before: w = %d, x = %d, y = %d, z = %d\n", w, x, y, z) ; w = towers(y) ; printf("after: w = %d, x = %d, y = %d, z = %d\n", w, x, y, z) ; } int towers(int x) { int y ; y = x + 5 ; z = z + y ; w = z - x ; printf("during: w = %d, x = %d, y = %d, z = %d\n", w, x, y, z) ; return(y) ; }
Click here for the solution.
int i, j; for (i = 0; i <= 3; i++) { for (j = 1; j <= 4; j++) { if ( (i + 1 == j) || (j + i == 4) ) { printf("+") ; } else { printf("o") ; } } printf("\n") ; }
Click here for the solution.
#include <stdio.h> int ents(int *, int *) ; main() { int a = 1, b = 2, c = 3 ; a = ents(&b, &c) ; printf("First Call: a = %d, b = %d, c = %d\n", a, b, c) ; c = ents(&a, &b) ; printf("Second Call: a = %d, b = %d, c = %d\n", a, b, c) ; } int ents(int *p1, int *p2) { int result, *q ; q = p1 ; *p1 = *p2 * 2 ; p1 = p2 ; *p1 = *q + 5 ; result = *p1 + *p2 ; return(result) ; }
Click here for the solution.
#include <stdio.h> #include "genlib.h" #include "simpio.h" #include "strlib.h" main() { string str, new ; int i, length ; char c ; str = "Smaug the Worm" ; new = "" ; length = StringLength(str) ; for(i = 0 ; i < length ; i++) { c = IthChar(str,i) ; if (isalpha(c)) { c = tolower(c) ; c = c + 7 ; if (c > 'z') c = c - 26 ; } new = Concat(new, CharToString(c)) ; } printf("new = %s\n", new) ; }
Click here for the solution.
18 23 28 33 38 43 48
Click here for a sample solution.
Click here for a sample solution.
Click here for a sample solution.