0% found this document useful (0 votes)
27 views8 pages

C Langavage Notes

notes for c langauage
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)
27 views8 pages

C Langavage Notes

notes for c langauage
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/ 8

A SAMPLE 'C' PROGRAM

======================
#include<stdio.h>
void main( )
{
printf("Welcome to C Language");
}
OUTPUT
=======
Welcome to C Language

#include<stdio.h>
void main( )
{
printf("Learning C Language is Good");
}
OUTPUT
========
Welcome to C LanguageLearning C Language is Good

#include<stdio.h>
#include<conio.h>
void main( )
{
clrscr( );
printf("Learning C Language is Good");
getch( );
}

OUTPUT
========
Learning C Language is Good

#include<stdio.h>
#include<conio.h>
void main( )
{
clrscr( );
printf("One");
printf("Two");
printf("Three");
getch( );
}

OUTPUT
========
OneTwoThree

\n (BACK SLASH n) :- IT IS USED TO GENERATE NEW LINE OR NEXT LINE.

#include<stdio.h>
#include<conio.h>
void main( )
{
clrscr( );
printf("One\n");
printf("Two\n");
printf("Three");
getch( );
}

OUTPUT
========
One
Two
Three

#include<stdio.h>
#include<conio.h>
void main( )
{
clrscr( );
printf("One");
printf("\nTwo");
printf("\nThree");
getch( );
}

OUTPUT
========
One
Two
Three

#include<stdio.h>
#include<conio.h>
void main( )
{
clrscr( );
printf("One");
printf("\nTwo\n");
printf("Three");
getch( );
}

OUTPUT
========
One
Two
Three

#include<stdio.h>
#include<conio.h>
void main( )
{
clrscr( );
printf("One\nTwo\nThree");
getch( );
}

OUTPUT
========
One
Two
Three

NOTE :- DONT GIVE SPACE BETWEEN BACKSLASH AND n. DONT USE UPPER CASE N. IF YOU TYPE
\n\n THEN GENERATES ONE EXTRA EMPTY LINE.
#include<stdio.h>
#include<conio.h>
void main( )
{
clrscr( );
printf("One\NTwo");
getch( );
}

OUTPUT
========
OneNTwo

#include<stdio.h>
#include<conio.h>
void main( )
{
clrscr( );
printf("One\n");
printf("\nTwo");
getch( );
}

OUTPUT
========
One

Two

\t (BACK SLASH t) :- IT IS USED TO GENERATE FIVE / EIGHT SPACES.


#include<stdio.h>
#include<conio.h>
void main( )
{
clrscr( );
printf("1\t");
printf("2");
getch( );
}

OUTPUT
========
1 2

#include<stdio.h>
#include<conio.h>
void main( )
{
clrscr( );
printf("*\n");
printf("*\t*\n");
printf("*\t*\t*");
getch( );
}
OUTPUT
=======
*
* *
* * *

#include<stdio.h>
#include<conio.h>
void main( )
{
clrscr( );
printf("*\n*\t*\n*\t*\t*");
getch( );
}

OUTPUT
=======
*
* *
* * *
#include<stdio.h>
#include<conio.h>
void main( )
{
clrscr( );
printf("\t\t*\n\t*\t*\n*\t*\t*");
getch( );
}
OUTPUT
=======
*
* *
* * *
ESCAPE SEQUENCES :- THESE ARE ALSO CALLED NON-PRINTABLE CHARARACTERS. THESE
CHARACTERS CAN'T PRINT ON SCREEN, WHICH PERFORMS SOME ACTION. THESE CHARACTERS
STARTS WITH BACK SLASH AND FOLLOWED BY A LOWER CASE ALPHABET.

[ \n, \t,\a, \b, \r, \', \", \?, \\, \0 ]

\n : NEW LINE / NEXT LINE

\t : HORIZONTAL TAB

\a : ALERT (BEEP / SOUND)

# include <stdio.h>
# include <conio.h>
void main()
{
clrscr();
printf("Hai,\a ");
printf("How R U");
getch();
}

OUTPUT
=======
Hai, Sound How R U

\b : BACK SPACE

# include <stdio.h>
# include <conio.h>
void main()
{
clrscr();
printf("Jaya\b");
printf("Sree");
getch();
}

OUTPUT
=======
JaySree

\r : CARRAIGE RETURN

IT IS SIMILAR TO \n.

\n : NEXT LINE FIRST COLUMN

\r : SAME LINE FIRST COLUMN

# include <stdio.h>
# include <conio.h>
void main()
{
clrscr();
printf("Jaya\r");
printf("Sri");
getch();
}

OUTPUT
=======
Sria

# include <stdio.h>
# include <conio.h>
void main()
{
clrscr();
printf("This is Rama\'s Pen\n");
printf("This is \"Rama\" System\n");
printf("What is your name\?\n");
printf("C:\\Jasmine\\Lily\\Rose\\Lotus\n");
getch();
}

OUTPUT
=======
This is Rama's Pen
This is "Rama" System
What is your name?
C:\Jasmine\Lily\Rose\Lotus

\0 : NULL CHARACTER (STRING TERMINATOR)

WORKING WITH DATA


=====================

DATA :- IT IS NOTHING BUT A KNOWN VALUE.


VARIABLE :- WHICH STORES DATA. IT IS A MEMORY LOCATION. BEFORE USING VARAIBLES WE
MUST DECLARE / CREATE THEM AT THE STARTING OF THE PROGRAM.

DECLARING VARIABLES
======================

SYNTAX
=======

DATA_TYPE VARIABLE_NAME;

Ex :-
int htno;
float rate;
char gndr;
char name[10]; (STRING)

=======================================
SAMPLE DATA DATA TYPE SIGN /
CONVERSION CHARACTER /
FORMAT SPECIFIER / CONTROL STRING
=======================================
10 int %d

12.45 float %f

'K' char %c

"Rama" string %s
=======================================

#include<stdio.h>
#include<conio.h>
void main()
{
int a=35; //intilization
clrscr();
printf("%i",a);
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c; // decalration
clrscr();
a=10; //assignment
b=20;
c=a+b;
printf("%d",c);
getch();
}

#include<stdio.h>
#include<conio.h>
void main()
{
int a=5,b=9;
clrscr();
printf("%d",a*b);
printf("\n%d",a>b);
getch();
}

#include<stdio.h>
#include<conio.h>
void main()
{
int a;
clrscr();
printf("%d",a);
getch();
}
o/p:- garbage value

#include<stdio.h>
#include<conio.h>
void main()
{
int a=10;
clrscr();
printf("%d",A);
getch();
}
o/p:- undefined symbol A

#include<stdio.h>
#include<conio.h>
void main( )
{
int a; / int A; (VARIABLE DECLARATION)
a = 10; (ASSIGNMENT / STORING)
clrscr( );
printf("a\n");
printf("%d\n",a);
printf("A Value : %d\n",a);
printf("%d is A Value\n",a);
printf("Ravana Has %d Heads\n",a);
printf("A = %d",a);
getch( );
}

OUTPUT
=======
a
10
A Value : 10
10 is A Value
Ravana Has 10 Heads
A = 10
#include<stdio.h>
#include<conio.h>
void main()
{
int a=10,b=39,c=4;
clrscr();
printf("A=%d\nB=%d\nC=%d",b,c,a);
getch();
}

You might also like