0% found this document useful (0 votes)
19 views44 pages

Tending To Infinity 1 Shot For PPS Theory 1 Shot Live

The document covers various fundamental programming concepts in C, including data types, operators, control structures, arrays, functions, recursion, and pointers. It explains key topics such as ASCII values, type casting, loops, switch statements, and function pointers. Additionally, it discusses advanced topics like structures, unions, and the differences between recursion and iteration.

Uploaded by

sowok45663
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)
19 views44 pages

Tending To Infinity 1 Shot For PPS Theory 1 Shot Live

The document covers various fundamental programming concepts in C, including data types, operators, control structures, arrays, functions, recursion, and pointers. It explains key topics such as ASCII values, type casting, loops, switch statements, and function pointers. Additionally, it discusses advanced topics like structures, unions, and the differences between recursion and iteration.

Uploaded by

sowok45663
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/ 44

Unit 2

➢ Data Types
Unit 2
➢ Precedence of Operator:
Unit 2
➢ Postfix & Prefix:
In C and many programming languages, ++ and -- are increment
and decrement operators.
Unit 2
➢ ASCII Value
ASCII stands for American Standard Code for Information
Interchange.

It is a character encoding standard that assigns a numerical value


to every character (letters, digits, symbols) so that computers can
store and process text.
ASCII Basics
• It uses 7 bits to represent characters
• Total of 128 characters: values from 0 to 127
• Includes:
• Uppercase letters: A–Z → 65–90
• Lowercase letters: a–z → 97–122
• Digits: 0–9 → 48–57
• Special characters: !, @, #, etc.
• Control characters: \n (newline), \t (tab), etc.
Unit 2
➢ Explicit & Implicit type casting
Unit 2
➢ Explicit & Implicit type casting
Unit 2
➢ Bitwise Operator (Dry Run):
Bitwise operators directly work on binary bits (0s and 1s) of
integer values.

They are used in:


• Low-level programming
• Embedded systems
• Optimized arithmetic operations
Unit 2
➢ Bitwise Operator (Dry Run):
Unit 3
➢ Condition
Unit 3
➢ Types of Loop
Unit 3 for (int j = 0; j < 5; j++) {
➢ Jump Statements (Break and Continue) // Break Statement
if (j == 2)
break;

printf("%d ", j);


}

for (int j = 0; j < 5; j++) {

// Continue Statement
if (j == 2)
continue;

printf("%d ", j);


}
Unit 3
➢ GOTO statement
The goto statement in C allows the program to jump to some part of the code, giving you more control over
its execution. While it can be useful in certain situations, like error handling or exiting complex loops, it's
generally not recommended because it can make the code harder to read and maintain.

#include <stdio.h>

int main() {
int n = 0;

// If the number is zero, jump to


// jump_here label
if (n == 0)
goto jump_here;

// This will be skipped


printf("You entered: %d\n", n);

jump_here:
printf("Exiting the program.\n");
return 0;
}
Unit 3
➢ GOTO statement
#include <stdio.h>

int main(){

int n = 1;

// Label here
label:
printf("%d ", n);
n++;
if (n <= 10)

// jumb back to the label


goto label;
return 0;
}
Unit 3
➢ What is conditional operator
The Conditional Operator is a shortcut for writing simple if-else
statements.

It’s also called the ternary operator because it takes three


operands
Unit 3
➢ Fall through, Use of break in switch, default Key-word in switch
What is a Switch-Case?
• A switch statement lets you choose among many options based on the value of a variable.
• It’s an alternative to multiple if-else statements for better readability.

1. Fall Through in Switch


• When a case doesn’t have a break;, the program continues executing the next cases until
it finds a break or the switch ends.
• This is called “fall through.”

2. Use of break in Switch


• break; stops the execution inside the switch and exits the switch block.
• Without break;, the switch keeps running all cases after the matched one — which is
usually not desired.

3. default Keyword in Switch


