CSC103-Programming Fundamentals: Lab Work - 1
CSC103-Programming Fundamentals: Lab Work - 1
CSC103-Programming Fundamentals
Submitted by:
Zagim Murtza Awan
SP19-BCS-148
B
Submitted to:
Mr. Abdul Karim Shahid
CSC103-Programming Fundamentals 1
Exercise 1: Print following shape using simple printf statements (You may print these shapes
vertically in one program)
(1)
Code:
#include<stdio.h>
int main()
printf(" * \n");
return 0;
CSC103-Programming Fundamentals 1
Output:
(2)
Code:
CSC103-Programming Fundamentals 1
Output:
(3)
Code:
/* This programme is prepared by ZAGIM MURTZA AWAN Reg no.: SP19-BCS-
148 Section: B on 12/09/1019. This programme is used to print shapes of different types.*/
#include<stdio.h>
int main()
{
printf("* \n");
printf("** \n");
printf("*** \n");
printf("**** \n");
printf("***** \n");
return 0;
}
CSC103-Programming Fundamentals 1
Output:
(4)
Code:
Output:
CSC103-Programming Fundamentals 1
(5)
Code:
Output:
(6)
Code:
/* This programme is prepared by ZAGIM MURTZA AWAN Reg no.: SP19-BCS-
148 Section: B on 11/9/2019. This programme prints shape*/
#include<stdio.h>
int main()
{
printf(" * \n"); /*\n is used for new line*/
printf(" ** \n");
printf(" *** \n");
printf(" **** \n");
printf(" ***** \n");
return 0;
}
CSC103-Programming Fundamentals 1
Output:
Exercise 2: Write a program that prints the numbers 1 to 4 on the same line. Write the program using the
following methods.
a)
Code:
Output:
CSC103-Programming Fundamentals 1
b)
Code:
Output:
c)
Code:
Output:
CSC103-Programming Fundamentals 1
Exercise 3: Write a C-Program to perform the simple arithmetic operations (addition,
subtraction, multiplication, division, remainder).
Code:
/* This programme is prepared by ZAGIM MURTZA AWAN Reg no.: SP19-BCS-
148 Section: B on 11/9/2019. This program is to perform arithmetic operations on two numbers input by
user*/
#include<stdio.h>
int main()
{
int a,b;/*Declaration*/
print("Enter the values of a and b");
scanf("%d%d",&a,&b);
printf("the sum of %d and %d is %d",a,b,a+b);/*Addition(arithmetic operation)*/
printf("the difference of %d and %d is %d",a,b,a-b);/*subtraction(arithmetic operation )*/
printf("the product of %d and %d is %d",a,b,a*b );/*multiplication(arithmetic operation)*/
printf("the quotient of %d and %d is %d",a,b,a/b);/*division(arithmetic operation)*/
printf("the remainder of %d and %d is %d",a,b,a%b);/*Modulus(arithmetic operation)*/
return 0;
}
Output:-
CSC103-Programming Fundamentals 1