SlideShare a Scribd company logo
C Programming Basics
C Programming Basics programming list and examples
Basic Syntax
#include <stdio.h>
The header file stdio.h stands for Standard Input Output.
int main()
Main functions from where the program starts executing
Followed by the body of the program
/* Comments */ -------------> comments in C
C Programming Basics programming list and examples
Initially num=1
Iteration Comparison Output Operation Num value
1 1<=10 Yes 1 num++ 2
2 2<=10 2 num++ 3
C Programming Basics programming list and examples
#include <stdio.h>
int main () {
for( ; ; ) {
printf("This loop will run forever.n");
}
return 0;
}
Functions in C
The general form of a function definition in C programming language
is as follows −
return_type function_name( parameter list ) {
body of the function
}
/* function returning the max between two numbers */
int max(int num1, int num2) {
/* local variable declaration */
int result;
if (num1 > num2)
result = num1;
else
result = num2;
return result;
}
For the above defined function max(), the function declaration is as follows −
int max(int num1, int num2);
Parameter names are not important in function declaration only their type is
required, so the following is also a valid declaration −
int max(int, int);
/* calling a function to get max value */
ret = max(a, b);
Arrays
Arrays a kind of data structure that can store a fixed-size sequential collection
of elements of the same type.
C Programming Basics programming list and examples
Initialization : sum=0 and Consider n=5
array= 1,2,3,4,5
Iteration Variable C Comparison Output
1 0 0<5 Yes sum= sum+array[c]
sum=0+array[0]
0+1=1
2 1 1<5 Yes sum=1+array[1]
1+2=3
3 2 2<Yes sum=3+array[1]
3+3=6
Iteration Variable C Comparison Output
4 3 3<5 Yes sum=6+array[3]
6+4=10
5 4 4<5 Yes sum=7+array[4]
10+5=15
Strings
String Functions
Structure
C Programming Basics programming list and examples
struct student
{
int roll_no;
char name[100];
}
struct student *s;
s->roll_no=12;
s->name=”ABC”;
typedef
The typedef is a keyword used in C programming to provide some
meaningful names to the already existing variable in the C program.
Syntax of typedef
typedef <existing_name> <alias_name>
struct student
{
char name[20];
int age;
};
typedef struct student stud;
stud s1, s2;

More Related Content

PPT
Functions in c
PPTX
C structure
PDF
Introduction to cpp
PDF
Module 1_Chapter 2_PPT (1)sasaddsdsds.pdf
PPTX
Basic c programming and explanation PPT1
PPTX
Programming Fundamentals lecture 5
PPTX
Lecture no 3
Functions in c
C structure
Introduction to cpp
Module 1_Chapter 2_PPT (1)sasaddsdsds.pdf
Basic c programming and explanation PPT1
Programming Fundamentals lecture 5
Lecture no 3

Similar to C Programming Basics programming list and examples (20)

PPTX
Presentation on Function in C Programming
PDF
Programming Fundamentals Functions in C and types
PPTX
C++ Chapter 3
PPT
Functions in C++
PDF
A function definition num_digits with Cpp programnum_digits.cpp#.pdf
PPT
PPTX
My first program in c, hello world !
PPT
Practical basics on c++
PPTX
Programming in C Presentation upto FILE
PDF
cuptopointer-180804092048-190306091149 (2).pdf
PPT
Cinfo
PPTX
Functions in c++
PPTX
Presentation on C language By Kirtika thakur
PPTX
Fundamental of programming Fundamental of programming
PPTX
basic program
PPTX
Presentation on function
PDF
unit3 part2 pcds function notes.pdf
PPTX
Silde of the cse fundamentals a deep analysis
PPT
Function
Presentation on Function in C Programming
Programming Fundamentals Functions in C and types
C++ Chapter 3
Functions in C++
A function definition num_digits with Cpp programnum_digits.cpp#.pdf
My first program in c, hello world !
Practical basics on c++
Programming in C Presentation upto FILE
cuptopointer-180804092048-190306091149 (2).pdf
Cinfo
Functions in c++
Presentation on C language By Kirtika thakur
Fundamental of programming Fundamental of programming
basic program
Presentation on function
unit3 part2 pcds function notes.pdf
Silde of the cse fundamentals a deep analysis
Function
Ad

Recently uploaded (20)

