CSE 332 - 201-15-3452 - Lab-Report 03
CSE 332 - 201-15-3452 - Lab-Report 03
Submitted To:
Mr. Mushfiqur Rahman
Senior Lecturer
Department of CSE
Daffodil International University
Submitted By:
Name : Avishek Das
ID : 201-15-3452
Section : PC-F
Department of CSE
Ans :
#include<stdio.h>
#include<string.h>
int main()
char str[50];
scanf("%[^ #]",str);
int i,line=0;
for(i=0;str[i]!='\0';i++)
if(str[i]=='\n')
line++;
return 0;
Screenshot
Question: 02
Write a C program that will take multiple lines as input and identify the
comments if there any.
Ans :
#include <stdio.h>
#include <string.h>
int main() {
char str[100];
int Q;
scanf("%[^#]", str);
int i, j, k = 1, k1 = 1, L, line = 0, m = 0;
printf("%c", str[j]);
printf("\n");
k++;
m = 1;
break;
}
printf("%c", str[L]);
if (m == 1)
break;
printf("\n");
k1++;
return 0;
Screenshot
Question: 03
Write a C program that will take multiple lines as input and remove the
single line/multiple line comments if there any.
Ans :
#include<stdio.h>
#include<string.h>
#include<conio.h>
void clrscr()
system("@cls||clear");
int main() {
clrscr();
char str[128];
scanf("%[^;]s", str);
int l=strlen(str),j=0;
char tmp[128];
for(int i=0;i<l;i++){
if(str[i]=='/' && str[i+1]=='/'){
for(;i<l-1;i++){
if(str[i]==10){
break;
for(;i<l;i++){
i++;
break;
else {
//printf("%d %c \n",i,str[i]);
tmp[j]=str[i];
j++;
}
int len=strlen(tmp);
for(int i=0;i<len;i++){
printf("%c",tmp[i]);
}printf("\n");
return 0;
Screenshot