Professional Documents
Culture Documents
Computing Fundamentals: Dr. Muhammad Yousaf Hamza
Computing Fundamentals: Dr. Muhammad Yousaf Hamza
• Final Exam
January 18–25, 2020
int main( )
{ //Our First C Program
int x, y, z;
x = 5;
y = 7; Function declaration in C
z = x + y;
printf(“%d", z);
getchar(); The program will run and close unless we add this statement i.e. program waits
for an input from user before proceeding any further
return 0; Note that we're writing a function so we have to return a value hence "return 0"
printf(“%d", z);
%d is used for digits
%c is used to display character
%f for float variable
%s for string variable
getchar();
return 0;
}
12
Dr. Muhammad Yousaf Hamza
#include <stdio.h>
int main( )
{
int x, y, z;
x = 5;
y = 7;
z = x + y;
getchar();
return 0;
}
Sum is 12Difference is -2
Dr. Muhammad Yousaf Hamza
#include <stdio.h>
int main( )
{
int x, y, z, m;
x = 5;
y = 7;
z = x + y;
m = x - y;
getchar();
return 0;
}
Sum is 12
Difference is -2
Dr. Muhammad Yousaf Hamza
#include <stdio.h>
int main( )
{
int x = 5, y = 7, z; // initialization with declaration
z = x + y;
printf(“%d", z);
getchar();
return 0;
}
x = x + 3;
printf(“%d\n", x);
printf(“%d\n", x*6);
printf(“%d\n", x);
getchar();
return 0;
}
Dr. Muhammad Yousaf Hamza
#include <stdio.h>
int main( )
{
int x;
x = 5;
printf(“%d\n", x); // 5
x = x + 3;
printf(“%d“\n, x); // 8
printf(“%d\n", x*6); // 48
printf(“%d\n", x); // 8
getchar();
return 0;
}
Dr. Muhammad Yousaf Hamza