C Programming Basics

HandsomePyramidsOfGiza avatar
HandsomePyramidsOfGiza
·
·
Download

Start Quiz

Study Flashcards

22 Questions

What is the smallest individual unit in a C program that is meaningful to the compiler?

Tokens

What are keywords in C?

Reserved words with predefined meanings

What is the purpose of the printf() function in C?

Printing formatted output

What is the purpose of the scanf() function in C?

Reading formatted input

What is the purpose of the clrscr() function in C?

Clearing the screen

What is the purpose of the getch() function in C?

Getting a character input without echoing it to the screen

What is the common use of the scanf() function?

Inputting values from the user during runtime

Why are clrscr() and getch() functions used in console-based programs?

For better screen management and user interaction

What is a one-dimensional array in C?

A linear array where elements are stored in a single row or column

What is the main difference between one-dimensional and multi-dimensional arrays?

The number of indices used to access elements

What are arithmetic operators used for in C?

To perform mathematical operations

What is the function of relational operators in C?

To compare the values of two operands

What is an example of a relational operator in C?

==

What is the function of the increment (++) operator in C?

To increment the value of a variable

What is the purpose of variables in C programming?

To store data values.

What determines the size and layout of a variable's memory?

Data type.

Which data type is used to store whole numbers without decimal points?

Integer

What is the typical size of a 'long long' integer in C?

8 bytes

What is the purpose of pointers in C?

To store memory addresses.

What is a structure in C?

A user-defined data type.

What is an array in C programming?

A collection of elements of the same data type.

How are elements in an array accessed?

Using an index.

Study Notes

C Programming Basics

  • Tokens are the smallest individual units in a program that are meaningful to the compiler.
  • Tokens can be identifiers, keywords, constants, strings, or symbols like operators and punctuation.

Keywords

  • Keywords are reserved words that have predefined meanings and cannot be used for other purposes.
  • Examples of keywords in C include 'int', 'char', 'if', 'else', 'for', 'while', and 'return'.

printf() Function

  • The printf() function is used to print formatted output to the standard output (usually the console).
  • It takes a format string followed by optional arguments, formats them according to the format string, and then prints the resulting string.

scanf() Function

  • The scanf() function is used for reading formatted input from the standard input (usually the keyboard) and storing the data into variables.
  • It works similarly to printf(), but in reverse, reading formatted data from the user and assigning it to variables.

clrscr() and getch() Functions

  • clrscr() is used to clear the screen, removing any previously printed output, making the screen blank.
  • getch() is used to get a character input from the user without echoing it to the screen.

Variables and Data Types

  • Variables are used to store data values.
  • Each variable in C has a specific data type, which determines the size and layout of the variable's memory, as well as the range of values it can store.
  • There are several data types in C, including:
    • Integers (int, short, long, long long)
    • Floating-point numbers (float, double, long double)
    • Characters (char)
    • Arrays (one-dimensional and multi-dimensional)
    • Pointers (store memory addresses)
    • Structures (user-defined data types that can hold multiple variables of different types)

Arrays

  • An array is a collection of elements of the same data type that are stored in contiguous memory locations.
  • Each element can be accessed using an index.
  • There are two main types of arrays in C:
    • One-dimensional array (linear array where elements are stored in a single row or column)
    • Multi-dimensional array (array with more than one dimension, such as two-dimensional arrays)

Operators

  • Operators are symbols that represent computations or actions to be performed on operands.
  • There are several types of operators in C, including:
    • Arithmetic Operators (+, -, *, /, %, ++, --)
    • Relational Operators (==, !=, >, <, >=, <=)

This quiz covers the fundamental concepts of C programming, including tokens and keywords. Learn about the building blocks of C programs and how they are used by the compiler to understand and process code.

Make Your Own Quizzes and Flashcards

Convert your notes into interactive study material.

Get started for free

More Quizzes Like This

Java Data Types and Tokens Quiz
5 questions
String Tokens in Python
16 questions
Use Quizgecko on...
Browser
Browser