Preview

Jim’s C Programming Problems

Powerful Essays
Open Document
Open Document
3249 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Jim’s C Programming Problems
Jim’s
C Programming Problems

The First 100
(currently up to 74)

gcc –ansi -Wall

A Varied Collection of Problems for Beginning Students

Version 1.0

Last Updated – January 3, 2008

Problem 1: Hello World

Write a C program that prints out the message Hello World.

Problem 2: The Value 6

Write a C program that prints out the value 6. I want you to use the %d format code.

Problem 3: The Character P

Write a C program that prints out the single character P. I want you to use the %c format code.

Problem 4: The scanf Function

Write a C program that reads in an integer value from the keyboard via the scanf function and then prints it back onto the screen. By now you should know that scanf seeks an address expression. For example, &n is an address expression.

Problem 5: Sum of Two Values

Write a C program that reads two integer values from the keyboard via the scanf function, then adds them together, stores the result into a variable called sum, and then prints out the value of the variable sum.

Problem 6: The fscanf Function

Create file called testdata6 that has a single integer value stored into it.
Write a C program that opens a file named testdata6, reads the single value stored in it using the fscanf function, and then prints the value back onto the screen. You should call the function fclose before you return to the Unix operating system.

Problem 7: Bigger than 100?

Write a C program that reads a number from the keyboard via the scanf function, and then prints the message The number is bigger than 100 if it is. If the number is 100 or less than 100 then you should print out the message The number is not bigger than 100.

Problem 8: One Line of Asterisks

Create a file called testdata8 that has a single integer value stored into it. The integer will be a number between 1 and 30 inclusive. Create a C program that uses the fscanf function to read in this integer value and then prints a line containing

You May Also Find These Documents Helpful

  • Satisfactory Essays

    a1 script win213

    • 380 Words
    • 2 Pages

    If the user does not enter a numeric value the program should prompt for a numeric value…

    • 380 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    a. The time in hours, minutes, and seconds is to be passed to a function named totsec().…

    • 720 Words
    • 3 Pages
    Satisfactory Essays
  • Good Essays

    Nt1310 Unit 3 Quiz

    • 6337 Words
    • 26 Pages

    What is the primary purpose of the __P() macro? Choice 1 The __P() macro has no function, and merely obfuscates library function declarat ions. It should be removed from further releases of the C library. Choice 2 The __P() macro provides forward compatibility for C++ compilers, which do not r ecognize Standard C prototypes. Choice 3 Identifiers that begin with two underscores are reserved for C library implement ations. It is impossible to determine the purpose of the macro from the context given. Choice 4 The __P() macro provides backward compatibility for K&R C compilers, which do no t recognize Standard C prototypes. Choice 5 The __P() macro serves primarily to differentiate library functions from applica tion-specific functions. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /*question number 68*/ Which one of the following is NOT a valid identifier? Choice 1 __ident Choice 2 auto [Ans] Choice 3 bigNumber Choice 4 g42277 Choice 5 peaceful_in_space - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /*question number 69*/ /* Read an arbitrarily long string. */ Code: int read_long_string (const char ** const buf) { char * p = NULL; const char * fwd = NULL; size_t len = 0; assert(buf); do { p = realloc(p, len += 256); if (!p) return 0; if (!fwd) fwd = p; else fwd = strchr(p, '\0'); } while (fgets(fwd, 256, stdin)); *buf =…

    • 6337 Words
    • 26 Pages
    Good Essays
  • Better Essays

    Nt1310 Unit 1 Assignment

    • 1994 Words
    • 8 Pages

    * The binary numbering system plays a central role in how information of all kinds is stored on the computer. Understanding binary can lift a lot of the mysteries from computers because at a fundamental level they're really just machines for flipping binary digits on and off. There are several activities on binary numbers in this document, all simple enough that they can be used to teach the binary system to anyone who can count! Generally children learn the binary system very quickly using this approach, but we find that many adults are also excited when they finally understand what bits…

    • 1994 Words
    • 8 Pages
    Better Essays
  • Better Essays

    Program Lovecs.Java

    • 422 Words
    • 2 Pages

    import java.util. Scanner; public class LoveCS { public static void main(String[] args) { Scanner scan=new Scanner(System.in); System.out.println("Enter how many times you wish the message to be printed."); int limit = 0; limit= scan.nextInt(); int sum=0; int count=1; while (count <=limit) { System.out.println(count+" I love Computer Science!!"); sum+=count; count++; } System.out.println("Printed this message " + limit + " times."); System.out.println("The sum of the numbers from 1 to "+limit+" is "+sum); } } import java.util. Scanner; public class PowersOf2 { public static void main(String[]args) { int valuePowersOf2; int nextPowersOf2 =1; int exponent= 0; int count=0; Scanner scan = new Scanner(System.in); System.out.println("Enter A Number.");…

    • 422 Words
    • 2 Pages
    Better Essays
  • Good Essays

    C Is difficult, because the control flow is out of the hands of the application programmer…

    • 1508 Words
    • 7 Pages
    Good Essays
  • Good Essays

    Unit 16 Ao1

    • 529 Words
    • 3 Pages

    Programs need to store data at some time during the execution of processes. Data is held in variables which are names containers for each piece of data. Each variable must be given a name so it can be referred to again and again throughout the program. It should be something that is recognisable because for example variable 1 would be soon forgotten in a substantial piece of code. Variable names cannot be the same as code words such as print or run.…

    • 529 Words
    • 3 Pages
    Good Essays
  • Satisfactory Essays

    12. The STO→ button stores numbers to variables. To evaluate the expression23 4 a c b + −, press 9 STO→ ALPHA MATH ENTER to store the number 9 to A. Repeat this same process if B = 2 and C = 1, then evaluate the expression by…

    • 641 Words
    • 3 Pages
    Satisfactory Essays
  • Satisfactory Essays

    unit 3

    • 313 Words
    • 2 Pages

    7. Write a pseudocode statement that assigns the value of 27 to the variable count.…

    • 313 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Comp122 Week 2 Homework

    • 301 Words
    • 2 Pages

    What values (if any) are assigned to x, y, and ch after each of these statements execute?…

    • 301 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Week 5 Assignments New

    • 754 Words
    • 6 Pages

    3.) Design an if-then-else statement that assigns 0 to variable b if variable a is less than 10, otherwise it should assign 99 to variable b. (Alternative if statement)…

    • 754 Words
    • 6 Pages
    Satisfactory Essays
  • Satisfactory Essays

    code program

    • 317 Words
    • 2 Pages

    (Input screenshot) - Insert here a screenshot of your program running showing entry of the provided set of test input data for this assignment:…

    • 317 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    Unit 7 Assignment 1

    • 749 Words
    • 4 Pages

    Design a Do-While loop that asks the user to enter two numbers. The numbers should be added and the sum displayed. The loop should ask the user if he or she wishes to perform the operation again. If so, the loop should repeat, otherwise it should terminate.…

    • 749 Words
    • 4 Pages
    Good Essays
  • Satisfactory Essays

    Assignment 2

    • 338 Words
    • 2 Pages

    3.) Input, and display, the total of the numeric input after each input is entered. Average the numeric input, indicate lowest numeric input value and the highest numeric input value for the previous numeric inputs, before the next numeric input is asked for. (Example given in class)…

    • 338 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    Programming Homework

    • 366 Words
    • 2 Pages

    The variables in this program will be declared are num_1, num_2 and will be used as integers.…

    • 366 Words
    • 2 Pages
    Good Essays

Related Topics