0% found this document useful (0 votes)
2 views2 pages

C Programming Basics and Concepts

Uploaded by

zenitsu.ag.1899
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

C Programming Basics and Concepts

Uploaded by

zenitsu.ag.1899
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

C Programming Notes

Unit 1
What is source code?
Source code is the human-readable set of instructions that programmers write to tell a computer what to do.
It's like a recipe written in a language the programmer understands, which then gets translated for the
computer.

Define an algorithm.
An algorithm is a step-by-step set of instructions to solve a problem or complete a task. Think of it like a
recipe for a computer program.

Which symbol in a flowchart is used for input/output?


The parallelogram symbol is used in a flowchart to show where data is entered (input) or displayed (output).

What is a variable?
A variable is a named storage location in a program that holds a value. This value can change during the
program's execution, like a box where you can put different things at different times.

Define a constant.
A constant is a value that is fixed and cannot be changed once it's set in a program. It's like a special box
where you put something and it stays there, unchanged, throughout the program's run.

Give an example of a valid identifier in C.


A valid identifier must start with a letter or underscore, and can contain letters, digits, or underscores.
Examples include myVariable, _count, or total_sum.

Can a variable name start with a digit?


No, a variable name in C cannot start with a digit. It must begin with a letter or an underscore.

What is a keyword in C?
Keywords are special, reserved words in C that have a predefined meaning and purpose for the compiler.
You cannot use them as names for your own variables or functions (e.g., int, if, for).

Name two numeric data types in C.


Two common numeric data types in C are int (for whole numbers) and float (for numbers with decimal points).

What is an interpreter?
An interpreter is a program that directly runs code line by line, translating and executing each instruction as it
goes. It provides immediate feedback and is often used in scripting languages.

What is a compiler?
A compiler is a program that translates an entire program written in a high-level language (like C) into a
low-level language (like machine code) before the program is run. It checks for errors and optimizes the code
during this translation process.

Unit 2
What is the purpose of the #include directive in C?
The #include directive tells the C preprocessor to insert the content of a specified file (usually a header file)
into your program during the compilation process. This allows you to use functions and definitions from those
files (like printf from stdio.h).

Name two common header files used for input/output in C.


Two common header files for input/output in C are stdio.h (for standard input/output functions like printf and
scanf) and conio.h (for console input/output functions, though less common in modern C).
Name one function used to read a single character from the keyboard without echoing it on the
screen.
The getch() function (found in conio.h) reads a single character from the keyboard without displaying it on the
screen.

What does the modulus operator (%) do?


The modulus operator (%) gives you the remainder when one integer is divided by another. For example, 10
% 3 would be 1.

What is the use of the sizeof() operator?


The sizeof() operator tells you the size in bytes of a variable or a data type. It helps you understand how much
memory different data takes up.

What does the ternary operator ?: do?


The ternary operator ?: is a shorthand way to write an if-else statement. It allows you to assign a value to a
variable based on a condition in a single line of code.

Which function returns the absolute value of an integer?


The abs() function (found in stdlib.h) returns the absolute value of an integer (making negative numbers
positive).

What does #define do in a C program?


#define is a preprocessor directive used to define symbolic constants or macros. It tells the preprocessor to
replace all occurrences of a defined name with its corresponding value before the code is compiled.

Which function returns the length of a string?


The strlen() function (found in string.h) returns the length of a string, which is the number of characters in it
before the null terminator.

You might also like