Define Keywords and Identifiers in C Language
auto | break | case |
char | const | continue |
default | do | double |
else | enum | extern |
float | for | goto |
if | int | long |
signed | sizeof | static |
struct | switch | typedef |
union | unsigned | void |
volatile | while | malloc |
calloc | realloc | free |
Special Characters in C
, | . | _ |
- | : | ; |
{ | } | ( |
# | $ | ! |
^ | & | * |
? | / | | |
\ | " | % |
%c | %d | %f |
[ | ] | ) |
< | > | ~ |
! | @ | &* |
%u | &a | % |
C Keywords List or Description
Auto Keyword in C
auto int variable_name; |
#include<stdio.h> #include<conio.h> void main() { auto int a=100; printf("Value of a:%d", a); getch(); } **********OUTPUT********** Value of a:100 |
What is the use of break keyword in C
#include<stdio.h> #include<conio.h> void main() { int n; printf("Enter a number:"); scanf("%d", &n); switch(n) { case 1: printf("Case one executed"); break; case 2: printf("Case two executed"); break; case 3: printf("Case three executed"); break; case 4: printf("Case four executed"); break; case 5: printf("Case five executed"); break; default: printf("invalid input"); } getch(); } **********OUTPUT********** Enter a number: 4 Case four executed |
Continue Keyword in C
#include<stdio.h> #include<conio.h> void main() { for(int i=1;i<=10;i++) { if(i==3) continue; printf("%d\n",i); } getch(); } **********OUTPUT********** 1 2 4 5 6 7 8 9 10 |
Case Keyword in C
#include<stdio.h> #include<conio.h> void main() { int n; printf("Enter a number:"); scanf("%d", &n); switch(n) { case 1: printf("Case one executed"); break; case 2: printf("Case two executed"); break; case 3: printf("Case three executed"); break; default: printf("invalid input"); } getch(); } **********OUTPUT********** Enter a number: 2 Case two executed |
Char keyword in C
#include<stdio.h> #include<conio.h> void main() { char a='A'; printf("Character Value of a:%c", a); getch(); } **********OUTPUT********** Character Value of a:A |
Const Keyword in C
#include<stdio.h> #include<conio.h> void main() { int x=500; printf("Value of x:%d", x); getch(); } **********OUTPUT********** Value of x:500 |
Do Keyword in C
#include<stdio.h> #include<conio.h> void main() { int i=1; do { printf("Value of i:%d ", i); while(i<=10); i=i+1; } getch(); } **********OUTPUT********** Value of i:1 2 3 4 5 6 7 8 9 10 |
Example of Double Data Type in C
#include<stdio.h> #include<conio.h> void main() { double x=76800; printf("Value of x:%d", x); getch(); } **********OUTPUT********** Value of x:76800 |
Why is if-else used in C
#include<stdio.h> #include<conio.h> void main() { int age=18; if(age>=18); { printf("Your age is greater than18"); } else { printf("Your age is less than 18"); } getch(); } **********OUTPUT********** Your age is greater than18 |
Enum Keyword in C
#include<stdio.h> #include<conio.h> enum week{Sunday=5,Monday=6,Thursday =7,Wednesday=9,Thursday=8, Friday=11,Saturday}; void main() { enum week data; data=Wednesday; printf("Value data:%d", data); getch(); } **********OUTPUT********** Value of data:9 |
Extern Keyword in C
File A.c #include<stdio.h> #include<conio.h> void main() { int x=100; printf("Value of x:%d", x); getch(); } File B.c #include<stdio.h> #include<conio.h> #include extern A.c void main() { extern int x; printf("Value of x:%d", x); getch(); } **********OUTPUT********** Value of x:100 |
Float Keyword in C
#include<stdio.h> #include<conio.h> void main() { float x=76.80; printf("Value of x:%f", x); getch(); } **********OUTPUT********** Value of x:76.80 |
Goto Keyword in C
#include<stdio.h> #include<conio.h> void main() { for(i=1; i<5; ++i) { if (i==10) goto level; } printf("i is not 10"); level: printf("level, count cannot be 10"); getch(); } **********OUTPUT********** level, count cannot be 10 |
int Keyword in C
#include<stdio.h> #include<conio.h> void main() { int x=768; printf("Value of x:%d", x); getch(); } **********OUTPUT********** Value of x:768 |
Short, Long, Signed and Unsigned Data Types
#include<stdio.h> #include<conio.h> void main() { short int a=768; long int b=65564; printf("Value of a:%d", a); printf("Value of b:%d", b); getch(); } **********OUTPUT********** Value of a:768 Value of b:65564 |
Return Keyword in C
#include<stdio.h> #include<conio.h> int add() { int a=10; int b=20; int c=a+b; return c; } int main() { printf("Value of c:%d",c); getch(); } **********OUTPUT********** Value of c:30 |
Sizeof keyword in C
#include<stdio.h> #include<conio.h> void main() { int x=76; printf("size of x:%d", sizeof(x)); getch(); } **********OUTPUT********** Size of x:4 |
Register Keyword in C
#include<stdio.h> #include<conio.h> void main() { register int x=76; printf("Value of x:%d", x); getch(); } **********OUTPUT********** Value of x:76 |
Static Keyword in C
#include<stdio.h> #include<conio.h> int add() { { static int i=0; printf("%d\n",i); i++; } } int main() { add(); add(); add(); } **********OUTPUT********** 0 1 2 |
Struct Keyword in C
#include<stdio.h> #include<string.h> struct Employee { int id; char name[50]; int salary; }; int main() { struct Employee e[10]; int n; printf("Enter Employee Number:"); scanf("%d",&n); for(int i=0;i<n;i++) { printf("Enter Employee Id:"); scanf("%d",&e[i].id); printf("Enter Employee Name:"); scanf("%s",e[i].name); printf("Enter Employee Salary:"); scanf("%d",&e[i].salary); } printf("--------------------------------\n"); for(int i=0;i<n;i++) { printf("Employee Id:%d\n",e[i].id); printf("Employee Name:%s\n",e[i].name); printf("Employee Salary:%d\n",e[i].salary); printf("--------------------------------\n"); } } **********OUTPUT********** Enter Employee Number:1 Enter Employee Id:6463 Enter Employee Name:Nivi Enter Employee Salary:67577 -------------------------------- Employee Id:6463 Employee Name: Nivi Employee Salary:67577 |
Union Keyword in C
#include<stdio.h> #include<string.h> union Employee { int id; char name[50]; int salary; }; int main() { union Employee e[10]; int n; printf("Enter Employee Number:"); scanf("%d",&n); for(int i=0;i<n;i++) { printf("Enter Employee Id:"); scanf("%d",&e[i].id); printf("Enter Employee Name:"); scanf("%s",e[i].name); printf("Enter Employee Salary:"); scanf("%d",&e[i].salary); } printf("--------------------------------\n"); for(int i=0;i<n;i++) { printf("Employee Id:%d\n",e[i].id); printf("Employee Name:%s\n",e[i].name); printf("Employee Salary:%d\n",e[i].salary); printf("--------------------------------\n"); } } **********OUTPUT********** Enter Employee Number:1 Enter Employee Id:6463 Enter Employee Name:Nivi Enter Employee Salary:67577 -------------------------------- Employee Id:67577 Employee Name:∙☺ Employee Salary:67577 |
Typedef Keyword in C
#include<stdio.h> #include<conio.h> typedef struct learncoding {
int id;
}learcoding; int main() { learncoding lc; lc.id=457; printf("Id is:%d",lc.id); getch(); } **********OUTPUT********** Id is: 457 |
Void Keyword in C
#include<stdio.h> #include<conio.h> void main() // void keyword use in c program { int x=400; printf("Value of x:%d", x); getch(); } **********OUTPUT********** Value of x:400 |
0 Comments