0% found this document useful (0 votes)
10 views

C Programming

The document discusses various C programming concepts like constants, variables, data types, operators, control instructions, functions, pointers, arrays and strings. It explains concepts like decision making using if-else, loops using for, while and do-while. Functions, pointers, arrays indexing and manipulation are also covered.

Uploaded by

itspb1907
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

C Programming

The document discusses various C programming concepts like constants, variables, data types, operators, control instructions, functions, pointers, arrays and strings. It explains concepts like decision making using if-else, loops using for, while and do-while. Functions, pointers, arrays indexing and manipulation are also covered.

Uploaded by

itspb1907
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

C Programming

Constants - is an entity that doesn't change


Variable - is an entity that may change / name given to the locations are called
variables
C Constants - Primary , Secondary
Primary Constants - Integer Real Character
Secondary Constants - Array, Pointer, Structure, Union, Enum ETC
Keywords - are the words whose meaning has already been explained to compiler 32
keywords
main() - is a collective name given to a set of statements Techincally main us a
function
C Instructions - Type Declaration, Airthmetic, Control
Modulus operator - cannot be applied on floats
* / % +- =
Control Instructions - determine the flow of control in a program
Decision making instructions - if else-if switch
In C a non zero value is considered to be TRUE
Logical Operators - AND OR NOT
Conditional Operators - expression 1 ? expression 2 : expression 3
e.g. y = x >5 ? 3 : 4
(a > b) ? ( a > c ? a : c): (b > c ? b :c))
Loop - to do something a fixed numbe of times
Multiple Statements : for ( i = 1, j = 2 ; j <= 10 ; j++ ), only one test
expression
break - jump out of the loop / control automatically passes to first statement
after loop
continue - When continue is encountered inside any loop,control automatically
passes to the beginning of the loop.
do-while - execute its statements at least once even if condition fails for first
time
A break takes you out of the do-while bypassing the conditional test. A continue
sends you straight to the test at the end of the loop.
Switch - control statements that allows us to make a decision from the number of
choices is called a switch
The switch statement is very useful while writing menu driven programs
Function - A function is a self-contained block of statements that perform a
coherent task of some kind.
called function - actual argumets, formal arguments
Calling convention - right to left
int a = 1 ;
printf ( "%d %d %d", a, ++a, a++ ) ; -- 3 3 1
pointers are variables that contain
addresses, and since addresses are always whole numbers, pointers would always
contain whole numbers.
A stack is a Last In First Out (LIFO) data structure.
C preprocessore - program processes our source program before it is passed to
compiler
source code PR1.C -> expanded source code get stored in a file PR1.I -> compiled
the object get stored PR1.OBJ->code is linked with object code of library func ->
executable code is stored in PR1.EXE

#ifdef macroname
statement 1 ;
statement 2 ;
statement 3 ;
#endif

#ifndef INTEL
code suitable for a Intel PC
#else
code suitable for a Motorola PC

A simple example of #if directive is shown below:


main( )
{
#if TEST <= 5
statement 1 ;
statement 2 ;
statement 3 ;
#else
statement 4 ;
statement 5 ;
statement 6 ;
#endif
}

#pragma Directive
This directive is another special-purpose directive that you can use
to turn on or off certain features

disp ( &marks[i] ) -> disp ( int *n )

A pointer when incremented always points to an immediately


next location of its type.

int i, *j ;
j = &num[0] ; /* assign address of zeroth element */

int num[ ] = { 24, 34, 12, 44, 56, 17 } ;


dislpay ( &num[0], 6 ) ;
for ( i = 0 ; i <= n - 1 ; i++ )
{
printf ( "\nelement = %d", *j ) ;
j++ ; /* increment pointer to point to next element */
}

int num[ ] = { 24, 34, 12, 44, 56, 17 } ;


*num -> *(num+0)=> zeroth element
num[i]->*(num+i)->*(i+num)->i[num]

s[2][1]
* ( s[2] + 1 )
* ( * ( s + 2 ) + 1 )

name[i]
*( name + i )
*( i + name )
i[name]

char name[25] ;
printf ( "Enter your full name " ) ;
scanf ( "%[^\n]s", name ) ;

char str[ ] = "Hello" ;


char *p = "Hello" ;
multiply any number by 9 in the fastest manner.
#include<stdio.h>
void main(){
int num;
printf(“Enter number: ”);
scanf(“%d”,&num);
printf(“%d”, (num<<3)+num);
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy