Thread: Programming Help

  1. #1
    Registered User
    Join Date
    Dec 2020
    Posts
    1

    Post Programming Help

    So i'm basically trying to build a C code for this assignment. (Ignore the red text that's crossed out and any other question that isn't about programming)
    Intro, Intro (beginning of A), A, B, B ii

    Also in hyperlink A i know it says python but forget about that too, everything is supposed to be in C. I can't get past Section A though as my program won't run. It looks like this. Any suggestions?

  2. #2
    Registered User
    Join Date
    May 2009
    Posts
    3,977
    Learn the difference between == and = when used in C code.

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    38,541
    Oh, and next time, post actual code between [code][/code] tags.

    Just dumping a bunch of urls to screen shots doesn't make a good experience.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    TEIAM - problem solved
    Join Date
    Apr 2012
    Location
    Melbourne Australia
    Posts
    1,894
    Why haven't you just named the variables "guestNumber", "length", "isSmoker", "CreditCardNumber"?

    That way your code will be self documenting.

    If you don't want to do that, at least change "l" - calling a variable "l" is a very bad idea because it looks like a "1"

    What is going on here...
    Code:
    printf("Please Enter Name\n");
    scanf
    ...
    Is there more to that scanf?

    Also, scanf needs the address of your variable - You do that by putting a "&" in front of it
    Code:
    scanf("%d", &length);
    There are lots of problems with getting strings (i.e. the name) from the user - You just need to look into the history of the "gets" function in the C language.

    The best way is to use a function called "fgets". I suggest that you have a look around for tutorials like this:
    C Strings - Cprogramming.com

    Good luck
    Fact - Beethoven wrote his first symphony in C

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 0
    Last Post: 02-01-2019, 12:27 PM
  2. Replies: 0
    Last Post: 02-01-2019, 12:22 PM
  3. Replies: 2
    Last Post: 09-11-2012, 01:03 AM
  4. Replies: 4
    Last Post: 12-11-2011, 04:25 PM
  5. Total newb to programming here... Question about the many programming languages. Ty!
    By tsubotakid1 in forum A Brief History of Cprogramming.com
    Replies: 11
    Last Post: 10-05-2003, 10:32 AM

Tags for this Thread