Posts
Repetition
- Get link
- X
- Other Apps
Repetition, or widely known as looping, are a way to run a block of program again and again until a certain condition has been fullfilled. These are the types of repetition used in C programming: -) for loop : The syntax of for loop is: for (initializationStatement; testExpression; updateStatement) { // codes } The initialization statement is executed only once. Then, the test expression is evaluated. If the test expression is false (0), for loop is terminated. But if the test expression is true (nonzero), codes inside the body of for loop is executed and the update expression is updated. This process repeats until the test expression is false. The for loop is commonly used when the number of iterations is known. for loop flowchart: for loop example: // Program to calculate the sum of first n natural numbers // Positive integers 1,2,3...n are known as natural numbers #include <stdio.h> int main () { int num , count , sum =
C Programming Files Manipulation
- Get link
- X
- Other Apps
C Programming Files I/O Types of Files When dealing with files, there are two types of files you should know about: Text files Binary files 1. Text files Text files are the normal .txt files that you can easily create using Notepad or any simple text editors. When you open those files, you'll see all the contents within the file as plain text. You can easily edit or delete the contents. They take minimum effort to maintain, are easily readable, and provide least security and takes bigger storage space. 2. Binary files Binary files are mostly the .bin files in your computer. Instead of storing data in plain text, they store it in the binary form (0's and 1's). They can hold higher amount of data, are not readable easily and provides a better security than text files. File Operations In C, you can perform four major operations on the file, either text or binary: Creating a new file Opening an existing file Closing a file Reading from and w