Foundation

Simple C Programming

Contents

No.Description
1Quadratic equation
2Sum of digits and reverse of a number
3Nth Fibonacci number
4Positives, negatives, and zeros in a set of n numbers
5Evaluate series: 1 + x + x22! + x33! + ... + xnn!
6Pyramid display using *
7Armstrong numbers in a range
8Scientific calculator with 8 functions
9Pattern display with a number (e.g., N=39174: 3 9 1 7 4)
10Leap years in a range
11Convert decimal to new base
12Standard deviation of n numbers
13Location of a number in an array
14Append arrays A and B
15Currency denomination
16Matrix transpose
17Upper triangle with 1, lower with -1, diagonal with zero in a 2D array
18Matrix multiplication
19Factorial of a number using recursion
20Prime numbers
21Short form of a string
22Number of vowels in a string
23Mark list of N students using array of structures
24String length using pointer
25Odd and even numbers to files

Writing Basic C Program

To start programming in C , you need to understand the structure of a basic C program.
Here’s a simple example:

main.c
#include <stdio.h>
#include <conio.h>
 
void main() {
    int number = 20 ;
    clrscr();
 
    printf("the number = %d",number);
    getch();
}
 

Explanation

#include <stdio.h>: This line tells the compiler to include the Standard Input Output library before compiling the program. This library is necessary for functions like printf.
void main(): This is the main function where the execution of the program begins. Every C program must have a main function.
printf("Value = %g",value);: This function prints the text to the screen.
The %g is a datatype representation characters that print the representing data in the console.

Other

Format SpecifierDescriptionExample
%dIntegerint age = 25;
%fDouble (floating-point)double pi = 3.14;
%gGeneral formatprintf("%g", pi);
%sArray of characters (string)char name[] = "Spiderman";
%cCharacterchar initial = 'S';