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

C Programming Notes and Programs

This document provides an introduction to the C programming language, including its basic structure, data types, operators, and control statements. It also includes several practice programs demonstrating addition, even/odd checking, factorial calculation, and Fibonacci sequence generation. Each program is accompanied by example code to illustrate the concepts discussed.

Uploaded by

Kongathi Srihari
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 Notes and Programs

This document provides an introduction to the C programming language, including its basic structure, data types, operators, and control statements. It also includes several practice programs demonstrating addition, even/odd checking, factorial calculation, and Fibonacci sequence generation. Each program is accompanied by example code to illustrate the concepts discussed.

Uploaded by

Kongathi Srihari
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 & Practice Programs

Introduction to C
C is a powerful general-purpose programming language used for system programming, embedded systems, and

Basic Structure of a C Program


#include <stdio.h>

int main() {
printf("Hello World");
return 0;
}

Data Types
int, float, char, double

Operators
Arithmetic: + - * /
Relational: == != > <
Logical: && || !

Control Statements
if, else, switch, for, while, do-while

Program 1: Addition of Two Numbers


#include <stdio.h>
int main() {
int a,b,sum;
scanf("%d %d", &a, &b);
sum=a+b;
printf("%d", sum);
return 0;
}

Program 2: Even or Odd


#include <stdio.h>
int main() {
int n;
scanf("%d", &n);
if(n%2==0)
printf("Even");
else
printf("Odd");
return 0;
}

Program 3: Factorial
#include <stdio.h>
int main() {
int i,n;
long long fact=1;
scanf("%d", &n);
for(i=1;i<=n;i++)
fact*=i;
printf("%lld", fact);
return 0;
}

Program 4: Fibonacci
#include <stdio.h>
int main() {
int a=0,b=1,c,n,i;
scanf("%d", &n);
for(i=0;i<n;i++){
printf("%d ",a);
c=a+b;
a=b;
b=c;
}
return 0;
}

You might also like