Week – 1 Exercises Solution

$35.00 $29.00

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; } Implement a Lex…

5/5 – (2 votes)

You’ll get a: zip file solution

 

Description

5/5 – (2 votes)

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.

  1. 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.

Week – 1 Exercises Solution
$35.00 $29.00