module 1
module 1
Introduction to C
S.PAVANI
Overview
Features of C language
Introduction to Embedded C
Difference between C and
Embedded C
Feature C Programming Embedded C
Embedded systems (microcontrollers,
Target Platform General-purpose computing platforms
microprocessors)
Designed for efficient use of limited resources
Resource Constraints May not be optimized for resource constraints
(memory, processing power) in embedded systems
#include <stdio.h>
int main() {
char ch;
printf(“Enter a character: “);
scanf(“%c”,&ch);
printf(“The ASCII value of ‘%c’ is %d\n”, ch, ch);
return 0;
}
• Write a C program to display the ASCII code of a character in
decimal, octal and hexadecimal
• Write a C program to swap two numbers without using third
variable
• Write a C program to swap two numbers
• Write a C program to calculate volume of a sphere
• Write a C program to calculate simple interest
• Write a C program to calculate compound interest
#include <stdio.h>
int main()
char ch;
scanf("%c", &ch);
}
#include <stdio.h>
int main() {
x = x+y;
y = x-y;
x = x-y;
return 0;
}
#include <stdio.h>
int main() {
return 0;
}
Write a C program to calculate volume of a sphere
#include <stdio.h>
int main() {
float radius, volume;
printf("Enter the radius of the sphere in cm: ");
const float PI = 3.14159;
scanf("%f", &radius);
volume = (4/3)*PI*radius*radius*radius;
printf("Volume of sphere in cubic centimeter = %.3f\n", volume);
return 0;
}
• #include <stdio.h>
• int main() {
• char ch;
• printf("Enter a character: ");
• scanf("%c",&ch);
• printf("The ASCII value of '%c' is %d\n", ch, ch);
• return 0;
•}
Arithmetic Operators in C
• Type casting, refers to the process of changing the data
type of a variable from one type to another. In
programming, different data types represent different
kinds of values and have different memory
representations. Type casting allows you to work with
variables of different types in a consistent manner.
int x = 5;
float y = 2.5;
float result = x + y; // Implicit type casting of 'x' from int to float
Logical operators
Bitwise operators
Other operators
Order of operations
Order of operations
Format specifiers
Escape sequences
Console I/O
1) Write a C program to convert temperature from Fahrenheit to Celsius
2) Write a C program to find the sum of digits of a 3-digit number
3) Write a C program to perform flooring and ceiling operation on a number
without using inbuilt function(s)
4) Write a C program to reverse a 3-digit number.
• For Ex : If input - 123, output = 321
• Additional exercises:
1. Average of three numbers
2. Perimeter of a rectangle
3. Volume of a cone
4. Total surface area of a cylinder
Enhanced I/O Operations