0% found this document useful (0 votes)
3 views5 pages

C Programming Notes Beginners (1)

This document provides an introduction to C programming, covering its basic structure, data types, input/output operations, conditional statements, loops, and functions. It includes practical examples such as calculating the sum of two numbers, checking even or odd, computing factorials, generating Fibonacci series, and checking for prime numbers. The content is aimed at beginners looking to understand the fundamentals of C programming.

Uploaded by

jishnukp2006
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)
3 views5 pages

C Programming Notes Beginners (1)

This document provides an introduction to C programming, covering its basic structure, data types, input/output operations, conditional statements, loops, and functions. It includes practical examples such as calculating the sum of two numbers, checking even or odd, computing factorials, generating Fibonacci series, and checking for prime numbers. The content is aimed at beginners looking to understand the fundamentals of C programming.

Uploaded by

jishnukp2006
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
You are on page 1/ 5

C Programming Notes for Beginners

1. Introduction to C

- C is a general-purpose programming language developed by Dennis Ritchie.

- It is widely used in system/software development.

- .c is the file extension for C programs.

2. Basic Structure of a C Program

#include <stdio.h>

int main() {

// Your code here

return 0;

3. Data Types & Variables

int age = 20;

float pi = 3.14;

char grade = 'A';

4. Input and Output

#include <stdio.h>

int main() {

int num;

printf("Enter a number: ");


scanf("%d", &num);

printf("You entered: %d", num);

return 0;

5. Conditional Statements

int num = 5;

if(num % 2 == 0)

printf("Even");

else

printf("Odd");

6. Loops

for loop:

for(int i = 1; i <= 5; i++) {

printf("%d\n", i);

while loop:

int i = 1;

while(i <= 5) {

printf("%d\n", i);

i++;

7. Functions

int add(int a, int b) {


return a + b;

int main() {

int result = add(3, 4);

printf("Sum = %d", result);

return 0;

Practice Programs

1. Sum of Two Numbers

int a, b;

printf("Enter two numbers: ");

scanf("%d %d", &a, &b);

printf("Sum = %d", a + b);

2. Check Even or Odd

int num;

scanf("%d", &num);

if(num % 2 == 0)

printf("Even");

else

printf("Odd");

3. Factorial of a Number

int n, fact = 1;
scanf("%d", &n);

for(int i = 1; i <= n; i++)

fact *= i;

printf("Factorial = %d", fact);

4. Fibonacci Series

int n, a = 0, b = 1, c;

scanf("%d", &n);

for(int i = 1; i <= n; i++) {

printf("%d ", a);

c = a + b;

a = b;

b = c;

5. Check Prime Number

int n, flag = 0;

scanf("%d", &n);

for(int i = 2; i <= n/2; i++) {

if(n % i == 0) {

flag = 1;

break;

if(flag == 0)

printf("Prime");

else
printf("Not Prime");

You might also like