You are on page 1of 6

Dated:28-01-2018

PROGRAMMING FUNDAMENTAL (SWE-102)


ASSIGNMENT#01
Part A (theoratical)
Q1. What is a Variable?
A. A variable is a space holder in computer’s memory for certain kind of data
which was given a name for easy reference.
Q2. getch( ) VS getche( )?
A.
getch( ) getche( )
 getch() reads only single  getche() reads single character
character from the screen. from keyboard and displays it
 It doesn’t have echo(display) on immediately on output screen.
screen.  e stands for echo so it has echo
 It is mostly used at the end of on screen.
program.  It is used when when user want
to display a character.
Q3. How many keywords in C language define shortly?
A. There are 32 keywords in C language. They are given below,
1. auto,
2. break,
3. case,
4. char,
5. const,
6. continue,
7. default,
8. do,
9. double,
10.else,
11.erum,
12.extern,
13.float,
14.far,
15.for,
16.goto,
17.if,
18.int,
19.long,

Prepared by Engr.Sumreena Bano.


Lecturer,
Computer Engineering Department.
Dated:28-01-2018

20.near,
21.register,
22.return,
23.short,
24.signed,
25.static,
26.struct,
27.switch,
28.typedef,
29.union,
30.unsigned,
31.void,
32.while.
Q5. Define Memory modules in C language?
A. Six memory modules are there in C language. Namely small, compact,
medium, large, and huge.
Small have 64kb of code and data storage.
Compact have 64k of code and data storage.
Medium, Large and Huge exceed 64 of code and data storage.

Part B (Programming)
Q1.Write a program using conditional operators to determine whether a year
entered through the keyboard is a leap year or not?
Code
#include<stdio.h>
main( )
{
int a=1,b; \\b=2016
scanf(“%d”,&b);
if(b=a*4)
printf(“Year entered is a leap year”);
else
printf(“Year entered is not a leap year”);
}
Output

Prepared by Engr.Sumreena Bano.


Lecturer,
Computer Engineering Department.
Dated:28-01-2018

Q2. Write a program to find the greatest of the three numbers entered through the
keyboard. Using conditional operators.
Code
#include<stdio.h>
main( )
{
int A,B,C; \\Declaration of integers,A=1,B=3,C=6
scanf(“%d%d%d”,&A,&B,&C);
if(A>B>=C) || (A>C>=B)
printf(“A is the greatest number”);
else
{
if(B>A>=C) || (B>C>=A)
printf(“B is the greatest number”);
else
{
if(C>A>=B) || (C>B>=A)
printf(“C is the greatest number”);
}
}
}
Output

Q3. Write a program to check whether an integer entered by the user is odd or
even.

Code

#include<stdio.h>
Prepared by Engr.Sumreena Bano.
Lecturer,
Computer Engineering Department.
Dated:28-01-2018

main( )
{
int a; \\Declaration of integer, a=83
scanf(“%d”,&a);
if(a/2)
{
printf(“Integer entered is odd”);
}
else
{
printf(“Integer entered is even”);
}
}
Output

Q4. Write a program to give bonus according to grade of employees. There are
only following three grades available. By using ternary operator.

Employee Grades Bonus


101 1000/-
102 1500/-
103 2000/=

Code
#include<stdio.h>
main( )
{
int grade; \\Declaration of integers
scanf(“%d”,&grade); \\grade=103
if (grade==101)
printf(“Grade bonus: 1000”);
else

Prepared by Engr.Sumreena Bano.


Lecturer,
Computer Engineering Department.
Dated:28-01-2018

{
if(grade==102)
printf(“Grade bonus:1500”);
else
{
If(grade==103)
Printf(“Grade bonus: 2000”);
}
}
}
Output

Q5. Write a program to create a Marksheet of 5 courses and print Percentage and
Grades by using Logical Operators.
Code
#include<stdio.h>
main( )
{
int m, i, e, u, c, A; \\Declaration of integers, m=98, i=90, e=83, u=78, c=92
scanf(“%d%d%d%d%d”,&m,&i,&e,&u,&c);
A=m*i*e*u*c/500*100;
if(A>60)
printf(“First division”);
else if(A<=60 && A>50)
printf(“Second division”);
else if(A<=50 && A>40)
printf(“Third division”);
else
printf(“Fail”);
}
Output

Prepared by Engr.Sumreena Bano.


Lecturer,
Computer Engineering Department.
Dated:28-01-2018

Submitted Date: 1st February 2018

Prepared by Engr.Sumreena Bano.


Lecturer,
Computer Engineering Department.

You might also like