A. No. -2 | A. No. -3 | A. No. -4 | A. No. -5 |
A. No. -6 | A. No. -7 | A. No. -8 | A. No. -9 |
A. No. -10 | A. No. -11 | A. No. -12 | A. No. -13 |
A. No. -14 | A. No. -15 | A. No. -16 | A. No. -17 |
Ch5 Assignment -1
- Draw classification chart of programming language.
- Compare program and programming language.
- Program is the product of programming language.
- Program can be created in short time period where as it takes long time period to create programming language.
- Program can solve a particular problem where as using programming language we can make to solve many problems.
- Program will be different as per user but the programming language will be same for all.
- Example of program is to calculate area of rectangle where as example of programming language is C, C++, PHP, Java etc.
- List any five third generation language.
- List any five fourth generation language.
- List any three research area of fifth generation languages.
Check Book page : 238
Ch5 Assignment -2
- List any three language translators.
- List any three interpreted programming languages. Ans: BASIC, LISP , Perl
- List any three compiler based programming languages. Ans: C, C++, Visual Basic
- Compare between compiler and interpreter.
- Draw figures of assembler, interpreter and compiler.
- Compare syntax and semantic of a programming language.
- Give an example of run time error.
Ch5 Assignment -3
- What are the three stages of program development?
- List any three program design tools.
- Write an algorithm to calculate area of square.
- Write an algorithm to calculate area of circle.
- Write an algorithm and a flowchart to calculate simple interest.
Ch5 Assignment -4
- What are the three major components of selection structure? Ans: Condition, True statement, False Statement
- List four types of selection structures. Ans: simple if , if-else, if-else ladder, nested if else
- Write an algorithm and a flowchart to check the number is positive or negative.
- Write an algorithm and a flowchart to check the number is odd or even.
- Write an algorithm and a flowchart to check the number is divisibly by 5.
Algorithm to check the number is positive or negative
Step 1: StartStep 2: Input N
Step 3: if(N>0)
Output "Positive"
else
Output "Negative"
Step 4: Stop
Algorithm to check the number is odd or even
Step 1: StartStep 2: Input N
Step 3: R= N%2
Step 4: if(R==0)
Output N is even.
else
Output N is odd.
Step 5: Stop
Algorithm to check the number is divisibly by 5
Step 1: StartStep 2: Input N
Step 3: R= N%5
Step 4: if(R==0)
Output N is divisibly by 5.
Step 5: Stop
Ch5 Assignment -5
- What are the three components of a loop?
- What happens when the condition is always true in the loop?
- Write an algorithm and a flowchart to print 100,99,98,...1. Ans:
- Write an algorithm and a flowchart to print 1 3 5 .....N Ans:
- Write an algorithm and a flowchart to display multiplication table of 5. Ans:
- Write the full form of BCD, ASCII, EBCDIC and Unicode.
Algorithm to print 100,99,98,...,1
Step 1: StartStep 2: i=100
Step 3: while(i>=1)
{
Output i
i=i-1
}
Step 4: Stop
Algorithm to print 1 3 5 .....N
Step 1: StartStep 2: i=1
Step 3: Input N
Step 4: while(i<=N)
{
Output i
i=i+2
}
Step 5: Stop
Algorithm to display multiplication table of 5
Step 1: StartStep 2: i=1
Step 3: while(i<=10)
{
Output 5*i
i=i+1
}
Step 4: Stop
Ch5 Assignment -6
- Who developed C language and when? Ans: Dennis Ritchie in 1972 AD
- List out any four major features of C langauge.
- List out the major four compenents of C program. Ans:
- Draw a figure of compilation process in C programming.
- Compare source file, object file and executable file Ans: Source File: The file which contains original code of high level language is called source file. e.g. abc.c . This is the code collection written by the programmer.
(i) Preprocessors and Header files
(ii)Comment
(iii) Declaration Part
(iv) Executable Part
Source file is translated into machine understandable form called object file. e.g. abc.obj . Object file is created by the compiler.
The linker produces an executable program located in a disk file with dot exe extension and the same name as the object file(for example, abc.obj is linked to create abc.exe).
Ch5 Assignment -7
- List any four header files and two pre-processor directives. Ans:
- What is character set?
- Write the types of comments.
- Write six types of tokesn used in c langugage.
- Compare indentifiers and keywords.
(i) #include<stdio.h>
(ii) #include<math.h>
(iii) #include<string.h>
(iv) #include<conio.h>
Two pre-processor directives are: #include and #define.
Ch5 Assignment -8
- List any four data types and any four secondary data types.
- How much memory require to hold character, integer, float and double data types?
- Compare variable and constant.
- List any five types of constants.
- List any five escape sequence constants.
- List any five type specifier characters.
Ch5 Assignment -9
- Compare simple statement and compound statement. Ans:
- List out any five types of operators of c language.
- List any five arithmetic operators and any five relation operators.
- List any three logical operators.
Simple statement:
A simple statement consists of an expression followed by a semicolon. The execution of a simple statement causes the expression to be evaluated.Example:
b=5;
c=d+e;
printf("Enter a number");
Compound statement:
A compound statement consists of several individual Statements enclosed in a pair of braces { } . It provides capability for embedding Statements within other statements.Example:
{
r=5;
area=3.14*r*r;
}
It shows a compound statement to calculate the area of the circle.
Ch5 Assignment -10
- Compare operator and expressions.
- What is operand?
- Compare implicit type casting and explicit type casting.
- List any five library functions of c language.
Ch5 Assignment -11
- List out any four input functions and output functions.
- Write syntax and example of functions: scanf() and printf().
- Write syntax and example of functions: getchar() and putchar().
- Write syntax and example of functions: gets() and puts().
Ch5 Assignment -12
- Write a C program to check whether the given number is positive.
- Write a C program to check whether the given number is odd.
- Write a C program to check whether the given number is divisible by 5.
- Write a program to check whether the given number is odd or even.
- Write a program to check whether the given number is positive or negative.
- Write a program to check whether the given number is divisible by 5 and not divisible by 10.
- Write a program to find the largest number among four numbers given by the user.
- Write a program to find the smallest number among five numbers given by the user.
- Write a program to check the given number is positive, negative or zero.
- Write a program to find the largest number among two positive numbers.
- Write a program to find the largest number among three positive numbers using nested if else statement.
- Write a program to find the given number is divisible by 5 and not by 10 using nested if else statement.
- Write a program to display the name of the day in a week, depending on the number entered through the keyboard using the switch statement.
if statement
#include<stdio.h>
main()
{
int num;
printf( " Enter any number : ");
scanf("%d",&num);
if(num>0)
printf( " %d is positive. ", num);
}
main()
{
int num;
printf( " Enter any number : ");
scanf("%d",&num);
if(num>0)
printf( " %d is positive. ", num);
}
#include<stdio.h>
main()
{
int num;
printf( " Enter any number : ");
scanf("%d",&num);
if(num%2==1)
printf( " %d is odd number. ", num);
}
main()
{
int num;
printf( " Enter any number : ");
scanf("%d",&num);
if(num%2==1)
printf( " %d is odd number. ", num);
}
#include<stdio.h>
main()
{
int num;
printf( " Enter any number : ");
scanf("%d",&num);
if(num%5==0)
printf( " %d is divisible by 5. ", num);
}
main()
{
int num;
printf( " Enter any number : ");
scanf("%d",&num);
if(num%5==0)
printf( " %d is divisible by 5. ", num);
}
if else statement
#include<stdio.h>
main()
{
int num;
printf( " Enter any number : ");
scanf("%d",&num);
if(num%2==1)
printf( " %d is odd number. ", num);
else
printf( " %d is even number. ", num);
}
main()
{
int num;
printf( " Enter any number : ");
scanf("%d",&num);
if(num%2==1)
printf( " %d is odd number. ", num);
else
printf( " %d is even number. ", num);
}
#include<stdio.h>
main()
{
int num;
printf( " Enter any number : ");
scanf("%d",&num);
if(num>0)
printf( " %d is positive. ", num);
else
printf( " %d is negative. ", num);
}
main()
{
int num;
printf( " Enter any number : ");
scanf("%d",&num);
if(num>0)
printf( " %d is positive. ", num);
else
printf( " %d is negative. ", num);
}
if else if statement
#include<stdio.h>
main()
{
int num,r1,r2;
printf( " Enter any number : ");
scanf("%d",&num);
r1=num%5;
r2=num%10;
if(r1==0&&r2!=0)
printf( " %d is divisible by 5 but not by 10.\n ", num);
else if(r1!=0&&r2!=0)
printf( " %d is not divisible by 5 and 10.\n ",num);
else
printf( " %d divisible by both 5 by 10.\n ", num);
}
main()
{
int num,r1,r2;
printf( " Enter any number : ");
scanf("%d",&num);
r1=num%5;
r2=num%10;
if(r1==0&&r2!=0)
printf( " %d is divisible by 5 but not by 10.\n ", num);
else if(r1!=0&&r2!=0)
printf( " %d is not divisible by 5 and 10.\n ",num);
else
printf( " %d divisible by both 5 by 10.\n ", num);
}
#include<stdio.h>
main()
{
int a,b,c,d;
printf( " Enter four numbers : ");
scanf("%d%d%d%d",&a,&b,&c,&d);
if(a>b&&a>c&&a>d)
printf("Largest number is %d ",a);
else if (b>a && b>c && b>d)
printf("Largest number is %d ",b);
else if(c>a && c>b && c>d)
printf("Largest number is %d ",c);
else if(d>a && d>b && d>c)
printf("Largest number is %d ",d);
else
printf("All numbers are same.");
}
main()
{
int a,b,c,d;
printf( " Enter four numbers : ");
scanf("%d%d%d%d",&a,&b,&c,&d);
if(a>b&&a>c&&a>d)
printf("Largest number is %d ",a);
else if (b>a && b>c && b>d)
printf("Largest number is %d ",b);
else if(c>a && c>b && c>d)
printf("Largest number is %d ",c);
else if(d>a && d>b && d>c)
printf("Largest number is %d ",d);
else
printf("All numbers are same.");
}
#include<stdio.h>
main()
{
int a,b,c,d,e,small;
printf( " Enter five numbers : ");
scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
if(a<b && a<c && a<d && a<e)
small=a;
else if (b<a && b<c && b<d && b<e)
small=b;
else if (c<a && c<b && c<d && c<e)
small=c;
else if (d<a && d<b && d<c && d<e)
small=d;
else
small=e;
printf("Smallest number is %d ",small);
}
main()
{
int a,b,c,d,e,small;
printf( " Enter five numbers : ");
scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
if(a<b && a<c && a<d && a<e)
small=a;
else if (b<a && b<c && b<d && b<e)
small=b;
else if (c<a && c<b && c<d && c<e)
small=c;
else if (d<a && d<b && d<c && d<e)
small=d;
else
small=e;
printf("Smallest number is %d ",small);
}
#include<stdio.h>
main()
{
int num;
printf(" Enter any number : ");
scanf("%d",&num);
if(num>0)
printf(" %d is positive number. ",num);
else if(num<0)
printf(" %d is negative number. ",num);
else
printf(" You entered zero. ");
}
main()
{
int num;
printf(" Enter any number : ");
scanf("%d",&num);
if(num>0)
printf(" %d is positive number. ",num);
else if(num<0)
printf(" %d is negative number. ",num);
else
printf(" You entered zero. ");
}
nested if else statement
#include<stdio.h>
main()
{
int a,b;
printf(" Enter two numbers : ");
scanf("%d%d",&a,&b);
if(a>0 && b>0)
{
if(a>b)
printf("%d is greater.",a);
else
printf("%d is greater.",b);
}
else
printf(" Sorry ! You entered negative numbers. ");
}
main()
{
int a,b;
printf(" Enter two numbers : ");
scanf("%d%d",&a,&b);
if(a>0 && b>0)
{
if(a>b)
printf("%d is greater.",a);
else
printf("%d is greater.",b);
}
else
printf(" Sorry ! You entered negative numbers. ");
}
switch statement
#include<stdio.h>
main()
{
int choice;
printf("Enter your choice betwen 1-7 : ");
scanf("%d",&choice);
switch(choice)
{
case 1:
printf("Sunday");
break;
case 2:
printf("Monday");
break;
case 3:
printf("Tuesday");
break;
case 4:
printf("Wednesday");
break;
case 5:
printf("Thursday");
break;
case 6:
printf("Friday");
break;
case 7:
printf("Saturday");
break;
default:
printf("Wrong Choice");
}
}
main()
{
int choice;
printf("Enter your choice betwen 1-7 : ");
scanf("%d",&choice);
switch(choice)
{
case 1:
printf("Sunday");
break;
case 2:
printf("Monday");
break;
case 3:
printf("Tuesday");
break;
case 4:
printf("Wednesday");
break;
case 5:
printf("Thursday");
break;
case 6:
printf("Friday");
break;
case 7:
printf("Saturday");
break;
default:
printf("Wrong Choice");
}
}
Ch5 Assignment -13
- Using while loop, display your name 10 times on screen.
- Using while loop, display the series:
10 9 8 ... to 1. - Using while loop, calculate and display sum of odd natural numbers up to n.
#include<stdio.h>
main()
{
int i=1;
while(i<=10)
{
printf(" (%d) Kripa Thapa\n", i);
i++;
}
}
#include<stdio.h>
main()
{
int i=1;
while(i>=1)
{
printf(" %d\t ", i);
i--;
}
}
#include<stdio.h>
main()
{
int i=1,n,sum=0;
printf("Enter the value of n: ");
scanf("%d",&n);
while(i<=n)
{
sum=sum+i;
i=i+2;
}
printf("Sum of odd natural numbers upto %d is %d ",n,sum);
}
Goto TopCh5 Assignment -14
- Using do while loop, calculate and display the series: 1 8 27 to 10th terms.
- Using do while loop, display the series: 15 9 ... up to 20th term.
- Using do while loop, display multiplication table of any number given by the user.
Ch5 Assignment -15
- Write a program to display multiplication table of given number.
- Write a program to display the multiplication table with NxN terms.
- Write a program to display the odd series 1 3 5 .... N using continue statement.
- Write a program to show an infinite loop.
- Write a program to display the following output.
333 22 1
Ch5 Assignment -16
- Define array and array index.
- List any two advantages and disadvantages of array.
- How is one dimensional array of integers initialized?
- How is two dimensional array of integers initialized?
- Write a program to find the smallest among the given set of numbers.
- Write a program to transpose of given matrix with size 2x2.
- Write a program to subtract two 2x2 matrices.
Ch5 Assignment -17
- Differentiate an array and a string.
- What is null character in a string?
- Compare between scanf() and gets() while entering a string.
- Write syntax and an example to define a table of strings.
- List any two string handling functions with respective syntax.
End of Ch-5 Assignment