Learn To Code: Introduction to C Sharvaani Thoguluva Technical and Non-Technical Team Member Achutha Dharani Non-Technical Team Member
The 3 W's of Coding ● What is Coding? ● Why should you learn to code? ● Where is coding used?
● Coding is how we communicate with computers. ● Code tells a computer what actions to take, and writing code is like creating a set of instructions. ● By learning to write code, you can tell computers what to do. ● You can use this skill to make websites and apps, and do lots of other cool things. What is Coding?
● Programming helps to learn problem-solving skills ● Computer programming gives a challenge and helps them develop resilience ● Coding teaches us how to think ● One can expand their creativity when they learn how to code ● Computer programming is the future Why should you learn to code?
● Video Games ● Websites ● Smartphones and a lot more... Where do we use Coding?
● C is a general-purpose programming language that is extremely popular, simple, and flexible to use. ● It is a structured programming language that is machine-independent and extensively used to write various applications. ● It is said that ‘C’ is the god of programming language. ● One can say, C is a base for the programming. What is C Programming Language?
● When we say Output, it means to display some data on screen, printer, or in any file. ● C programming provides a set of built-in functions to output the data on the computer screen as well as to save it in text or binary files. Syntax: ● Normal expression: printf(“Expression to be typed”); ● Printing variable: printf(“%d”, sum); ● Printing expression with variable: printf(“The sum is %d”,sum); Output in C
Datatypes ● Each variable in C has an associated data type. Each data type requires different amounts of memory and has some specific operations which can be performed over it. ● The C language provides the four basic arithmetic type specifiers char, int, float and double, and the modifiers signed, unsigned, short, and long. What are Datatypes?
● A variable is a name of the memory location. ● It is used to store data. ● Its value can be changed ● It is a way to represent memory location through symbol so that it can be easily identified. Let's see the syntax to declare a variable: type variablename; Variables A little into variables!
● Local variable ● Global variable ● Static variable ● Automatic variable ● External variable Types of Variables in C There are many types of variables in c:
Rules For Defining Variables Few rules to define a variable! ● A variable can have alphabets, digits, and underscore. ● A variable name can start with the alphabet, and underscore only. It can’t start with a digit. ● No whitespace is allowed within the variable name. ● A variable name must not be any reserved word or keyword, e.g. int, goto , etc.
Input in C • When we say Input, it means to feed some data into a program. An input can be given in the form of a file or from the command line. • C programming provides a set of built-in functions to read the given input and feed it to the program as per requirement. Syntax: scanf("%d", &intVariable);
Operators ● An operator is a symbol that operates on a value or a variable. ● For example: + is an operator to perform addition. ● C has a wide range of operators to perform various operations.
Control Structures ● Selection (Conditional) : Execution of a set of statements when a particular condition is met ● Iteration (Loops): Repetition of the execution of a set of statements as long as the condition is satisfied
if and else if Selection if if-else Syntax if (condition) { Statement; ………... } if (condition) { Statement; } else { Statement; }
if else-if ladder and nested if Selection if else-if ladder nested if Syntax if (condition1) { Statements; } else if (condition2) { Statement; } else if (condition3) { Statement; } ….. else { Statement; } if (condition 1) { if (condition 2) { Statement; } ………………... }
Switch Case Selection Syntax switch (expression) { case constant expression: statements; break; case constant expression: statements; break; default: statements; }
for loop Iterations Syntax for (initialization; condition; increment) { statements; }
while loop Iterations Syntax while (condition) { statements; }
Control Structures Difference between for and while loops For While ● Used only when the number of iterations are known beforehand ● If the condition is not put, the loop will repeat/iterate infinite number of times ● Initialization is not repeated ● Usually used when the number of iterations are not known beforehand ● If the condition is not given, then it will result into an error
Programming a formula Write a program in C to find the sum of ‘N’ numbers.

