CSE321 – Operating Systems Lab Lab 03: Introducing C Solved

$ 29.99
Category:

Description

Programming (02)

Summary
● Flow Statement in C
● Loops in C
● Function in C
● FILE I/O
● Command Line Arguments if statement

While Loop:

For Loop:
#include <stdio.h>
int main ()
{
/* for loop execution */
for( int a = 10; a < 20; a = a + 1 )
{ printf(“value of a: %d “, a);
} return 0;
}
Nested Loop:
Function in C

Function call by value
passing arguments to a function copies the actual value of an argument into the formal parameter of the function. In this case, changes made to the parameter inside the function have no effect on the argument.

Function call by reference
passing arguments to a function copies the address of an argument into the formal parameter. Inside the function, the address is used to access the actual argument used in the call. This means that changes made to the parameter affect the passed argument.

FILE I/O

Command Line Arguments
pass some values from the command line to your C programs when they are executed. These values are called command line arguments.
The command line arguments are handled using main() function arguments where argc refers to the number of arguments passed, and argv[] is a pointer array which points to each argument passed to the program.
It should be noted that argv[0] holds the name of the program itself and argv[1] is a pointer to the first command line argument supplied, and *argv[n] is the last argument.

Some examples of executing this program –
Lab Tasks:
1. Write a C program to check if the entered character is vowel or consonant.
2. Write a C program to check whether a triangle can be formed by the given value for the angles.
3. Write a C program to find the sum of even numbers between 1 to n.
4. Write a C program to reverse the numbers in an array.
5. Write a C program to find diameter, circumference and area of circle using function.
6. Write a C program to swap two numbers in an array using function call by reference.
7. Write a C program to open a text file and print the characters [a-z, A-Z] only from that file.
8. Write a C program to sort given numbers using command line arguments.

Reviews

There are no reviews yet.

Be the first to review “CSE321 – Operating Systems Lab Lab 03: Introducing C Solved”

Your email address will not be published. Required fields are marked *