History of Social Media
History of Social Media
History of Social Media
DEPARTMENT OF CSE
first_digit=n/10000;
second_last_digit=n%100/10;
sum=first_digit+second_last_digit;
printf("sum of the first and second last digit=%d\n",sum);
}
Input
Output
If Statement
CODE
#include<stdio.h>
main()
{
int x,y;
printf("Enter the number of X\n\n");
scanf("%d",& x);
Output
If Else Statement
#include<stdio.h>
main()
{
int x;
printf("Enter any number \n\n");
scanf("%d",&x);
if(x%2==0){
printf("%d is EVEN NUMBER\n",x);}
else
{printf("%d is ODD NUMBER",x);}
}
Input
Output
If-Else-If Ladder
#include<stdio.h>
main()
{
int number;
printf("Enter any number \n\n");
scanf("%d",&number);
if(number>=0){
printf("The number is positive\n",number);}
else if(number<=0){
printf("The number is negative",number);}
else if(number==0) {
printf("The number is zero",number);
}
Input
Output
For Loop
Components
A.Initialization
B.Condition
C.Body
D.Update
Example
Code: Output:
#include<stdio.h>
main()
{
int i,num;
for(i=100;i<=104;i++)
{
printf("CSE'23\n");
}
}
Nested For loops
#include<stdio.h>
main()
{
int i,j;
for(i=1;i<=5;i++){
for(j=1;j<=10;j++) {
printf("%4d",i*j);
} printf("\n");
}
}
While loop
Code:
Formulae:
Initialization;
While (condition)
{ body
update
}
Output:
Do While loop
Formulae: Code:
Initialization;
Do
{ body
update
}
While (condition);
Output:
Structure
Code:
#include<stdio.h> scanf("%s %d %s %d %f",
struct personal person.name,
{ &person.day,
char name[20]; person.month,
int day; &person.year,
char month[1]; &person.salary);
int year;
printf("%s %d %s %d %.2f\n",
float salary;
person.name,
};
person.day,
main()
person.month,
{
person.year,
struct personal person;
person.salary);
printf("Input Values\n"); }
Input:
Output:
Topic Highlights
DATA TYPES
MODULO DIVISION
OPERATORS
Data types-(int, char, float & double)
Each variable in C has an associated data type. It specifies the type of data that
the variable can store like integer, character, floating, double, etc.
Here some example:
Given number of
days, convert it in
terms of Years,
Months and Days.
Operators
Relation Operator
Logical Operator
Increment and Decrement Operators
Conditional Operator
Bitwise Operator
Relational Operators
Relational operators are the symbols that are
used for comparison between two values to
understand the type of relationship a pair of
numbers shares. The result that we get after the
relational operation is a boolean value, that tells
whether the comparison is true or false.
Relational operators are mainly used in
conditional statements and loops to check the
conditions in C programming.
Logical Operator
The following 6
operators are bitwise
operators (also known
as bit operators as they
work at the bit-level).
They are used to
perform bitwise
operations in C.
Today's
Outline
Topic Highlights
ARRAY
CONTINUE & BREAK
STATEMENT
PARAMETER
POINTER
ARRAY
Array are used to store multiple values
in a single variable , instead of
declaring separate variables for each
value.
Example :
Output :
Code :
Continue Statement
The continue statement skips the current
iteration of the loop and continue with the
next iteration.
Break Statement
The break statement ends the loop
immediately when it is encountered.
Continue &
Break
Statement
Code:
Sample
Output :
Code:
Sample
Output :
In C , There are two
types of parameter.
Output:
Output :
⥫
Switch
operator
A control fl o w statement in
C programming.