Learn To Code: Introduction to c

  • 1.
    Learn To Code:Introduction to C Sharvaani Thoguluva Technical and Non-Technical Team Member Achutha Dharani Non-Technical Team Member
  • 2.
    The 3 W'sof Coding ● What is Coding? ● Why should you learn to code? ● Where is coding used?
  • 3.
    ● Coding ishow we communicate with computers. ● Code tells a computer what actions to take, and writing code is like creating a set of instructions. ● By learning to write code, you can tell computers what to do. ● You can use this skill to make websites and apps, and do lots of other cool things. What is Coding?
  • 4.
    ● Programming helpsto learn problem-solving skills ● Computer programming gives a challenge and helps them develop resilience ● Coding teaches us how to think ● One can expand their creativity when they learn how to code ● Computer programming is the future Why should you learn to code?
  • 5.
    ● Video Games ●Websites ● Smartphones and a lot more... Where do we use Coding?
  • 6.
    ● C isa general-purpose programming language that is extremely popular, simple, and flexible to use. ● It is a structured programming language that is machine-independent and extensively used to write various applications. ● It is said that ‘C’ is the god of programming language. ● One can say, C is a base for the programming. What is C Programming Language?
  • 7.
    ● When wesay Output, it means to display some data on screen, printer, or in any file. ● C programming provides a set of built-in functions to output the data on the computer screen as well as to save it in text or binary files. Syntax: ● Normal expression: printf(“Expression to be typed”); ● Printing variable: printf(“%d”, sum); ● Printing expression with variable: printf(“The sum is %d”,sum); Output in C
  • 8.
    Datatypes ● Each variablein C has an associated data type. Each data type requires different amounts of memory and has some specific operations which can be performed over it. ● The C language provides the four basic arithmetic type specifiers char, int, float and double, and the modifiers signed, unsigned, short, and long. What are Datatypes?
  • 10.
    ● A variableis a name of the memory location. ● It is used to store data. ● Its value can be changed ● It is a way to represent memory location through symbol so that it can be easily identified. Let's see the syntax to declare a variable: type variablename; Variables A little into variables!
  • 11.
    ● Local variable ●Global variable ● Static variable ● Automatic variable ● External variable Types of Variables in C There are many types of variables in c:
  • 12.
    Rules For DefiningVariables Few rules to define a variable! ● A variable can have alphabets, digits, and underscore. ● A variable name can start with the alphabet, and underscore only. It can’t start with a digit. ● No whitespace is allowed within the variable name. ● A variable name must not be any reserved word or keyword, e.g. int, goto , etc.
  • 13.
    Input in C •When we say Input, it means to feed some data into a program. An input can be given in the form of a file or from the command line. • C programming provides a set of built-in functions to read the given input and feed it to the program as per requirement. Syntax: scanf("%d", &intVariable);
  • 14.
    Operators ● An operatoris a symbol that operates on a value or a variable. ● For example: + is an operator to perform addition. ● C has a wide range of operators to perform various operations.
  • 16.
    Control Structures ● Selection(Conditional) : Execution of a set of statements when a particular condition is met ● Iteration (Loops): Repetition of the execution of a set of statements as long as the condition is satisfied
  • 17.
    if and elseif Selection if if-else Syntax if (condition) { Statement; ………... } if (condition) { Statement; } else { Statement; }
  • 18.
    if else-if ladderand nested if Selection if else-if ladder nested if Syntax if (condition1) { Statements; } else if (condition2) { Statement; } else if (condition3) { Statement; } ….. else { Statement; } if (condition 1) { if (condition 2) { Statement; } ………………... }
  • 19.
    Switch Case Selection Syntax switch (expression) { caseconstant expression: statements; break; case constant expression: statements; break; default: statements; }
  • 20.
    for loop Iterations Syntax for (initialization;condition; increment) { statements; }
  • 21.
  • 22.
    Control Structures Difference betweenfor and while loops For While ● Used only when the number of iterations are known beforehand ● If the condition is not put, the loop will repeat/iterate infinite number of times ● Initialization is not repeated ● Usually used when the number of iterations are not known beforehand ● If the condition is not given, then it will result into an error
  • 23.
    Programming a formula Writea program in C to find the sum of ‘N’ numbers.