Starting from:
$35

$29

Week – 1 Exercises Solution

Given input file(input.c):

/*Sum of Natural Numbers

using for loop*/

#include <stdio.h>
int main () {
int n, i, sum = 0;

printf("Enter a positive integer: ");

scanf("%d", &n);
//loop starts here
for (i = 1; i <= n; ++i) {

sum += i;
}

printf("Sum = %d", sum);
return 0;
}


    1. Implement a Lex program to copy the content of input file (input.c) to another file (input_copied.c) and remove single-line comments, multi-line comments and whitespaces in input_copied.c file.

    2. Implement a Lex program to print the count and line number of identifiers, keywords and operators in input_copied.c file.



Upload your code with its output in .zip or .rar.

More products