C Langavage Notes
C Langavage Notes
======================
#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
#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
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.
\t : HORIZONTAL TAB
# 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.
# 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
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();
}