PPT
pwm ppt .pdf long description of pwm....
PPTX
Slideham presentation for the students a
PPTX
GPAT Presentation PPT and details about imp topics.pptx
PPTX
microtomy kkk. presenting to cryst in gl
PPTX
Core Characteristics and Abilities of an Effective Teacher_0.pptx
PPTX
Your Guide to a Winning Interview Aug 2025.
PPTX
PE3-WEEK-3sdsadsadasdadadwadwdsdddddd.pptx
PPT
ALLIED MATHEMATICS -I UNIT III MATRICES.ppt
PPTX
430838499-Anaesthesiiiia-Equipmenooot.pptx
PPTX
AREAS OF SPECIALIZATION AND CAREER OPPORTUNITIES FOR COMMUNICATORS AND JOURNA...
PDF
LSR CASEBOOK 2024-25.pdf. very nice casbook
PDF
Career Overview of John Munro of Hilton Head
PDF
202s5_Luciano André Deitos Koslowski.pdf
PPT
NO000387 (1).pptsbsnsnsnsnsnsnsmsnnsnsnsjsnnsnsnsnnsnnansnwjwnshshshs
PPTX
1751884730-Visual Basic -Unitj CS B.pptx
PDF
Shopify Store Management_ Complete Guide to E-commerce Success.pdf
PDF
CV of Architect Professor A F M Mohiuddin Akhand.pdf
PPTX
Prokaryotes v Eukaryotes PowerPoint.pptx
PPTX
Digital Education Presentation for students.
PDF
Beyond the Lab Coat - Perjalanan Karier di Dunia Pasca-Fisika S1
pwm ppt .pdf long description of pwm....
Slideham presentation for the students a
GPAT Presentation PPT and details about imp topics.pptx
microtomy kkk. presenting to cryst in gl
Core Characteristics and Abilities of an Effective Teacher_0.pptx
Your Guide to a Winning Interview Aug 2025.
PE3-WEEK-3sdsadsadasdadadwadwdsdddddd.pptx
ALLIED MATHEMATICS -I UNIT III MATRICES.ppt
430838499-Anaesthesiiiia-Equipmenooot.pptx
AREAS OF SPECIALIZATION AND CAREER OPPORTUNITIES FOR COMMUNICATORS AND JOURNA...
LSR CASEBOOK 2024-25.pdf. very nice casbook
Career Overview of John Munro of Hilton Head
202s5_Luciano André Deitos Koslowski.pdf
NO000387 (1).pptsbsnsnsnsnsnsnsmsnnsnsnsjsnnsnsnsnnsnnansnwjwnshshshs
1751884730-Visual Basic -Unitj CS B.pptx
Shopify Store Management_ Complete Guide to E-commerce Success.pdf
CV of Architect Professor A F M Mohiuddin Akhand.pdf
Prokaryotes v Eukaryotes PowerPoint.pptx
Digital Education Presentation for students.
Beyond the Lab Coat - Perjalanan Karier di Dunia Pasca-Fisika S1
Ad

C Programming Basics programming list and examples

  • 3. Basic Syntax #include <stdio.h> The header file stdio.h stands for Standard Input Output. int main() Main functions from where the program starts executing Followed by the body of the program /* Comments */ -------------> comments in C
  • 5. Initially num=1 Iteration Comparison Output Operation Num value 1 1<=10 Yes 1 num++ 2 2 2<=10 2 num++ 3
  • 7. #include <stdio.h> int main () { for( ; ; ) { printf("This loop will run forever.n"); } return 0; }
  • 8. Functions in C The general form of a function definition in C programming language is as follows − return_type function_name( parameter list ) { body of the function }
  • 9. /* function returning the max between two numbers */ int max(int num1, int num2) { /* local variable declaration */ int result; if (num1 > num2) result = num1; else result = num2; return result; }
  • 10. For the above defined function max(), the function declaration is as follows − int max(int num1, int num2); Parameter names are not important in function declaration only their type is required, so the following is also a valid declaration − int max(int, int); /* calling a function to get max value */ ret = max(a, b);
  • 11. Arrays Arrays a kind of data structure that can store a fixed-size sequential collection of elements of the same type.
  • 13. Initialization : sum=0 and Consider n=5 array= 1,2,3,4,5 Iteration Variable C Comparison Output 1 0 0<5 Yes sum= sum+array[c] sum=0+array[0] 0+1=1 2 1 1<5 Yes sum=1+array[1] 1+2=3 3 2 2<Yes sum=3+array[1] 3+3=6
  • 14. Iteration Variable C Comparison Output 4 3 3<5 Yes sum=6+array[3] 6+4=10 5 4 4<5 Yes sum=7+array[4] 10+5=15
  • 19. struct student { int roll_no; char name[100]; } struct student *s; s->roll_no=12; s->name=”ABC”;
  • 20. typedef The typedef is a keyword used in C programming to provide some meaningful names to the already existing variable in the C program. Syntax of typedef typedef <existing_name> <alias_name>
  • 21. struct student { char name[20]; int age; }; typedef struct student stud; stud s1, s2;