Professional Documents
Culture Documents
Submitted to:
Nusrat Zerin Zenia
Lecturer
Institute of Information Technology
Jahangirnagar University
Submitted by:
Tania Sultana
Roll Number- 1575
Reg. Number- 47570
Batch-8th
1
Table of Contents
Answer of question number 1....................................................................................................3
Arithmetic expression............................................................................................................3
Conditional operator...............................................................................................................3
Loop in C................................................................................................................................3
Syntax error............................................................................................................................5
Function arguments................................................................................................................8
The program...........................................................................................................................8
The program:........................................................................................................................10
2
Answer of question number 1
Arithmetic expression
An arithmetic expression is an expression in code which consists of a numeric value. In
arithmetic expression, there are two kinds of numeric values, integers (whole numbers), and
real or floating-point numbers (numbers containing a decimal point).
Conditional operator
Conditional operators used to evaluate a condition that’s applied to one or two Boolean
expressions. The result of the evaluation is either true or false.
Loop in C
In programming, a loop is used to repeat a block of code until the specified condition is met.
For loop
While loop
While (testExpression)
3
// statements inside the body of the loop
Do {
Statement(s);
} while( condition );
4
Answer of question number 2
Syntax error
There are various kinds of errors that can occur in a program, which can be categorized into
syntax errors, runtime errors, and logical errors.
Mistakes in using the language is called Syntax errors. Examples of syntax errors are missing
a comma or a quotation mark, or misspelling a word.
For example, the following character vector is missing the end quote:
↑
If this type of error is typed in a script or function using the Editor, the Editor will flag it.
Error 3: Each undeclared identifier is reported only once for each function it appears in
5
Expected expression before ‘if’
In the line }
6
Answer of question number 3
The codes output:
Enter the number of rows: 1
12
12
123
Similarly, with each increasing value, another row will be added with and output will be
1234, 12345, 123456 & so on like following,
(n+1)(n+2)
(n+1)(n+2)(n+3)
(n+1)(n+2)(n+3)(n+4)
………………………………………….
7
Answer of question number 4
Function arguments
The function-arguments property means array-like object corresponding to the arguments
passed to a function. Use the simple variable arguments instead. This property is restricted to
non-strict functions.
#include<stdio.h>
{{
Int main() {
Int a, b;
Printf(“\nThe sum of two numbers is done by function with argument and with return
Return 0;
The program
#include<stdio.h>
Void sqr_it(intnum)
Printf(“%d”,num*num);
Int main()
8
{
Intnum=5;
Sqr_it(num);
Return 0;
9
Answer of question number 5
The program:
#include<stdio.h>
int main() {
intn,i;
int sum=0;
scanf("%d",&n);
sum = (n * (n + 1)) / 2;
if (i!=n)
printf("%d = %d ",i,sum);
return 0;
10