Squirrels have fuzzy tails.
0 Members and 1 Guest are viewing this topic.
#include <stdio.h>int main(){ char name; int age; int end; printf( "What is your name? "); scanf( "%c", &name ); printf( "Hello %c", name); printf( "How old are you? "); scanf( "%d", &age ); do { if ( age <= 5 ) { printf( "How old are you really? " ); scanf( "%c", age ); } else if ( age < 18 ) { printf( "You're still a minor, nah-nah neh-nah-nah" ); end = 1; } else if ( age < 25 ) { printf( "You're a young adult now!" ); end = 1; } else if ( age < 35 ) { printf( "You're not quite middle aged." ); end = 1; } else if ( age < 50 ) printf( "Be glad you're not old."); end = 1; } else { printf( "You're old! Nah-nah neh-nah-nah!"); //this is where it "went wrong" end = 1 }} while ( end != 1) return 0;}
C:\Users\David\Desktop\Personal\Poof\Library\nameAge.c||In function 'main':|C:\Users\David\Desktop\Personal\Poof\Library\nameAge.c|36|error: expected 'while' before 'else'|C:\Users\David\Desktop\Personal\Poof\Library\nameAge.c|40|error: expected identifier or '(' before 'while'|C:\Users\David\Desktop\Personal\Poof\Library\nameAge.c|43|error: expected identifier or '(' before '}' token|||=== Build finished: 3 errors, 0 warnings ===|
#include <stdio.h>int main(){ char name; int age; int end; printf( "What is your name? "); scanf( "%c", &name ); printf( "Hello %c\n", name); printf( "How old are you? "); scanf( "%d", &age ); getchar(); do { if ( age <= 5 ) { printf( "How old are you really? " ); scanf( "%d", age ); } else if ( age < 18 && age > 5 ) { printf( "You're still a minor, nah-nah neh-nah-nah" ); end = 1; } else if ( age < 25 && age >= 18 ) { printf( "You're a young adult now!" ); end = 1; } else if ( age < 35 && age >= 25 ) { printf( "You're not quite middle aged." ); end = 1; } else if ( age < 50 && age >= 35 ) { printf( "Be glad you're not old."); end = 1; } else { printf( "You're old! Nah-nah neh-nah-nah!"); end = 1; }} while ( end != 1); return 0;}
char myString[15] = "hello world";
#include <stdio.h>int main(){ char name[15]; //max name length = 14 (plus NULL terminator = 15) printf("Enter your name: "); scanf("%s", name); printf("Your name is: %s", name);}