khalid rasheed shaikh computer programming theory 1
TRANSCRIPT
Khalid Rasheed Shaikh
Computer ProgrammingTheory 1
Programming Environment
• Command Line • IDE (Integrated Development System)
Library and Run-Time Files
• library Files• Math Library• Run-Time Object Files• Header Files• Programmer Generated Files
Writing a program
• void main(void){
printf("I can speak German"); }• Saving Programe• Making an .EXE• Compiling• Linking• Executing a Program
Errors
• Syntax Errors• Logical Errors
Basic Structure of C programs
• Function Definition• Delimiters• Statement Terminator• Program Style, Round One
o void main(void){ printf("Hello");}
The printf Function
printf("My First C Program");
Exploring the printf function
• Printing Numberso printf("Number: %d", 2) ;
• Format Specifiers• Printing String
o printf("$s is an %s" 2, "int")• Printing Characters
Variables
• Constant and Variables o Definingo Declaringo Assigning
Variables Type
• int• char• float• double
Input / Output
float flt = 2.3; printf("%.1f", flt);
The scanf() Function
float years, days; printf("Enter age in Years");scanf("%f",&years);days = years*365;printf("Your age is %.1f", days)
The Address Operator (&)
scanf("%f",&years);printf("Address = %d, value = %f ", years, &years);
Operators
• Arithmetic Operators• Operator Precedence
o (B)rackets, (O)rder, (D)ivision, (M)ultiplication, (A)ddition, (S)ubtraction
• The Reminder Operatoro answer = 13 % 5;
• Expression Vs Variableso days = years * 365
• Arithmetic Assignment Operators • Increment operators• Relational operators