write a c program to identify whether a given line is a comment or not.

0 votes
asked Jan 11 by (120 points)
use for loop

1 Answer

0 votes
answered Jan 22 by Jyothi_Rk
#include <stdio.h>
#include <string.h>
#define max 100
void main ()
{
    int a,b;
    char arr[max];
    char dest[2];
    printf("Enter the line\n");
    scanf("%s",arr);
    strncpy(dest,arr,2);
    if ((a=strncmp(dest,"//",2))  && (b=strncmp(dest,"/*",2)))
        printf("not Comment\n");
    else
        printf("Comment\n");

}
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...