• default is the fallback case if none of the cases match.
• It’s optional, but recommended for handling unexpected values.
Unit 3
➢ Fall through, Use of break in switch, default Key-word in switch
Unit 3
➢ Example of infinite & null Loop
1. Infinite Loop

What is an Infinite Loop?


• A loop that never stops running
because its exit condition is never met.
• Happens when loop control variables
are not updated properly.

2. Null Loop
• A loop that runs zero times because
the condition is false initially.
• Loop body never executes.
Unit 3
➢ Difference between exit (0) & break:
Unit 3
➢ Break only , breaks, internal Loop
What Does break Do?
• The break statement exits only the nearest (innermost) loop or switch where it is
used.
• It does NOT affect outer loops if loops are nested.
Unit 4
➢ Array
What is an Array?
• An array is a collection of elements of the same data type stored in contiguous memory
locations.
• It helps store multiple values using a single variable name.
Unit 4
➢ Size of Array
Unit 4
➢ functions in <string.h>
What is <string.h>?
• It is a header file in C that provides built-in
functions to work with strings.
• Strings in C are arrays of characters ending with
a null character (\0).
Unit 5
➢ TC of Algorithms
Unit 5
➢ Roots of quadratic equation
A quadratic equation is of the form: 𝑎𝑥 2 + 𝑏𝑥 + 𝑐 = 0

Where:
• 𝑎≠ 0
• a, b, c are real constants
• x is the unknown variable

How to Find the Roots? Use the quadratic formula:

−𝑏 ± 𝑏2 − 4𝑎𝑐
𝑥 =
2𝑎

Here, the term inside the square root is called the


discriminant
𝐷 = 𝑏2 − 4𝑎𝑐
Unit 6
➢ Parts of function definition
A function in C is a set of statements that, when called, perform some specific tasks. It is the basic
building block of a C program that provides modularity and code reusability. They are also called
subroutines or procedures in other languages.
Unit 6
➢ #include <math.h>
What is <math.h>?

The math.h header file in C provides


mathematical functions like:
• Power (pow)
• Square root (sqrt)
• Trigonometry (sin, cos, tan)
• Logarithmic & exponential
functions (log, exp)
• Absolute values (fabs)

This header allows you to perform advanced


mathematical operations easily in C programs.
Unit 6
➢ Call by value and Call by Reference:
Unit 6
➢ Actual Parameters & Formal
Parameters
Unit 6
➢ Return keyword
Unit 7
Recursion is the process of a function calling itself repeatedly till the given condition is satisfied. A function that
calls itself directly or indirectly is called a recursive function and such kind of function calls are called recursive
➢ What is Recursion
calls.
Unit 7
➢ Difference between Recursion & Iteration
Unit 7
➢ Algorithm(Sum, factorial, Fibonacci, Count digits, gcd)
Unit 8
➢ Structure, Union

struct Student { union Student {


int id; int id;
float marks; float marks;
char grade; char grade;
}; };

•All members occupy different memory locations. Total size is sum of all members (aligned)

•All members share the same memory location. Only one value can be used at a time. Total size is equal to the size
of the largest member.
Unit 8
➢ Difference between array & structure
Unit 8
➢ Array of structure
Unit 9
➢ Definition of pointer with example {*,&}
Unit 9
➢ Size of pointers
Unit 9
➢ Self-Referential Structures
Unit 9
➢ Passing function pointer to a parameter
#include <stdio.h> #include <stdio.h>

// A simple function int add(int a, int b) {


void greet() { return a + b;
printf("Hello from the greet function!\n");
}
}

int main() { int operate(int x, int y, int (*operation)(int, int)) {


// Declare a function pointer return operation(x, y);
void (*funcPtr)(); }

// Point it to the greet function int main() {


funcPtr = greet; int result = operate(5, 3, add);
printf("Result: %d\n", result);
// Call the function using the pointer
funcPtr(); return 0;
}
return 0;
}

You might also like