250 likes | 393 Vues
This document provides an overview of C programming, a versatile middle-level programming language designed by Ken Thompson and Dennis Ritchie in 1970 for system software but extensively used for developing portable application software as well. Key topics include basic syntax, data types, operators (arithmetic, relational), and program structure in C. Sample code snippets illustrate concepts like integer input, character handling, and the use of special characters. Ideal for beginners, this guide lays the groundwork for further exploration into C programming techniques and applications.
E N D
Data structure and c K.S. Prabhu Letterer All Deaf Educational Technology
Introduction in c • C program made by ken Thompson and Dennis Ritchie in 1970. • Developed by martin Richards. • Although C was designed for implementing System Software. • It is also widely used for developing portable Application Software.
Means • C program mean compiler programming • C is a Program language. • It is a middle level language • This programming language is designed to help as Data process. • Data process is numbers, characters and strings. • Its provide use of output display
The Character Set in C • Upper case alphabets: • It is capital word alphabets Example: • A B C D E …….Z
Sample code Program fflush(stdin); printf("Enter power to raise to:"); scanf("%d",&Y); fflush(stdin); power(&X,&Y); …………….. ……………… ………………. getch(); #include<stdio.h> power(int*m,int*n); void main() { int X,Y; clrscr(); printf("Enter number:"); scanf("%d",&X);
2) Lower case alphabets: • It is small word through called by lower case alphabets Example: • a b c d e……..z
Sample Code Program #include<stdio.h> power(int*m,int*n); void main() { intx,y; clrscr(); printf("Enter number:"); scanf("%d",&x); • fflush(stdin); • printf("Enter power to raise to:"); • scanf("%d",&y); • fflush(stdin); • power(&x,&y); • …………….. • ……………… • ………………. • getch(); • }
3) Numbered or digital characters: • It means also used by number or Ditital characters. Example: • 0 1 2 3 4 5 6 7 8 9
Sample code Program #include<stdio.h> void main() { inta,b; char cmd[25]; ………. ………. ………. } #include<stdio.h> #include<conio.h> void main() { char name[21],addrs[31]; clrscr(); puts("Enter your Name to a maximum of 20 characters"); puts("Enter your Address to a maximum of 30 characters"); …… …… }
4) Arithmetic Operators: • It means arithmetic program through operated by arithmetic operators. • Example: • + , %, *, - • Plus,Division,Multiple and Minus
Sample Code Program #include<stdio.h> sum(inta,int b); void main() { intx,y,value; scanf("%d%d",&x,&y); value=sum(x,y); printf("Total is %d\n",value); } sum(inta,int b) { return a+b; } OUTPUT Output:: 5 3 Total is 8
5) Relational Operators: • It is numberic and case character relation operated by relational operators. • Syntax:- • < >, < = >, = , = • Less and Great, Less Equal Great,Equal • Example • Example: • 4>5,6<4,4=4
Sample Code Program #include<stdio.h> #include<conio.h> void main() { intI,sum,num; clrscr(); sum=num=0; for(I=0;I<8;I=I+1) { …….. …….. …….. if(num<=0) getch(); }
6) curly brace: Syntax:- { } • { → Starting curely space • } → Ending curely space • Example: • {……………………}
Sample Code Program { Head of curly ………….. ………….. ………….. { Sub of curly ………….. ………….. } Sub End of curly ………. ………. getch(); } Head End of Curly
7) Square braces: Syntax:- [ ] Example: • Float [4] ; • String [9] ;
Sample Code program #include<stdio.h> #include<conio.h> void main() { char str1[101],str2[101]; intdiff,I=0; clrscr(); ……….. ……….. getch(); }
8) Parenthèses braces :- • Syntax:- • ( ) Example: • Print (………) • Scant (………)
Sample Code program Program:: #include<stdio.h> #include<conio.h> void main() { char in_str[21]; clrscr(); puts("Enter a string to a maximum of 20 characters"); gets(in_str); fflush(stdin); puts(in_str); getch(); }
9) Special characters: • It mean other syntax characters Syntax:- • &, !, #, ?, ~, `, @, ^, $, |,:,; .
Sample code program #include<stdio.h> #include<conio.h> void main() { char yn; clrscr(); do { puts("enter y/n(yes/no)"); yn=getchar(); fflush(stdin); if(yn!='y'&&yn!='n') puts("invalid input"); } while(yn!='y'&&yn!='n'); getch(); }